Fix PNaCl debug commandline flags, and use the pexe with debug info in test.
[chromium-blink-merge.git] / mojo / shell / child_process.cc
blob90338f52b02958a9669761dab3e5ca9f3a0e5d21
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"
15 namespace mojo {
16 namespace shell {
18 ChildProcess::~ChildProcess() {
21 // static
22 scoped_ptr<ChildProcess> ChildProcess::Create(const CommandLine& command_line) {
23 if (!command_line.HasSwitch(switches::kChildProcessType))
24 return scoped_ptr<ChildProcess>();
26 int type_as_int;
27 CHECK(base::StringToInt(command_line.GetSwitchValueASCII(
28 switches::kChildProcessType), &type_as_int));
30 scoped_ptr<ChildProcess> rv;
31 switch (type_as_int) {
32 case TYPE_TEST:
33 rv.reset(new TestChildProcess());
34 break;
35 case TYPE_APP:
36 rv.reset(new AppChildProcess());
37 break;
38 default:
39 CHECK(false) << "Invalid child process type";
40 break;
43 if (rv) {
44 rv->platform_channel_ =
45 embedder::PlatformChannelPair::PassClientHandleFromParentProcess(
46 command_line);
47 CHECK(rv->platform_channel_.is_valid());
50 return rv.Pass();
53 void ChildProcess::Run() {
54 Main();
57 ChildProcess::ChildProcess() {
60 } // namespace shell
61 } // namespace mojo