| 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" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "mojo/edk/embedder/platform_channel_pair.h" | 10 #include "mojo/edk/embedder/platform_channel_pair.h" |
| 11 #include "shell/app_child_process.h" | 11 #include "shell/app_child_process.h" |
| 12 #include "shell/switches.h" | 12 #include "shell/switches.h" |
| 13 #include "shell/test_child_process.h" | |
| 14 | 13 |
| 15 namespace mojo { | 14 namespace mojo { |
| 16 namespace shell { | 15 namespace shell { |
| 17 | 16 |
| 18 ChildProcess::~ChildProcess() { | 17 ChildProcess::~ChildProcess() { |
| 19 } | 18 } |
| 20 | 19 |
| 21 // static | 20 // static |
| 22 scoped_ptr<ChildProcess> ChildProcess::Create( | 21 scoped_ptr<ChildProcess> ChildProcess::Create( |
| 23 const base::CommandLine& command_line) { | 22 const base::CommandLine& command_line) { |
| 24 if (!command_line.HasSwitch(switches::kChildProcessType)) | 23 if (!command_line.HasSwitch(switches::kChildProcessType)) |
| 25 return scoped_ptr<ChildProcess>(); | 24 return scoped_ptr<ChildProcess>(); |
| 26 | 25 |
| 27 int type_as_int; | 26 int type_as_int; |
| 28 CHECK(base::StringToInt( | 27 CHECK(base::StringToInt( |
| 29 command_line.GetSwitchValueASCII(switches::kChildProcessType), | 28 command_line.GetSwitchValueASCII(switches::kChildProcessType), |
| 30 &type_as_int)); | 29 &type_as_int)); |
| 31 | 30 |
| 32 scoped_ptr<ChildProcess> rv; | 31 scoped_ptr<ChildProcess> rv; |
| 33 switch (type_as_int) { | 32 switch (type_as_int) { |
| 34 case TYPE_TEST: | |
| 35 rv.reset(new TestChildProcess()); | |
| 36 break; | |
| 37 case TYPE_APP: | 33 case TYPE_APP: |
| 38 rv.reset(new AppChildProcess()); | 34 rv.reset(new AppChildProcess()); |
| 39 break; | 35 break; |
| 40 default: | 36 default: |
| 41 CHECK(false) << "Invalid child process type"; | 37 CHECK(false) << "Invalid child process type"; |
| 42 break; | 38 break; |
| 43 } | 39 } |
| 44 | 40 |
| 45 if (rv) { | 41 if (rv) { |
| 46 rv->platform_channel_ = | 42 rv->platform_channel_ = |
| 47 embedder::PlatformChannelPair::PassClientHandleFromParentProcess( | 43 embedder::PlatformChannelPair::PassClientHandleFromParentProcess( |
| 48 command_line); | 44 command_line); |
| 49 CHECK(rv->platform_channel_.is_valid()); | 45 CHECK(rv->platform_channel_.is_valid()); |
| 50 } | 46 } |
| 51 | 47 |
| 52 return rv.Pass(); | 48 return rv.Pass(); |
| 53 } | 49 } |
| 54 | 50 |
| 55 ChildProcess::ChildProcess() { | 51 ChildProcess::ChildProcess() { |
| 56 } | 52 } |
| 57 | 53 |
| 58 } // namespace shell | 54 } // namespace shell |
| 59 } // namespace mojo | 55 } // namespace mojo |
| OLD | NEW |