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

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: 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
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();
30 CHECK(platform_channel_.is_valid()); 32 CHECK(platform_channel_.is_valid());
31 } 33 }
32 34
33 ChildProcessHost::~ChildProcessHost() { 35 ChildProcessHost::~ChildProcessHost() {
34 if (child_process_.IsValid()) { 36 if (child_process_.IsValid()) {
35 LOG(WARNING) << "Destroying ChildProcessHost with unjoined child"; 37 LOG(WARNING) << "Destroying ChildProcessHost with unjoined child";
36 child_process_.Close(); 38 child_process_.Close();
37 } 39 }
38 } 40 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 bool ChildProcessHost::DoLaunch() { 97 bool ChildProcessHost::DoLaunch() {
96 static const char* kForwardSwitches[] = { 98 static const char* kForwardSwitches[] = {
97 switches::kTraceToConsole, switches::kV, switches::kVModule, 99 switches::kTraceToConsole, switches::kV, switches::kVModule,
98 }; 100 };
99 101
100 const base::CommandLine* parent_command_line = 102 const base::CommandLine* parent_command_line =
101 base::CommandLine::ForCurrentProcess(); 103 base::CommandLine::ForCurrentProcess();
102 base::CommandLine child_command_line(parent_command_line->GetProgram()); 104 base::CommandLine child_command_line(parent_command_line->GetProgram());
103 child_command_line.CopySwitchesFrom(*parent_command_line, kForwardSwitches, 105 child_command_line.CopySwitchesFrom(*parent_command_line, kForwardSwitches,
104 arraysize(kForwardSwitches)); 106 arraysize(kForwardSwitches));
107 child_command_line.AppendSwitchASCII(switches::kApp, name_);
sky 2015/04/23 21:48:54 Should you only do this if name_ is not empty?
jam 2015/04/23 22:18:44 I don't expect name_ to be empty. i added a dcheck
105 child_command_line.AppendSwitch(switches::kChildProcess); 108 child_command_line.AppendSwitch(switches::kChildProcess);
109 if (parent_command_line->HasSwitch(switches::kWaitForDebugger)) {
110 std::vector<std::string> apps_to_debug;
111 base::SplitString(
112 parent_command_line->GetSwitchValueASCII(switches::kWaitForDebugger),
113 ',', &apps_to_debug);
114 if (apps_to_debug.empty() || ContainsValue(apps_to_debug, name_))
115 child_command_line.AppendSwitch(switches::kWaitForDebugger);
116 }
106 117
107 embedder::HandlePassingInformation handle_passing_info; 118 embedder::HandlePassingInformation handle_passing_info;
108 platform_channel_pair_.PrepareToPassClientHandleToChildProcess( 119 platform_channel_pair_.PrepareToPassClientHandleToChildProcess(
109 &child_command_line, &handle_passing_info); 120 &child_command_line, &handle_passing_info);
110 121
111 base::LaunchOptions options; 122 base::LaunchOptions options;
112 #if defined(OS_WIN) 123 #if defined(OS_WIN)
113 options.start_hidden = true; 124 options.start_hidden = true;
114 options.handles_to_inherit = &handle_passing_info; 125 options.handles_to_inherit = &handle_passing_info;
115 #elif defined(OS_POSIX) 126 #elif defined(OS_POSIX)
(...skipping 19 matching lines...) Expand all
135 146
136 void ChildProcessHost::DidCreateChannel(embedder::ChannelInfo* channel_info) { 147 void ChildProcessHost::DidCreateChannel(embedder::ChannelInfo* channel_info) {
137 DVLOG(2) << "AppChildProcessHost::DidCreateChannel()"; 148 DVLOG(2) << "AppChildProcessHost::DidCreateChannel()";
138 149
139 CHECK(channel_info); 150 CHECK(channel_info);
140 channel_info_ = channel_info; 151 channel_info_ = channel_info;
141 } 152 }
142 153
143 } // namespace shell 154 } // namespace shell
144 } // namespace mojo 155 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698