| 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/runner/child_process_host.h" | 5 #include "mojo/runner/child_process_host.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/process/kill.h" | 14 #include "base/process/kill.h" |
| 15 #include "base/process/launch.h" | 15 #include "base/process/launch.h" |
| 16 #include "base/stl_util.h" | |
| 17 #include "base/strings/string_split.h" | |
| 18 #include "base/task_runner.h" | 16 #include "base/task_runner.h" |
| 19 #include "base/task_runner_util.h" | 17 #include "base/task_runner_util.h" |
| 20 #include "mojo/edk/embedder/embedder.h" | 18 #include "mojo/edk/embedder/embedder.h" |
| 21 #include "mojo/public/cpp/system/core.h" | 19 #include "mojo/public/cpp/system/core.h" |
| 22 #include "mojo/runner/context.h" | 20 #include "mojo/runner/context.h" |
| 23 #include "mojo/runner/switches.h" | 21 #include "mojo/runner/switches.h" |
| 24 #include "mojo/runner/task_runners.h" | 22 #include "mojo/runner/task_runners.h" |
| 25 #include "ui/gl/gl_switches.h" | 23 #include "ui/gl/gl_switches.h" |
| 26 | 24 |
| 27 namespace mojo { | 25 namespace mojo { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 return; | 93 return; |
| 96 } | 94 } |
| 97 } | 95 } |
| 98 | 96 |
| 99 bool ChildProcessHost::DoLaunch() { | 97 bool ChildProcessHost::DoLaunch() { |
| 100 static const char* kForwardSwitches[] = { | 98 static const char* kForwardSwitches[] = { |
| 101 switches::kOverrideUseGLWithOSMesaForTests, | 99 switches::kOverrideUseGLWithOSMesaForTests, |
| 102 switches::kTraceToConsole, | 100 switches::kTraceToConsole, |
| 103 switches::kV, | 101 switches::kV, |
| 104 switches::kVModule, | 102 switches::kVModule, |
| 103 switches::kWaitForDebugger, |
| 105 }; | 104 }; |
| 106 | 105 |
| 107 const base::CommandLine* parent_command_line = | 106 const base::CommandLine* parent_command_line = |
| 108 base::CommandLine::ForCurrentProcess(); | 107 base::CommandLine::ForCurrentProcess(); |
| 109 base::CommandLine child_command_line(parent_command_line->GetProgram()); | 108 base::CommandLine child_command_line(parent_command_line->GetProgram()); |
| 110 child_command_line.CopySwitchesFrom(*parent_command_line, kForwardSwitches, | 109 child_command_line.CopySwitchesFrom(*parent_command_line, kForwardSwitches, |
| 111 arraysize(kForwardSwitches)); | 110 arraysize(kForwardSwitches)); |
| 112 child_command_line.AppendSwitchASCII(switches::kApp, name_); | 111 child_command_line.AppendSwitchASCII(switches::kApp, name_); |
| 113 child_command_line.AppendSwitch(switches::kChildProcess); | 112 child_command_line.AppendSwitch(switches::kChildProcess); |
| 114 if (parent_command_line->HasSwitch(switches::kWaitForDebugger)) { | |
| 115 std::vector<std::string> apps_to_debug; | |
| 116 base::SplitString( | |
| 117 parent_command_line->GetSwitchValueASCII(switches::kWaitForDebugger), | |
| 118 ',', &apps_to_debug); | |
| 119 if (apps_to_debug.empty() || ContainsValue(apps_to_debug, name_)) | |
| 120 child_command_line.AppendSwitch(switches::kWaitForDebugger); | |
| 121 } | |
| 122 | 113 |
| 123 auto args = parent_command_line->GetArgs(); | 114 auto args = parent_command_line->GetArgs(); |
| 124 for (const auto& arg : args) | 115 for (const auto& arg : args) |
| 125 child_command_line.AppendArgNative(arg); | 116 child_command_line.AppendArgNative(arg); |
| 126 | 117 |
| 127 embedder::HandlePassingInformation handle_passing_info; | 118 embedder::HandlePassingInformation handle_passing_info; |
| 128 platform_channel_pair_.PrepareToPassClientHandleToChildProcess( | 119 platform_channel_pair_.PrepareToPassClientHandleToChildProcess( |
| 129 &child_command_line, &handle_passing_info); | 120 &child_command_line, &handle_passing_info); |
| 130 | 121 |
| 131 base::LaunchOptions options; | 122 base::LaunchOptions options; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 154 | 145 |
| 155 void ChildProcessHost::DidCreateChannel(embedder::ChannelInfo* channel_info) { | 146 void ChildProcessHost::DidCreateChannel(embedder::ChannelInfo* channel_info) { |
| 156 DVLOG(2) << "AppChildProcessHost::DidCreateChannel()"; | 147 DVLOG(2) << "AppChildProcessHost::DidCreateChannel()"; |
| 157 | 148 |
| 158 CHECK(channel_info); | 149 CHECK(channel_info); |
| 159 channel_info_ = channel_info; | 150 channel_info_ = channel_info; |
| 160 } | 151 } |
| 161 | 152 |
| 162 } // namespace runner | 153 } // namespace runner |
| 163 } // namespace mojo | 154 } // namespace mojo |
| OLD | NEW |