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_host.h" | 5 #include "mojo/shell/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" | 16 #include "base/stl_util.h" |
17 #include "base/strings/string_split.h" | 17 #include "base/strings/string_split.h" |
18 #include "base/task_runner.h" | 18 #include "base/task_runner.h" |
19 #include "base/task_runner_util.h" | 19 #include "base/task_runner_util.h" |
20 #include "mojo/edk/embedder/embedder.h" | 20 #include "mojo/edk/embedder/embedder.h" |
21 #include "mojo/public/cpp/system/core.h" | 21 #include "mojo/public/cpp/system/core.h" |
22 #include "mojo/shell/context.h" | 22 #include "mojo/shell/context.h" |
23 #include "mojo/shell/switches.h" | 23 #include "mojo/shell/switches.h" |
24 #include "mojo/shell/task_runners.h" | 24 #include "mojo/shell/task_runners.h" |
| 25 #include "ui/gl/gl_switches.h" |
25 | 26 |
26 namespace mojo { | 27 namespace mojo { |
27 namespace shell { | 28 namespace shell { |
28 | 29 |
29 ChildProcessHost::ChildProcessHost(Context* context, const std::string& name) | 30 ChildProcessHost::ChildProcessHost(Context* context, const std::string& name) |
30 : context_(context), name_(name), channel_info_(nullptr) { | 31 : context_(context), name_(name), channel_info_(nullptr) { |
31 platform_channel_ = platform_channel_pair_.PassServerHandle(); | 32 platform_channel_ = platform_channel_pair_.PassServerHandle(); |
32 DCHECK(!name.empty()); | 33 DCHECK(!name.empty()); |
33 CHECK(platform_channel_.is_valid()); | 34 CHECK(platform_channel_.is_valid()); |
34 } | 35 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 91 |
91 if (!success) { | 92 if (!success) { |
92 LOG(ERROR) << "Failed to start child process"; | 93 LOG(ERROR) << "Failed to start child process"; |
93 AppCompleted(MOJO_RESULT_UNKNOWN); | 94 AppCompleted(MOJO_RESULT_UNKNOWN); |
94 return; | 95 return; |
95 } | 96 } |
96 } | 97 } |
97 | 98 |
98 bool ChildProcessHost::DoLaunch() { | 99 bool ChildProcessHost::DoLaunch() { |
99 static const char* kForwardSwitches[] = { | 100 static const char* kForwardSwitches[] = { |
100 switches::kTraceToConsole, switches::kV, switches::kVModule, | 101 switches::kOverrideUseGLWithOSMesaForTests, |
| 102 switches::kTraceToConsole, |
| 103 switches::kV, |
| 104 switches::kVModule, |
101 }; | 105 }; |
102 | 106 |
103 const base::CommandLine* parent_command_line = | 107 const base::CommandLine* parent_command_line = |
104 base::CommandLine::ForCurrentProcess(); | 108 base::CommandLine::ForCurrentProcess(); |
105 base::CommandLine child_command_line(parent_command_line->GetProgram()); | 109 base::CommandLine child_command_line(parent_command_line->GetProgram()); |
106 child_command_line.CopySwitchesFrom(*parent_command_line, kForwardSwitches, | 110 child_command_line.CopySwitchesFrom(*parent_command_line, kForwardSwitches, |
107 arraysize(kForwardSwitches)); | 111 arraysize(kForwardSwitches)); |
108 child_command_line.AppendSwitchASCII(switches::kApp, name_); | 112 child_command_line.AppendSwitchASCII(switches::kApp, name_); |
109 child_command_line.AppendSwitch(switches::kChildProcess); | 113 child_command_line.AppendSwitch(switches::kChildProcess); |
110 if (parent_command_line->HasSwitch(switches::kWaitForDebugger)) { | 114 if (parent_command_line->HasSwitch(switches::kWaitForDebugger)) { |
111 std::vector<std::string> apps_to_debug; | 115 std::vector<std::string> apps_to_debug; |
112 base::SplitString( | 116 base::SplitString( |
113 parent_command_line->GetSwitchValueASCII(switches::kWaitForDebugger), | 117 parent_command_line->GetSwitchValueASCII(switches::kWaitForDebugger), |
114 ',', &apps_to_debug); | 118 ',', &apps_to_debug); |
115 if (apps_to_debug.empty() || ContainsValue(apps_to_debug, name_)) | 119 if (apps_to_debug.empty() || ContainsValue(apps_to_debug, name_)) |
116 child_command_line.AppendSwitch(switches::kWaitForDebugger); | 120 child_command_line.AppendSwitch(switches::kWaitForDebugger); |
117 } | 121 } |
118 | 122 |
| 123 auto args = parent_command_line->GetArgs(); |
| 124 for (const auto& arg : args) |
| 125 child_command_line.AppendArgNative(arg); |
| 126 |
119 embedder::HandlePassingInformation handle_passing_info; | 127 embedder::HandlePassingInformation handle_passing_info; |
120 platform_channel_pair_.PrepareToPassClientHandleToChildProcess( | 128 platform_channel_pair_.PrepareToPassClientHandleToChildProcess( |
121 &child_command_line, &handle_passing_info); | 129 &child_command_line, &handle_passing_info); |
122 | 130 |
123 base::LaunchOptions options; | 131 base::LaunchOptions options; |
124 #if defined(OS_WIN) | 132 #if defined(OS_WIN) |
125 options.handles_to_inherit = &handle_passing_info; | 133 options.handles_to_inherit = &handle_passing_info; |
126 #elif defined(OS_POSIX) | 134 #elif defined(OS_POSIX) |
127 options.fds_to_remap = &handle_passing_info; | 135 options.fds_to_remap = &handle_passing_info; |
128 #endif | 136 #endif |
(...skipping 17 matching lines...) Expand all Loading... |
146 | 154 |
147 void ChildProcessHost::DidCreateChannel(embedder::ChannelInfo* channel_info) { | 155 void ChildProcessHost::DidCreateChannel(embedder::ChannelInfo* channel_info) { |
148 DVLOG(2) << "AppChildProcessHost::DidCreateChannel()"; | 156 DVLOG(2) << "AppChildProcessHost::DidCreateChannel()"; |
149 | 157 |
150 CHECK(channel_info); | 158 CHECK(channel_info); |
151 channel_info_ = channel_info; | 159 channel_info_ = channel_info; |
152 } | 160 } |
153 | 161 |
154 } // namespace shell | 162 } // namespace shell |
155 } // namespace mojo | 163 } // namespace mojo |
OLD | NEW |