Support the method to set WebProcess executable path explicitly
authorYunchan Cho <yunchan.cho@samsung.com>
Wed, 21 Aug 2013 06:49:08 +0000 (15:49 +0900)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Tue, 10 Sep 2013 09:49:47 +0000 (09:49 +0000)
[Title] Support the method to set WebProcess executable path that is forked/executed by UIProcess.
[Issue#] DCM-2299
[Problem] Some tizen device api based on tizen 'appid' doesn't work in WebProcess.
[Cause] Tizen Webkit considers only web app process model, that has 1UIProcess and 1WebProcess.
        But, web-provider for dynamic box, has 1UIProcess and NWebProcess.
        And the N WebProcesses must has different /proc/self/cmdline from each other,
        because some tizen device api uses 'appid' using app_manager API, which reads /proc/self/cmdline of the WebProcess internally.
        Currently, forked all WebProcesses has '/usr/bin/WebProcess' as /proc/self/cmdline value.
        This is cause of this issue.
[Solution] For fixing this issue, special method to set WebProcess path per ewk context is added using env variable.
           ewk_context_new() or ewk_context_new_with_injected_bundle() reads this env variable as soon as ewk context is created.
           web-provider will change value of the env variable to proper path before calling ewk_context_new_with_injected_bundle().
           For using this webkit's support, web-provider may create several symbolic links to /usr/bin/WebProcess.

Change-Id: I9ea320774ce32b5e88bf74450b53b9d66628fa1b

Source/WTF/wtf/Platform.h
Source/WebKit2/UIProcess/API/efl/ewk_context.cpp
Source/WebKit2/UIProcess/Launcher/ProcessLauncher.h
Source/WebKit2/UIProcess/Launcher/efl/ProcessLauncherEfl.cpp
Source/WebKit2/UIProcess/WebContext.cpp
Source/WebKit2/UIProcess/WebContext.h
Source/WebKit2/UIProcess/WebProcessProxy.cpp
Source/WebKit2/UIProcess/efl/WebContextEfl.cpp

index 6035868..0809b45 100644 (file)
@@ -788,6 +788,7 @@ com) : Patch to do not adjust cover rect as fixed pixel size*/
 #define ENABLE_TIZEN_UPDATE_TIMEZONE_INFO 1 /* Hojong Han(hojong.han@samsung.com) : Sync timezone before getting local time */
 
 #define ENABLE_TIZEN_WRT_LAUNCHING_PERFORMANCE 1 /* Byungwoo Lee(bw80.lee@samsung.com) : Local patches to enhance web app launching performance */
+#define ENABLE_TIZEN_SET_WEB_PROCESS_EXECUTABLE_PATH 1 /* Yunchan Cho(yunchan.cho@samsung.com) : Support to set path of web process executable file */
 
 #define ENABLE_TIZEN_REDUCE_KEY_LAGGING 1    /* Soon-Young Lee(sy5002.lee@samsung.com) : Temporary solution for a keylagging problem. FIXME */
 #define ENABLE_TIZEN_TEXT_CODEC_MEMORY_REDUCTION 1 /*KyungTae Kim(ktf.kim@samsung.com) : Share Encode & Decode buffer for TextCodecUTF8 for memory reduction */
index ab51c9f..3fb1c92 100755 (executable)
@@ -548,11 +548,19 @@ uint64_t ewkContextGetDatabaseQuota(Ewk_Context* ewkContext)
 Ewk_Context* ewk_context_new()
 {
 #if OS(TIZEN)
-    Ewk_Context* ewk_context = Ewk_Context::create().leakRef();
-    ewkContextInjectedBundleClientAttachClient(ewk_context);
-    return ewk_context;
+    Ewk_Context* ewkContext = Ewk_Context::create().leakRef();
+    ewkContextInjectedBundleClientAttachClient(ewkContext);
+#if ENABLE(TIZEN_SET_WEB_PROCESS_EXECUTABLE_PATH)
+    const char* webProcessExecutablePath = getenv("WEB_PROCESS_EXECUTABLE_PATH");
+    if (webProcessExecutablePath) {
+        WKContextRef contextRef = ewkContext->wkContext();
+        toImpl(contextRef)->setWebProcessExecutablePath(String::fromUTF8(webProcessExecutablePath));
+    }
 #endif
+    return ewkContext;
+#else
     return Ewk_Context::create().leakRef();
+#endif
 }
 
 Ewk_Context* ewk_context_new_with_injected_bundle_path(const char* path)
@@ -599,11 +607,19 @@ Ewk_Context* ewk_context_new_with_injected_bundle_path(const char* path)
 #endif
 
 #if OS(TIZEN)
