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