2011-01-18 Anders Carlsson <andersca@apple.com>
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Jan 2011 18:11:15 +0000 (18:11 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Jan 2011 18:11:15 +0000 (18:11 +0000)
        Reviewed by Dan Bernstein.

        Plug-in hosting WebProcess instances appear in Activity Monitor as WebProcess
        https://bugs.webkit.org/show_bug.cgi?id=52635
        <rdar://problem/8731337>

        * PluginProcess/PluginProcess.cpp:
        (WebKit::PluginProcess::initialize):
        Call platformInitialize.

        * PluginProcess/PluginProcess.h:
        Add platformInitialize.

        * PluginProcess/mac/PluginProcessMac.mm:
        (WebKit::PluginProcess::platformInitialize):
        Set the compositing render server port and the visible application name.

        * Shared/Plugins/PluginProcessCreationParameters.cpp:
        (WebKit::PluginProcessCreationParameters::encode):
        (WebKit::PluginProcessCreationParameters::decode):
        Encode/decode the parent process name.

        * Shared/Plugins/PluginProcessCreationParameters.h:
        Add parentProcessName.

        * Shared/WebProcessCreationParameters.cpp:
        (WebKit::WebProcessCreationParameters::encode):
        (WebKit::WebProcessCreationParameters::decode):
        Encode/decode the parent process name.

        * Shared/WebProcessCreationParameters.h:
        Add parentProcessName.

        * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
        (WebKit::ProcessLauncher::launchProcess):
        Don't pass the parent process name here.

        * UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
        (WebKit::PluginProcessProxy::platformInitializePluginProcess):
        Set the visible name.

        * UIProcess/mac/WebContextMac.mm:
        (WebKit::WebContext::platformInitializeWebProcess):
        Pass along the parent process name.

        * WebProcess/mac/WebProcessMac.mm:
        (WebKit::WebProcess::platformInitializeWebProcess):
        Set the visible name.

        * WebProcess/mac/WebProcessMainMac.mm:
        (WebKit::WebProcessMain):
        Don't set the visible name here. It's done in platformInitializeWebProcess.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@76034 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/PluginProcess/PluginProcess.cpp
Source/WebKit2/PluginProcess/PluginProcess.h
Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm
Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.cpp
Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.h
Source/WebKit2/Shared/WebProcessCreationParameters.cpp
Source/WebKit2/Shared/WebProcessCreationParameters.h
Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm
Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm
Source/WebKit2/UIProcess/mac/WebContextMac.mm
Source/WebKit2/WebProcess/mac/WebProcessMac.mm
Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm

index 1834009..63ae025 100644 (file)
@@ -1,3 +1,58 @@
+2011-01-18  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Plug-in hosting WebProcess instances appear in Activity Monitor as WebProcess
+        https://bugs.webkit.org/show_bug.cgi?id=52635
+        <rdar://problem/8731337>
+
+        * PluginProcess/PluginProcess.cpp:
+        (WebKit::PluginProcess::initialize):
+        Call platformInitialize.
+
+        * PluginProcess/PluginProcess.h:
+        Add platformInitialize.
+
+        * PluginProcess/mac/PluginProcessMac.mm:
+        (WebKit::PluginProcess::platformInitialize):
+        Set the compositing render server port and the visible application name.
+
+        * Shared/Plugins/PluginProcessCreationParameters.cpp:
+        (WebKit::PluginProcessCreationParameters::encode):
+        (WebKit::PluginProcessCreationParameters::decode):
+        Encode/decode the parent process name.
+
+        * Shared/Plugins/PluginProcessCreationParameters.h:
+        Add parentProcessName.
+
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode):
+        (WebKit::WebProcessCreationParameters::decode):
+        Encode/decode the parent process name.
+
+        * Shared/WebProcessCreationParameters.h:
+        Add parentProcessName.
+
+        * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
+        (WebKit::ProcessLauncher::launchProcess):
+        Don't pass the parent process name here.
+
+        * UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
+        (WebKit::PluginProcessProxy::platformInitializePluginProcess):
+        Set the visible name.
+
+        * UIProcess/mac/WebContextMac.mm:
+        (WebKit::WebContext::platformInitializeWebProcess):
+        Pass along the parent process name.
+
+        * WebProcess/mac/WebProcessMac.mm:
+        (WebKit::WebProcess::platformInitializeWebProcess):
+        Set the visible name.
+
+        * WebProcess/mac/WebProcessMainMac.mm:
+        (WebKit::WebProcessMain):
+        Don't set the visible name here. It's done in platformInitializeWebProcess.
+
 2011-01-18  Balazs Kelemen  <kbalazs@webkit.org>
 
         Reviewed by Csaba Osztrogon√°c.
