Commit b1adb2d7 authored by andersca@apple.com's avatar andersca@apple.com
Browse files

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.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76034 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6f93041c
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.
......@@ -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()
......
......@@ -72,6 +72,8 @@ private:
void shutdownTimerFired();
void platformInitialize(const PluginProcessCreationParameters&);
// The connection to the UI process.
RefPtr<CoreIPC::Connection> m_connection;
......
......@@ -24,11 +24,16 @@
*/
#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)
......@@ -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
......
......@@ -50,6 +50,7 @@ struct PluginProcessCreationParameters {
String pluginPath;
#if PLATFORM(MAC)
String parentProcessName;
CoreIPC::MachPort acceleratedCompositingPort;
#endif
};
......
......@@ -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))
......
......@@ -73,6 +73,8 @@ struct WebProcessCreationParameters {
TextCheckerState textCheckerState;
#if PLATFORM(MAC)
String parentProcessName;
pid_t presenterApplicationPid;
CString nsURLCachePath;
......
......@@ -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);
......
......@@ -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);
......
......@@ -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];
......
......@@ -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;
......
......@@ -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());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment