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.h" | 5 #include "mojo/shell/child_process.h" |
6 | 6 |
7 #include "base/base_switches.h" | |
7 #include "base/bind.h" | 8 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/debug/debugger.h" | |
10 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
11 #include "base/location.h" | 13 #include "base/location.h" |
12 #include "base/logging.h" | 14 #include "base/logging.h" |
13 #include "base/macros.h" | 15 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
16 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
17 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
18 #include "base/synchronization/waitable_event.h" | 20 #include "base/synchronization/waitable_event.h" |
19 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
272 | 274 |
273 DISALLOW_COPY_AND_ASSIGN(ChildControllerImpl); | 275 DISALLOW_COPY_AND_ASSIGN(ChildControllerImpl); |
274 }; | 276 }; |
275 | 277 |
276 } // namespace | 278 } // namespace |
277 | 279 |
278 int ChildProcessMain() { | 280 int ChildProcessMain() { |
279 DVLOG(2) << "ChildProcessMain()"; | 281 DVLOG(2) << "ChildProcessMain()"; |
280 const base::CommandLine& command_line = | 282 const base::CommandLine& command_line = |
281 *base::CommandLine::ForCurrentProcess(); | 283 *base::CommandLine::ForCurrentProcess(); |
284 if (command_line.HasSwitch(switches::kWaitForDebugger)) { | |
285 std::string app = command_line.GetSwitchValueASCII(switches::kApp); | |
286 #if defined(OS_WIN) | |
287 MessageBox(NULL, command_line.GetSwitchValueNative(switches::kApp).c_str(), | |
288 command_line.GetSwitchValueNative(switches::kApp).c_str(), | |
289 MB_OK | MB_SETFOREGROUND); | |
290 #else | |
291 LOG(ERROR) << command_line.GetSwitchValueASCII(switches::kApp) | |
292 << " waiting for GDB."; | |
sky
2015/04/23 21:48:54
Can you add the process id to this output.
jam
2015/04/23 22:18:44
Done.
| |
293 base::debug::WaitForDebugger(60, true); | |
294 #endif | |
295 } | |
296 | |
282 embedder::ScopedPlatformHandle platform_channel = | 297 embedder::ScopedPlatformHandle platform_channel = |
283 embedder::PlatformChannelPair::PassClientHandleFromParentProcess( | 298 embedder::PlatformChannelPair::PassClientHandleFromParentProcess( |
284 command_line); | 299 command_line); |
285 CHECK(platform_channel.is_valid()); | 300 CHECK(platform_channel.is_valid()); |
286 | 301 |
287 DCHECK(!base::MessageLoop::current()); | 302 DCHECK(!base::MessageLoop::current()); |
288 | 303 |
289 AppContext app_context; | 304 AppContext app_context; |
290 app_context.Init(); | 305 app_context.Init(); |
291 | 306 |
292 Blocker blocker; | 307 Blocker blocker; |
293 app_context.controller_runner()->PostTask( | 308 app_context.controller_runner()->PostTask( |
294 FROM_HERE, | 309 FROM_HERE, |
295 base::Bind(&ChildControllerImpl::Init, base::Unretained(&app_context), | 310 base::Bind(&ChildControllerImpl::Init, base::Unretained(&app_context), |
296 base::Passed(&platform_channel), blocker.GetUnblocker())); | 311 base::Passed(&platform_channel), blocker.GetUnblocker())); |
297 // This will block, then run whatever the controller wants. | 312 // This will block, then run whatever the controller wants. |
298 blocker.Block(); | 313 blocker.Block(); |
299 | 314 |
300 app_context.Shutdown(); | 315 app_context.Shutdown(); |
301 | 316 |
302 return 0; | 317 return 0; |
303 } | 318 } |
304 | 319 |
305 } // namespace shell | 320 } // namespace shell |
306 } // namespace mojo | 321 } // namespace mojo |
OLD | NEW |