index 6c19c21..6124f9a 100644 (file)
@@ -115,9 +115,7 @@ void PluginProcess::initialize(const PluginProcessCreationParameters& parameters
 
     m_pluginPath = parameters.pluginPath;
 
-#if USE(ACCELERATED_COMPOSITING) && PLATFORM(MAC)
-    m_compositingRenderServerPort = parameters.acceleratedCompositingPort.port();
-#endif
+    platformInitialize(parameters);
 }
 
 void PluginProcess::createWebProcessConnection()
index e60d52d..d7f592e 100644 (file)
@@ -72,6 +72,8 @@ private:
     
     void shutdownTimerFired();
 
+    void platformInitialize(const PluginProcessCreationParameters&);
+
     // The connection to the UI process.
     RefPtr<CoreIPC::Connection> m_connection;
 
index ccf444c..3919c8b 100644 (file)
  */
 
 #if ENABLE(PLUGIN_PROCESS)
+
+// FIXME (WebKit2) <rdar://problem/8728860> WebKit2 needs to be localized
+#define UI_STRING(__str, __desc) [NSString stringWithUTF8String:__str]
  
 #include "PluginProcess.h"
 
 #include "NetscapePlugin.h"
 #include "PluginProcessShim.h"
+#include "PluginProcessCreationParameters.h"
+#include <WebKitSystemInterface.h>
 #include <dlfcn.h>
 
 namespace WebKit {
@@ -84,6 +89,19 @@ void PluginProcess::initializeShim()
     initFunc(callbacks);
 }
 
+void PluginProcess::platformInitialize(const PluginProcessCreationParameters& parameters)
+{
+    m_compositingRenderServerPort = parameters.acceleratedCompositingPort.port();
+
+    NSString *applicationName = [NSString stringWithFormat:UI_STRING("%@ (%@ Internet plug-in)",
+                                                                     "visible name of the plug-in host process. The first argument is the plug-in name "
+                                                                     "and the second argument is the application name."),
+                                 [[(NSString *)parameters.pluginPath lastPathComponent] stringByDeletingPathExtension], 
+                                 (NSString *)parameters.parentProcessName];
+    
+    WKSetVisibleApplicationName((CFStringRef)applicationName);
+}
+
 } // namespace WebKit
 
 #endif // ENABLE(PLUGIN_PROCESS)
index 90bbf07..c95a825 100644 (file)
@@ -40,6 +40,7 @@ void PluginProcessCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder)
     encoder->encode(pluginPath);
 
 #if PLATFORM(MAC)
+    encoder->encode(parentProcessName);
     encoder->encode(acceleratedCompositingPort);
 #endif
 }
@@ -50,6 +51,8 @@ bool PluginProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder,
         return false;
 
 #if PLATFORM(MAC)
+    if (!decoder->decode(result.parentProcessName))
+        return false;
     if (!decoder->decode(result.acceleratedCompositingPort))
         return false;
 #endif
index 1aeef01..62cf4bb 100644 (file)
@@ -50,6 +50,7 @@ struct PluginProcessCreationParameters {
     String pluginPath;
 
 #if PLATFORM(MAC)
+    String parentProcessName;
     CoreIPC::MachPort acceleratedCompositingPort;
 #endif
 };
index ceae6c1..77e3a82 100644 (file)
@@ -56,6 +56,7 @@ void WebProcessCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) con
     encoder->encode(languageCode);
     encoder->encode(textCheckerState);
 #if PLATFORM(MAC)
+    encoder->encode(parentProcessName);
     encoder->encode(presenterApplicationPid);
     encoder->encode(nsURLCachePath);
     encoder->encode(nsURLCacheMemoryCapacity);
@@ -95,6 +96,8 @@ bool WebProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, Web
         return false;
 
 #if PLATFORM(MAC)
+    if (!decoder->decode(parameters.parentProcessName))
+        return false;
     if (!decoder->decode(parameters.presenterApplicationPid))
         return false;
     if (!decoder->decode(parameters.nsURLCachePath))
