Changeset 161020 in webkit


Ignore:
Timestamp:
Dec 23, 2013 2:07:40 PM (10 years ago)
Author:
zandobersek@gmail.com
Message:

[GTK][WK2] Simplify ProcessExecutablePathGtk
https://bugs.webkit.org/show_bug.cgi?id=126173

Reviewed by Martin Robinson.

Don't store process name strings in global variables -- each of the names is only used in the relevant
function, so the string can be directly passed into the findWebKitProcess function call.

Simplify the findWebKitProcess function. Make the execDirectory variable static so that g_getenv is only
called once, as it's not expected for the WEBKIT_EXEC_PATH environment variable to change during the runtime.

Introduce the getExecutablePath helper function that gets the current executable path and, if non-null, returns
the directory path of that executable. The helper function preserves the small performance improvement of querying
and processing the executable path only once.
The return value of getExecutablePath is stored in a static variable and is used to construct the process path
if the executable path was successfully retrieved.

  • Shared/gtk/ProcessExecutablePathGtk.cpp:

(WebKit::getExecutablePath):
(WebKit::findWebKitProcess):
(WebKit::executablePathOfWebProcess):
(WebKit::executablePathOfPluginProcess):
(WebKit::executablePathOfNetworkProcess):

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r161018 r161020  
     12013-12-23  Zan Dobersek  <zdobersek@igalia.com>
     2
     3        [GTK][WK2] Simplify ProcessExecutablePathGtk
     4        https://bugs.webkit.org/show_bug.cgi?id=126173
     5
     6        Reviewed by Martin Robinson.
     7
     8        Don't store process name strings in global variables -- each of the names is only used in the relevant
     9        function, so the string can be directly passed into the findWebKitProcess function call.
     10
     11        Simplify the findWebKitProcess function. Make the execDirectory variable static so that g_getenv is only
     12        called once, as it's not expected for the WEBKIT_EXEC_PATH environment variable to change during the runtime.
     13
     14        Introduce the getExecutablePath helper function that gets the current executable path and, if non-null, returns
     15        the directory path of that executable. The helper function preserves the small performance improvement of querying
     16        and processing the executable path only once.
     17        The return value of getExecutablePath is stored in a static variable and is used to construct the process path
     18        if the executable path was successfully retrieved.
     19
     20        * Shared/gtk/ProcessExecutablePathGtk.cpp:
     21        (WebKit::getExecutablePath):
     22        (WebKit::findWebKitProcess):
     23        (WebKit::executablePathOfWebProcess):
     24        (WebKit::executablePathOfPluginProcess):
     25        (WebKit::executablePathOfNetworkProcess):
     26
    1272013-12-23  Zan Dobersek  <zdobersek@igalia.com>
    228
  • trunk/Source/WebKit2/Shared/gtk/ProcessExecutablePathGtk.cpp

    r155934 r161020  
    3636namespace WebKit {
    3737
    38 const char* gWebKitWebProcessName = "WebKitWebProcess";
    39 const char* gWebKitPluginProcessName = "WebKitPluginProcess";
    40 const char* gWebKitNetworkProcessName = "WebKitNetworkProcess";
     38static String getExecutablePath()
     39{
     40    CString executablePath = getCurrentExecutablePath();
     41    if (!executablePath.isNull())
     42        return directoryName(filenameToString(executablePath.data()));
     43    return String();
     44}
    4145
    4246static String findWebKitProcess(const char* processName)
    4347{
    44     const char* execDirectory = g_getenv("WEBKIT_EXEC_PATH");
     48    static const char* execDirectory = g_getenv("WEBKIT_EXEC_PATH");
    4549    if (execDirectory) {
    4650        String processPath = pathByAppendingComponent(filenameToString(execDirectory), processName);
     
    4953    }
    5054
    51     static bool gotExecutablePath = false;
    52     static String executablePath;
    53     if (!gotExecutablePath) {
    54         gotExecutablePath = true;
    55 
    56         CString executableFile = getCurrentExecutablePath();
    57         if (!executableFile.isNull())
    58             executablePath = directoryName(filenameToString(executableFile.data()));
    59     }
    60 
     55    static String executablePath = getExecutablePath();
    6156    if (!executablePath.isNull()) {
    6257        String processPath = pathByAppendingComponent(executablePath, processName);
     
    7065String executablePathOfWebProcess()
    7166{
    72     return findWebKitProcess(gWebKitWebProcessName);
     67    return findWebKitProcess("WebKitWebProcess");
    7368}
    7469
    7570String executablePathOfPluginProcess()
    7671{
    77     return findWebKitProcess(gWebKitPluginProcessName);
     72    return findWebKitProcess("WebKitPluginProcess");
    7873}
    7974
     
    8176String executablePathOfNetworkProcess()
    8277{
    83     return findWebKitProcess(gWebKitNetworkProcessName);
     78    return findWebKitProcess("WebKitNetworkProcess");
    8479}
    8580#endif
Note: See TracChangeset for help on using the changeset viewer.