ProcessLauncher.cpp [plain text]
#include "config.h"
#include "ProcessLauncher.h"
#include "WorkQueue.h"
#include <wtf/StdLibExtras.h>
namespace WebKit {
static WorkQueue& processLauncherWorkQueue()
{
DEFINE_STATIC_LOCAL(WorkQueue, processLauncherWorkQueue, ("com.apple.WebKit.ProcessLauncher"));
return processLauncherWorkQueue;
}
ProcessLauncher::ProcessLauncher(Client* client, const LaunchOptions& launchOptions)
: m_client(client)
, m_launchOptions(launchOptions)
, m_processIdentifier(0)
{
m_isLaunching = true;
processLauncherWorkQueue().scheduleWork(WorkItem::create(this, &ProcessLauncher::launchProcess));
}
void ProcessLauncher::didFinishLaunchingProcess(PlatformProcessIdentifier processIdentifier, CoreIPC::Connection::Identifier identifier)
{
m_processIdentifier = processIdentifier;
m_isLaunching = false;
if (!m_client) {
return;
}
m_client->didFinishLaunching(this, identifier);
}
void ProcessLauncher::invalidate()
{
m_client = 0;
platformInvalidate();
}
const char* ProcessLauncher::processTypeAsString(ProcessType processType)
{
switch (processType) {
case WebProcess:
return "webprocess";
case PluginProcess:
return "pluginprocess";
}
ASSERT_NOT_REACHED();
return 0;
}
bool ProcessLauncher::getProcessTypeFromString(const char* string, ProcessType& processType)
{
if (!strcmp(string, "webprocess")) {
processType = WebProcess;
return true;
}
if (!strcmp(string, "pluginprocess")) {
processType = PluginProcess;
return true;
}
return false;
}
}