Title: [123331] trunk/Source/WebKit2
Revision
123331
Author
[email protected]
Date
2012-07-23 04:37:26 -0700 (Mon, 23 Jul 2012)

Log Message

[EFL][WK2] ProcessExecutablePath is required
https://bugs.webkit.org/show_bug.cgi?id=89719

Patch by KwangYong Choi <[email protected]> on 2012-07-23
Reviewed by Kenneth Rohde Christiansen.

Added executablePathOfWebProcess and executablePathOfPluginProcess.
It's used for getting the location of WebProcess and PluginProcess.

* PlatformEfl.cmake: Added LIBEXECDIR definition
* Shared/efl/ProcessExecutablePathEfl.cpp: Added.
(WebKit):
(WebKit::findWebKitProcess):
(WebKit::executablePathOfWebProcess): Get the absolute path of WebProcess
(WebKit::executablePathOfPluginProcess): Get the absolute path of PluginProcess
* UIProcess/Launcher/efl/ProcessLauncherEfl.cpp:
(WebKit::ProcessLauncher::launchProcess): Modified to use above routines

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (123330 => 123331)


--- trunk/Source/WebKit2/ChangeLog	2012-07-23 11:27:34 UTC (rev 123330)
+++ trunk/Source/WebKit2/ChangeLog	2012-07-23 11:37:26 UTC (rev 123331)
@@ -1,3 +1,22 @@
+2012-07-23  KwangYong Choi  <[email protected]>
+
+        [EFL][WK2] ProcessExecutablePath is required
+        https://bugs.webkit.org/show_bug.cgi?id=89719
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Added executablePathOfWebProcess and executablePathOfPluginProcess.
+        It's used for getting the location of WebProcess and PluginProcess.
+
+        * PlatformEfl.cmake: Added LIBEXECDIR definition
+        * Shared/efl/ProcessExecutablePathEfl.cpp: Added.
+        (WebKit):
+        (WebKit::findWebKitProcess):
+        (WebKit::executablePathOfWebProcess): Get the absolute path of WebProcess
+        (WebKit::executablePathOfPluginProcess): Get the absolute path of PluginProcess
+        * UIProcess/Launcher/efl/ProcessLauncherEfl.cpp:
+        (WebKit::ProcessLauncher::launchProcess): Modified to use above routines
+
 2012-07-23  Christophe Dumez  <[email protected]>
 
         WebKit2 needs layoutTestController.setAlwaysAcceptCookies

Modified: trunk/Source/WebKit2/PlatformEfl.cmake (123330 => 123331)


--- trunk/Source/WebKit2/PlatformEfl.cmake	2012-07-23 11:27:34 UTC (rev 123330)
+++ trunk/Source/WebKit2/PlatformEfl.cmake	2012-07-23 11:37:26 UTC (rev 123331)
@@ -24,6 +24,7 @@
     Shared/efl/NativeWebKeyboardEventEfl.cpp
     Shared/efl/NativeWebWheelEventEfl.cpp
     Shared/efl/NativeWebMouseEventEfl.cpp
+    Shared/efl/ProcessExecutablePathEfl.cpp
     Shared/efl/WebEventFactory.cpp
     Shared/efl/WebCoreArgumentCodersEfl.cpp
 
