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
3 // found in the LICENSE file.
5 #include "mojo/shell/child_process.h"
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "base/strings/string_number_conversions.h"
10 #include "mojo/shell/app_child_process.h"
11 #include "mojo/shell/switches.h"
12 #include "mojo/shell/test_child_process.h"
13 #include "mojo/system/embedder/platform_channel_pair.h"
18 ChildProcess::~ChildProcess() {
22 scoped_ptr
<ChildProcess
> ChildProcess::Create(const CommandLine
& command_line
) {
23 if (!command_line
.HasSwitch(switches::kChildProcessType
))
24 return scoped_ptr
<ChildProcess
>();
27 CHECK(base::StringToInt(command_line
.GetSwitchValueASCII(
28 switches::kChildProcessType
), &type_as_int
));
30 scoped_ptr
<ChildProcess
> rv
;
31 switch (type_as_int
) {
33 rv
.reset(new TestChildProcess());
36 rv
.reset(new AppChildProcess());
39 CHECK(false) << "Invalid child process type";
44 rv
->platform_channel_
=
45 embedder::PlatformChannelPair::PassClientHandleFromParentProcess(
47 CHECK(rv
->platform_channel_
.is_valid());
53 void ChildProcess::Run() {
57 ChildProcess::ChildProcess() {