OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "shell/child_process.h" | 5 #include "shell/child_process.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_number_conversions.h" | |
10 #include "mojo/edk/embedder/platform_channel_pair.h" | 9 #include "mojo/edk/embedder/platform_channel_pair.h" |
11 #include "shell/app_child_process.h" | 10 #include "shell/app_child_process.h" |
12 #include "shell/switches.h" | 11 #include "shell/switches.h" |
13 | 12 |
14 namespace mojo { | 13 namespace mojo { |
15 namespace shell { | 14 namespace shell { |
16 | 15 |
17 ChildProcess::~ChildProcess() { | 16 ChildProcess::~ChildProcess() { |
18 } | 17 } |
19 | 18 |
20 // static | 19 // static |
21 scoped_ptr<ChildProcess> ChildProcess::Create( | 20 scoped_ptr<ChildProcess> ChildProcess::Create( |
22 const base::CommandLine& command_line) { | 21 const base::CommandLine& command_line) { |
23 if (!command_line.HasSwitch(switches::kChildProcessType)) | 22 if (!command_line.HasSwitch(switches::kChildProcess)) |
24 return scoped_ptr<ChildProcess>(); | 23 return scoped_ptr<ChildProcess>(); |
25 | 24 |
26 int type_as_int; | 25 scoped_ptr<ChildProcess> rv(new AppChildProcess()); |
27 CHECK(base::StringToInt( | 26 if (!rv) |
28 command_line.GetSwitchValueASCII(switches::kChildProcessType), | 27 return nullptr; |
29 &type_as_int)); | |
30 | 28 |
31 scoped_ptr<ChildProcess> rv; | 29 rv->platform_channel_ = |
32 switch (type_as_int) { | 30 embedder::PlatformChannelPair::PassClientHandleFromParentProcess( |
33 case TYPE_APP: | 31 command_line); |
34 rv.reset(new AppChildProcess()); | 32 CHECK(rv->platform_channel_.is_valid()); |
35 break; | 33 return rv; |
36 default: | |
37 CHECK(false) << "Invalid child process type"; | |
38 break; | |
39 } | |
40 | |
41 if (rv) { | |
42 rv->platform_channel_ = | |
43 embedder::PlatformChannelPair::PassClientHandleFromParentProcess( | |
44 command_line); | |
45 CHECK(rv->platform_channel_.is_valid()); | |
46 } | |
47 | |
48 return rv.Pass(); | |
49 } | 34 } |
50 | 35 |
51 ChildProcess::ChildProcess() { | 36 ChildProcess::ChildProcess() { |
52 } | 37 } |
53 | 38 |
54 } // namespace shell | 39 } // namespace shell |
55 } // namespace mojo | 40 } // namespace mojo |
OLD | NEW |