Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(770)

Side by Side Diff: mojo/shell/child_process_host.cc

Issue 1107633002: Improve multi-process debugging. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/shell/child_process_host.h ('k') | mojo/shell/child_process_host_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
17 #include "base/strings/string_split.h"
16 #include "base/task_runner.h" 18 #include "base/task_runner.h"
17 #include "base/task_runner_util.h" 19 #include "base/task_runner_util.h"
18 #include "mojo/edk/embedder/embedder.h" 20 #include "mojo/edk/embedder/embedder.h"
19 #include "mojo/public/cpp/system/core.h" 21 #include "mojo/public/cpp/system/core.h"
20 #include "mojo/shell/context.h" 22 #include "mojo/shell/context.h"
21 #include "mojo/shell/switches.h" 23 #include "mojo/shell/switches.h"
22 #include "mojo/shell/task_runners.h" 24 #include "mojo/shell/task_runners.h"
23 25
24 namespace mojo { 26 namespace mojo {
25 namespace shell { 27 namespace shell {
26 28
27 ChildProcessHost::ChildProcessHost(Context* context) 29 ChildProcessHost::ChildProcessHost(Context* context, const std::string& name)
28 : context_(context), channel_info_(nullptr) { 30 : context_(context), name_(name), channel_info_(nullptr) {
29 platform_channel_ = platform_channel_pair_.PassServerHandle(); 31 platform_channel_ = platform_channel_pair_.PassServerHandle();
32 DCHECK(!name.empty());
30 CHECK(platform_channel_.is_valid()); 33 CHECK(platform_channel_.is_valid());
31 } 34 }
32 35
33 ChildProcessHost::~ChildProcessHost() { 36 ChildProcessHost::~ChildProcessHost() {
34 if (child_process_.IsValid()) { 37 if (child_process_.IsValid()) {
35 LOG(WARNING) << "Destroying ChildProcessHost with unjoined child"; 38 LOG(WARNING) << "Destroying ChildProcessHost with unjoined child";
36 child_process_.Close(); 39 child_process_.Close();
37 } 40 }
38 } 41 }
39 42
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 bool ChildProcessHost::DoLaunch() { 98 bool ChildProcessHost::DoLaunch() {
96 static const char* kForwardSwitches[] = { 99 static const char* kForwardSwitches[] = {
97 switches::kTraceToConsole, switches::kV, switches::kVModule, 100 switches::kTraceToConsole, switches::kV, switches::kVModule,
98 }; 101 };
99 102
100 const base::CommandLine* parent_command_line = 103 const base::CommandLine* parent_command_line =
101 base::CommandLine::ForCurrentProcess(); 104 base::CommandLine::ForCurrentProcess();
102 base::CommandLine child_command_line(parent_command_line->GetProgram()); 105 base::CommandLine child_command_line(parent_command_line->GetProgram());
103 child_command_line.CopySwitchesFrom(*parent_command_line, kForwardSwitches, 106 child_command_line.CopySwitchesFrom(*parent_command_line, kForwardSwitches,
104 arraysize(kForwardSwitches)); 107 arraysize(kForwardSwitches));
108 child_command_line.AppendSwitchASCII(switches::kApp, name_);
105 child_command_line.AppendSwitch(switches::kChildProcess); 109 child_command_line.AppendSwitch(switches::kChildProcess);
110 if (parent_command_line->HasSwitch(switches::kWaitForDebugger)) {
111 std::vector<std::string> apps_to_debug;
112 base::SplitString(
113 parent_command_line->GetSwitchValueASCII(switches::kWaitForDebugger),
114 ',', &apps_to_debug);
115 if (apps_to_debug.empty() || ContainsValue(apps_to_debug, name_))
116 child_command_line.AppendSwitch(switches::kWaitForDebugger);
117 }
106 118
107 embedder::HandlePassingInformation handle_passing_info; 119 embedder::HandlePassingInformation handle_passing_info;
108 platform_channel_pair_.PrepareToPassClientHandleToChildProcess( 120 platform_channel_pair_.PrepareToPassClientHandleToChildProcess(
109 &child_command_line, &handle_passing_info); 121 &child_command_line, &handle_passing_info);
110 122
111 base::LaunchOptions options; 123 base::LaunchOptions options;
112 #if defined(OS_WIN) 124 #if defined(OS_WIN)
113 options.start_hidden = true; 125 options.start_hidden = true;
114 options.handles_to_inherit = &handle_passing_info; 126 options.handles_to_inherit = &handle_passing_info;
115 #elif defined(OS_POSIX) 127 #elif defined(OS_POSIX)
(...skipping 19 matching lines...) Expand all
135 147
136 void ChildProcessHost::DidCreateChannel(embedder::ChannelInfo* channel_info) { 148 void ChildProcessHost::DidCreateChannel(embedder::ChannelInfo* channel_info) {
137 DVLOG(2) << "AppChildProcessHost::DidCreateChannel()"; 149 DVLOG(2) << "AppChildProcessHost::DidCreateChannel()";
138 150
139 CHECK(channel_info); 151 CHECK(channel_info);
140 channel_info_ = channel_info; 152 channel_info_ = channel_info;
141 } 153 }
142 154
143 } // namespace shell 155 } // namespace shell
144 } // namespace mojo 156 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/child_process_host.h ('k') | mojo/shell/child_process_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698