index fe582b3..50d8a90 100644 (file)
@@ -73,6 +73,8 @@ struct WebProcessCreationParameters {
     TextCheckerState textCheckerState;
 
 #if PLATFORM(MAC)
+    String parentProcessName;
+
     pid_t presenterApplicationPid;
     CString nsURLCachePath;
 
index c285bae..a725d6b 100644 (file)
@@ -49,32 +49,6 @@ extern "C" kern_return_t bootstrap_register2(mach_port_t, name_t, mach_port_t, u
 
 namespace WebKit {
 
-#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
-static const char* processName()
-{
-    return [[[NSProcessInfo processInfo] processName] fileSystemRepresentation];
-}
-#else
-// -[NSProcessInfo processName] isn't thread-safe on Leopard and Snow Leopard so we have our own implementation.
-static const char* createProcessName()
-{
-    uint32_t bufferSize = MAXPATHLEN;
-    char executablePath[bufferSize];
-    
-    if (_NSGetExecutablePath(executablePath, &bufferSize))
-        return "";
-    
-    const char *processName = strrchr(executablePath, '/') + 1;
-    return strdup(processName);
-}
-
-static const char* processName()
-{
-    static const char* processName = createProcessName();
-    return processName;
-}
-#endif
-
 static void setUpTerminationNotificationHandler(pid_t pid)
 {
 #if HAVE(DISPATCH_H)
@@ -226,7 +200,7 @@ void ProcessLauncher::launchProcess()
     CString serviceName = String::format("com.apple.WebKit.WebProcess-%d-%p", getpid(), this).utf8();
 
     const char* path = [webProcessAppExecutablePath fileSystemRepresentation];
-    const char* args[] = { path, bundlePath, "-type", processTypeAsString(m_launchOptions.processType), "-servicename", serviceName.data(), "-parentprocessname", processName(), 0 };
+    const char* args[] = { path, bundlePath, "-type", processTypeAsString(m_launchOptions.processType), "-servicename", serviceName.data(), 0 };
 
     // Register ourselves.
     kern_return_t kr = bootstrap_register2(bootstrap_port, const_cast<char*>(serviceName.data()), listeningPort, 0);
index 81c8620..eaf8aef 100644 (file)
@@ -35,6 +35,7 @@ namespace WebKit {
 void PluginProcessProxy::platformInitializePluginProcess(PluginProcessCreationParameters& parameters)
 {
 #if USE(ACCELERATED_COMPOSITING) && HAVE(HOSTED_CORE_ANIMATION)
+    parameters.parentProcessName = [[NSProcessInfo processInfo] processName];
     mach_port_t renderServerPort = WKInitializeRenderServer();
     if (renderServerPort != MACH_PORT_NULL)
         parameters.acceleratedCompositingPort = CoreIPC::MachPort(renderServerPort, MACH_MSG_TYPE_COPY_SEND);
index ce4c3e6..4d1679f 100644 (file)
@@ -74,7 +74,8 @@ void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& para
         cachePath = reinterpret_cast<CFStringRef>(NSHomeDirectory());
 
     NSURLCache *urlCache = [NSURLCache sharedURLCache];
-    
+
+    parameters.parentProcessName = [[NSProcessInfo processInfo] processName];    
     parameters.nsURLCachePath = fileSystemRepresentation([(NSString *)cachePath.get() stringByStandardizingPath]);
     parameters.nsURLCacheMemoryCapacity = [urlCache memoryCapacity];
     parameters.nsURLCacheDiskCapacity = [urlCache diskCapacity];
index c899fcb..d394c98 100644 (file)
@@ -151,6 +151,12 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters
 {
     initializeSandbox(parameters);
 
+    if (!parameters.parentProcessName.isNull()) {
+        // FIXME (WebKit2) <rdar://problem/8728860> WebKit2 needs to be localized
+        NSString *applicationName = [NSString stringWithFormat:@"%@ Web Content", (NSString *)parameters.parentProcessName];
+        WKSetVisibleApplicationName((CFStringRef)applicationName);
+    }
+
     if (!parameters.nsURLCachePath.isNull()) {
         NSUInteger cacheMemoryCapacity = parameters.nsURLCacheMemoryCapacity;
         NSUInteger cacheDiskCapacity = parameters.nsURLCacheDiskCapacity;
index 5cefb59..a44dc23 100644 (file)
@@ -80,14 +80,6 @@ int WebProcessMain(const CommandLine& commandLine)
     WTF::initializeMainThread();
     RunLoop::initializeMainRunLoop();
 
-    // Set the visible application name.
-    String parentProcessName = commandLine["parentprocessname"];
-    if (!parentProcessName.isNull()) {
-        // FIXME: Localization!
-        NSString *applicationName = [NSString stringWithFormat:@"%@ Web Content", (NSString *)parentProcessName];
-        WKSetVisibleApplicationName((CFStringRef)applicationName);
-    }
-
     // Create the connection.
     WebProcess::shared().initialize(serverPort, RunLoop::main());