~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2010, 2012 Apple Inc. All rights reserved.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without
 
5
 * modification, are permitted provided that the following conditions
 
6
 * are met:
 
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.
 
12
 *
 
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.
 
24
 */
 
25
 
 
26
#include "config.h"
 
27
#include "ProcessLauncher.h"
 
28
 
 
29
#include "WorkQueue.h"
 
30
#include <wtf/StdLibExtras.h>
 
31
 
 
32
namespace WebKit {
 
33
 
 
34
static WorkQueue& processLauncherWorkQueue()
 
35
{
 
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;
 
40
}
 
41
 
 
42
ProcessLauncher::ProcessLauncher(Client* client, const LaunchOptions& launchOptions)
 
43
    : m_client(client)
 
44
    , m_launchOptions(launchOptions)
 
45
    , m_processIdentifier(0)
 
46
{
 
47
    // Launch the process.
 
48
    m_isLaunching = true;
 
49
    processLauncherWorkQueue().dispatch(bind(&ProcessLauncher::launchProcess, this));
 
50
}
 
51
 
 
52
void ProcessLauncher::didFinishLaunchingProcess(PlatformProcessIdentifier processIdentifier, CoreIPC::Connection::Identifier identifier)
 
53
{
 
54
    m_processIdentifier = processIdentifier;
 
55
    m_isLaunching = false;
 
56
    
 
57
    if (!m_client) {
 
58
        // FIXME: Dispose of the connection identifier.
 
59
        return;
 
60
    }
 
61
    
 
62
    m_client->didFinishLaunching(this, identifier);
 
63
}
 
64
 
 
65
void ProcessLauncher::invalidate()
 
66
{
 
67
    m_client = 0;
 
68
    platformInvalidate();
 
69
}
 
70
 
 
71
const char* ProcessLauncher::processTypeAsString(ProcessType processType)
 
72
{
 
73
    switch (processType) {
 
74
    case WebProcess:
 
75
        return "webprocess";
 
76
#if ENABLE(PLUGIN_PROCESS)
 
77
    case PluginProcess:
 
78
        return "pluginprocess";
 
79
#endif
 
80
#if ENABLE(NETWORK_PROCESS)
 
81
    case NetworkProcess:
 
82
        return "networkprocess";
 
83
#endif
 
84
#if ENABLE(SHARED_WORKER_PROCESS)
 
85
    case SharedWorkerProcess:
 
86
        return "sharedworkerprocess";
 
87
#endif
 
88
    }
 
89
 
 
90
    ASSERT_NOT_REACHED();
 
91
    return 0;
 
92
}
 
93
 
 
94
bool ProcessLauncher::getProcessTypeFromString(const char* string, ProcessType& processType)
 
95
{
 
96
    if (!strcmp(string, "webprocess")) {
 
97
        processType = WebProcess;
 
98
        return true;
 
99
    }
 
100
 
 
101
#if ENABLE(PLUGIN_PROCESS)
 
102
    if (!strcmp(string, "pluginprocess")) {
 
103
        processType = PluginProcess;
 
104
        return true;
 
105
    }
 
106
#endif
 
107
 
 
108
#if ENABLE(NETWORK_PROCESS)
 
109
    if (!strcmp(string, "networkprocess")) {
 
110
        processType = NetworkProcess;
 
111
        return true;
 
112
    }
 
113
#endif
 
114
 
 
115
#if ENABLE(SHARED_WORKER_PROCESS)
 
116
    if (!strcmp(string, "sharedworkerprocess")) {
 
117
        processType = SharedWorkerProcess;
 
118
        return true;
 
119
    }
 
120
#endif
 
121
 
 
122
    return false;
 
123
}
 
124
 
 
125
} // namespace WebKit