-    Ewk_Context* ewk_context = Ewk_Context::create(String::fromUTF8(path)).leakRef();
-    ewkContextInjectedBundleClientAttachClient(ewk_context);
-    return ewk_context;
+    Ewk_Context* ewkContext = Ewk_Context::create(String::fromUTF8(path)).leakRef();
+    ewkContextInjectedBundleClientAttachClient(ewkContext);
+#if ENABLE(TIZEN_SET_WEB_PROCESS_EXECUTABLE_PATH)
+    const char* webProcessExecutablePath = getenv("WEB_PROCESS_EXECUTABLE_PATH");
+    if (webProcessExecutablePath) {
+        WKContextRef contextRef = ewkContext->wkContext();
+        toImpl(contextRef)->setWebProcessExecutablePath(String::fromUTF8(webProcessExecutablePath));
+    }
 #endif
+    return ewkContext;
+#else
     return Ewk_Context::create(String::fromUTF8(path)).leakRef();
+#endif
 }
 
 void ewk_context_delete(Ewk_Context* ewkContext)
index 3e90b19..7f09523 100644 (file)
@@ -58,6 +58,9 @@ public:
         cpu_type_t architecture;
         bool executableHeap;
 #endif
+#if ENABLE(TIZEN_SET_WEB_PROCESS_EXECUTABLE_PATH)
+        String webProcessExecutablePath;
+#endif
 #ifndef NDEBUG
         String processCmdPrefix;
 #endif
index 633441b..e4e4cb3 100644 (file)
@@ -195,7 +195,13 @@ void ProcessLauncher::launchProcess()
         String executablePath;
         switch (m_launchOptions.processType) {
         case WebProcess:
-            executablePath = executablePathOfWebProcess();
+#if ENABLE(TIZEN_SET_WEB_PROCESS_EXECUTABLE_PATH)
+            if (!m_launchOptions.webProcessExecutablePath.isEmpty()) {
+                executablePath = m_launchOptions.webProcessExecutablePath;
+                TIZEN_LOGI("executable path: %s", executablePath.utf8().data());
+            } else
+#endif
+                executablePath = executablePathOfWebProcess();
             break;
         case PluginProcess:
             executablePath = executablePathOfPluginProcess();
index 089c88d..140eb55 100644 (file)
@@ -178,6 +178,9 @@ WebContext::WebContext(ProcessModel processModel, const String& injectedBundlePa
 #endif
     , m_processTerminationEnabled(true)
     , m_pluginWorkQueue("com.apple.CoreIPC.PluginQueue")
+#if ENABLE(TIZEN_SET_WEB_PROCESS_EXECUTABLE_PATH)
+    , m_webProcessExecutablePath(String())
+#endif
 {
 #if !LOG_DISABLED
     WebKit::initializeLogChannelsIfNecessary();
index 214c80d..f98dd8d 100755 (executable)
@@ -182,6 +182,10 @@ public:
 #if PLATFORM(EFL)
     void notifyLowMemory();
 #endif
+#if ENABLE(TIZEN_SET_WEB_PROCESS_EXECUTABLE_PATH)
+    void setWebProcessExecutablePath(const String);
+    const String& webProcessExecutablePath() const { return m_webProcessExecutablePath; };
+#endif
 #if ENABLE(TIZEN_WEBKIT2_MEMORY_SAVING_MODE)
     void setMemorySavingMode(bool memorySavingMode);
 #endif
@@ -452,6 +456,10 @@ private:
     String m_soupDataDirectory;
 #endif
 
+#if ENABLE(TIZEN_SET_WEB_PROCESS_EXECUTABLE_PATH)
+    String m_webProcessExecutablePath;
+#endif
+
     bool m_processTerminationEnabled;
 
     HashMap<uint64_t, RefPtr<DictionaryCallback> > m_dictionaryCallbacks;
index ecd645b..147d2d4 100644 (file)
@@ -120,6 +120,10 @@ void WebProcessProxy::connect()
         launchOptions.architecture = ProcessLauncher::LaunchOptions::MatchCurrentArchitecture;
         launchOptions.executableHeap = false;
 #endif
+#if ENABLE(TIZEN_SET_WEB_PROCESS_EXECUTABLE_PATH)
+        launchOptions.webProcessExecutablePath = m_context->webProcessExecutablePath();
+#endif
+
 #ifndef NDEBUG
         const char* webProcessCmdPrefix = getenv("WEB_PROCESS_CMD_PREFIX");
         if (webProcessCmdPrefix && *webProcessCmdPrefix)
index 7529466..6e26e74 100755 (executable)
@@ -125,6 +125,13 @@ void WebContext::setProxy(const String& proxyAddress)
 }
 #endif
 
+#if ENABLE(TIZEN_SET_WEB_PROCESS_EXECUTABLE_PATH)
+void WebContext::setWebProcessExecutablePath(const String webProcessExecutablePath)
+{
+    m_webProcessExecutablePath = webProcessExecutablePath;
+}
+#endif
+
 #if ENABLE(TIZEN_SESSION_REQUEST_CANCEL)
 void WebContext::abortSession()
 {