2
* Copyright (C) 2010, 2012 Apple Inc. All rights reserved.
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
7
* 1. Redistributions of source code must retain the above copyright
8
* notice, this list of conditions and the following disclaimer.
9
* 2. Redistributions in binary form must reproduce the above copyright
10
* notice, this list of conditions and the following disclaimer in the
11
* documentation and/or other materials provided with the distribution.
13
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
* THE POSSIBILITY OF SUCH DAMAGE.
27
#include "ProcessLauncher.h"
29
#include "WorkQueue.h"
30
#include <wtf/StdLibExtras.h>
34
static WorkQueue& processLauncherWorkQueue()
36
// Give in to VisualStudio and its 31 character thread name limit and shorten the thread name to ProcLauncher instead of class name.
37
// See createThread() in Threading.cpp.
38
DEFINE_STATIC_LOCAL(WorkQueue, processLauncherWorkQueue, ("com.apple.WebKit.ProcLauncher"));
39
return processLauncherWorkQueue;
42
ProcessLauncher::ProcessLauncher(Client* client, const LaunchOptions& launchOptions)
44
, m_launchOptions(launchOptions)
45
, m_processIdentifier(0)
47
// Launch the process.
49
processLauncherWorkQueue().dispatch(bind(&ProcessLauncher::launchProcess, this));
52
void ProcessLauncher::didFinishLaunchingProcess(PlatformProcessIdentifier processIdentifier, CoreIPC::Connection::Identifier identifier)
54
m_processIdentifier = processIdentifier;
55
m_isLaunching = false;
58
// FIXME: Dispose of the connection identifier.
62
m_client->didFinishLaunching(this, identifier);
65
void ProcessLauncher::invalidate()
71
const char* ProcessLauncher::processTypeAsString(ProcessType processType)
73
switch (processType) {
76
#if ENABLE(PLUGIN_PROCESS)
78
return "pluginprocess";
80
#if ENABLE(NETWORK_PROCESS)
82
return "networkprocess";
84
#if ENABLE(SHARED_WORKER_PROCESS)
85
case SharedWorkerProcess:
86
return "sharedworkerprocess";
94
bool ProcessLauncher::getProcessTypeFromString(const char* string, ProcessType& processType)
96
if (!strcmp(string, "webprocess")) {
97
processType = WebProcess;
101
#if ENABLE(PLUGIN_PROCESS)
102
if (!strcmp(string, "pluginprocess")) {
103
processType = PluginProcess;
108
#if ENABLE(NETWORK_PROCESS)
109
if (!strcmp(string, "networkprocess")) {
110
processType = NetworkProcess;
115
#if ENABLE(SHARED_WORKER_PROCESS)
116
if (!strcmp(string, "sharedworkerprocess")) {
117
processType = SharedWorkerProcess;
125
} // namespace WebKit