/src/mozilla-central/dom/ipc/ContentProcessHost.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
2 | | * vim: sts=8 sw=2 ts=2 tw=99 et : |
3 | | * This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #include "ContentProcessHost.h" |
8 | | |
9 | | namespace mozilla { |
10 | | namespace dom { |
11 | | |
12 | | using namespace ipc; |
13 | | |
14 | | ContentProcessHost::ContentProcessHost(ContentParent* aContentParent, |
15 | | bool aIsFileContent) |
16 | | : GeckoChildProcessHost(GeckoProcessType_Content, aIsFileContent), |
17 | | mHasLaunched(false), |
18 | | mContentParent(aContentParent) |
19 | 0 | { |
20 | 0 | MOZ_COUNT_CTOR(ContentProcessHost); |
21 | 0 | } |
22 | | |
23 | | ContentProcessHost::~ContentProcessHost() |
24 | 0 | { |
25 | 0 | MOZ_COUNT_DTOR(ContentProcessHost); |
26 | 0 | } |
27 | | |
28 | | bool |
29 | | ContentProcessHost::Launch(StringVector aExtraOpts) |
30 | 0 | { |
31 | 0 | MOZ_ASSERT(!mHasLaunched); |
32 | 0 | MOZ_ASSERT(mContentParent); |
33 | 0 |
|
34 | 0 | bool res = GeckoChildProcessHost::AsyncLaunch(aExtraOpts); |
35 | 0 | MOZ_RELEASE_ASSERT(res); |
36 | 0 | return true; |
37 | 0 | } |
38 | | |
39 | | void |
40 | | ContentProcessHost::OnProcessHandleReady(ProcessHandle aProcessHandle) |
41 | 0 | { |
42 | 0 | MOZ_ASSERT(!NS_IsMainThread()); |
43 | 0 |
|
44 | 0 | // This will wake up the main thread if it is waiting for the process to |
45 | 0 | // launch. |
46 | 0 | mContentParent->SetOtherProcessId(base::GetProcId(aProcessHandle)); |
47 | 0 |
|
48 | 0 | mHasLaunched = true; |
49 | 0 | GeckoChildProcessHost::OnProcessHandleReady(aProcessHandle); |
50 | 0 | } |
51 | | |
52 | | void |
53 | | ContentProcessHost::OnProcessLaunchError() |
54 | 0 | { |
55 | 0 | MOZ_ASSERT(!NS_IsMainThread()); |
56 | 0 | mContentParent->SetOtherProcessId(mozilla::ipc::kInvalidProcessId, |
57 | 0 | ContentParent::ProcessIdState::eError); |
58 | 0 | mHasLaunched = true; |
59 | 0 | GeckoChildProcessHost::OnProcessLaunchError(); |
60 | 0 | } |
61 | | |
62 | | } // namespace dom |
63 | | } // namespace mozilla |