@@ -213,6 +214,9 @@
 ADD_DEFINITIONS(-DTEST_RESOURCES_DIR=\"${TEST_RESOURCES_DIR}\"
     -DTEST_THEME_DIR=\"${THEME_BINARY_DIR}\"
     -DGTEST_LINKED_AS_SHARED_LIBRARY=1
+    -DLIBEXECDIR=\"${CMAKE_INSTALL_PREFIX}/${EXEC_INSTALL_DIR}\"
+    -DWEBPROCESSNAME=\"${WebProcess_EXECUTABLE_NAME}\"
+    -DPLUGINPROCESSNAME=\"${PluginProcess_EXECUTABLE_NAME}\"
 )
 
 ADD_LIBRARY(ewk2UnitTestUtils

Added: trunk/Source/WebKit2/Shared/efl/ProcessExecutablePathEfl.cpp (0 => 123331)


--- trunk/Source/WebKit2/Shared/efl/ProcessExecutablePathEfl.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/Shared/efl/ProcessExecutablePathEfl.cpp	2012-07-23 11:37:26 UTC (rev 123331)
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ProcessExecutablePath.h"
+
+#include "FileSystem.h"
+#include <libgen.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <wtf/StdLibExtras.h>
+#include <wtf/text/CString.h>
+
+namespace WebKit {
+
+static String findProcessPath(const char* processName)
+{
+#if OS(UNIX)
+    char readLinkBuffer[PATH_MAX] = {0};
+
+#if OS(LINUX)
+    ssize_t result = readlink("/proc/self/exe", readLinkBuffer, PATH_MAX);
+#else
+    ssize_t result = readlink("/proc/curproc/file", readLinkBuffer, PATH_MAX);
+#endif
+    if (result > 0) {
+        char* executablePathPtr = dirname(readLinkBuffer);
+        String executablePath = WebCore::pathByAppendingComponent(String(executablePathPtr), processName);
+
+        // Checks whether process exist on the current path.
+        struct stat fileStat;
+        if (!stat(executablePath.utf8().data(), &fileStat))
+            return executablePath;
+    }
+#endif
+
+    return WebCore::pathByAppendingComponent(String(LIBEXECDIR), processName);
+}
+
+String executablePathOfWebProcess()
+{
+    DEFINE_STATIC_LOCAL(const String, webKitWebProcessName, (findProcessPath(WEBPROCESSNAME)));
+
+    return webKitWebProcessName;
+}
+
+String executablePathOfPluginProcess()
+{
+    DEFINE_STATIC_LOCAL(const String, webKitPluginProcessName, (findProcessPath(PLUGINPROCESSNAME)));
+
+    return webKitPluginProcessName;
+}
+
+} // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/Launcher/efl/ProcessLauncherEfl.cpp (123330 => 123331)


--- trunk/Source/WebKit2/UIProcess/Launcher/efl/ProcessLauncherEfl.cpp	2012-07-23 11:27:34 UTC (rev 123330)
+++ trunk/Source/WebKit2/UIProcess/Launcher/efl/ProcessLauncherEfl.cpp	2012-07-23 11:37:26 UTC (rev 123331)
@@ -21,11 +21,10 @@
 #include "ProcessLauncher.h"
 
 #include "Connection.h"
+#include "ProcessExecutablePath.h"
 #include <WebCore/FileSystem.h>
 #include <WebCore/ResourceHandle.h>
 #include <WebCore/RunLoop.h>
-#include <libgen.h>
-#include <unistd.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/WTFString.h>
 
@@ -45,38 +44,26 @@
     if (!pid) { // child process
         close(sockets[1]);
         String socket = String::format("%d", sockets[0]);
-        String processName;
+        String executablePath;
         switch (m_launchOptions.processType) {
         case WebProcess:
-            processName = "WebProcess";
+            executablePath = executablePathOfWebProcess();
             break;
         case PluginProcess:
-            processName = "PluginProcess";
+            executablePath = executablePathOfPluginProcess();
             break;
         default:
             ASSERT_NOT_REACHED();
             return;
         }
 
-        String executablePath;
-        char readLinkBuffer[PATH_MAX];
-        memset(readLinkBuffer, 0, PATH_MAX);
-        ssize_t result = readlink("/proc/self/exe", readLinkBuffer, PATH_MAX);
-
-        if (result == -1)
-            executablePath = String("/usr/bin");
-        else {
-            char* executablePathPtr = dirname(readLinkBuffer);
-            executablePath = String(executablePathPtr);
-        }
-        String fullPath = executablePath + "/" + processName;
 #ifndef NDEBUG
         if (m_launchOptions.processCmdPrefix.isEmpty())
 #endif
-            execl(fullPath.utf8().data(), processName.utf8().data(), socket.utf8().data(), static_cast<char*>(0));
+            execl(executablePath.utf8().data(), executablePath.utf8().data(), socket.utf8().data(), static_cast<char*>(0));
 #ifndef NDEBUG
         else {
-            String cmd = makeString(m_launchOptions.processCmdPrefix, ' ', fullPath, ' ', socket);
+            String cmd = makeString(m_launchOptions.processCmdPrefix, ' ', executablePath, ' ', socket);
             if (system(cmd.utf8().data()) == -1) {
                 ASSERT_NOT_REACHED();
                 return;
@@ -92,7 +79,6 @@
         ASSERT_NOT_REACHED();
         return;
     }
-
 }
 
 void ProcessLauncher::terminateProcess()
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to