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/host/child_process.h" | 5 #include "mojo/runner/host/child_process.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/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/debug/stack_trace.h" |
11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
12 #include "base/i18n/icu_util.h" | 13 #include "base/i18n/icu_util.h" |
13 #include "base/location.h" | 14 #include "base/location.h" |
14 #include "base/logging.h" | 15 #include "base/logging.h" |
15 #include "base/macros.h" | 16 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
18 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
19 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
20 #include "base/synchronization/waitable_event.h" | 21 #include "base/synchronization/waitable_event.h" |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 const base::CommandLine& command_line = | 353 const base::CommandLine& command_line = |
353 *base::CommandLine::ForCurrentProcess(); | 354 *base::CommandLine::ForCurrentProcess(); |
354 | 355 |
355 #if defined(OS_LINUX) && !defined(OS_ANDROID) | 356 #if defined(OS_LINUX) && !defined(OS_ANDROID) |
356 scoped_ptr<mojo::runner::LinuxSandbox> sandbox; | 357 scoped_ptr<mojo::runner::LinuxSandbox> sandbox; |
357 #endif | 358 #endif |
358 base::NativeLibrary app_library = 0; | 359 base::NativeLibrary app_library = 0; |
359 // Load the application library before we engage the sandbox. | 360 // Load the application library before we engage the sandbox. |
360 app_library = mojo::runner::LoadNativeApplication( | 361 app_library = mojo::runner::LoadNativeApplication( |
361 command_line.GetSwitchValuePath(switches::kChildProcess)); | 362 command_line.GetSwitchValuePath(switches::kChildProcess)); |
362 | |
363 base::i18n::InitializeICU(); | 363 base::i18n::InitializeICU(); |
364 if (app_library) | 364 if (app_library) |
365 CallLibraryEarlyInitialization(app_library); | 365 CallLibraryEarlyInitialization(app_library); |
366 #if defined(OS_LINUX) && !defined(OS_ANDROID) | 366 #if defined(OS_LINUX) && !defined(OS_ANDROID) |
367 if (command_line.HasSwitch(switches::kEnableSandbox)) | 367 if (command_line.HasSwitch(switches::kEnableSandbox)) { |
| 368 #if !defined(OFFICIAL_BUILD) |
| 369 // Initialize stack dumping just before initializing sandbox to make |
| 370 // sure symbol names in all loaded libraries will be cached. |
| 371 base::debug::EnableInProcessStackDumping(); |
| 372 #endif |
368 sandbox = InitializeSandbox(); | 373 sandbox = InitializeSandbox(); |
| 374 } |
369 #endif | 375 #endif |
370 | 376 |
371 embedder::ScopedPlatformHandle platform_channel = | 377 embedder::ScopedPlatformHandle platform_channel = |
372 embedder::PlatformChannelPair::PassClientHandleFromParentProcess( | 378 embedder::PlatformChannelPair::PassClientHandleFromParentProcess( |
373 command_line); | 379 command_line); |
374 CHECK(platform_channel.is_valid()); | 380 CHECK(platform_channel.is_valid()); |
375 | 381 |
376 DCHECK(!base::MessageLoop::current()); | 382 DCHECK(!base::MessageLoop::current()); |
377 | 383 |
378 AppContext app_context; | 384 AppContext app_context; |
379 app_context.Init(); | 385 app_context.Init(); |
380 ScopedMessagePipeHandle host_message_pipe = InitializeHostMessagePipe( | 386 ScopedMessagePipeHandle host_message_pipe = InitializeHostMessagePipe( |
381 platform_channel.Pass(), app_context.io_runner()); | 387 platform_channel.Pass(), app_context.io_runner()); |
382 Blocker blocker; | 388 Blocker blocker; |
383 app_context.controller_runner()->PostTask( | 389 app_context.controller_runner()->PostTask( |
384 FROM_HERE, | 390 FROM_HERE, |
385 base::Bind(&ChildControllerImpl::Init, base::Unretained(&app_context), | 391 base::Bind(&ChildControllerImpl::Init, base::Unretained(&app_context), |
386 base::Unretained(app_library), | 392 base::Unretained(app_library), |
387 base::Passed(&host_message_pipe), blocker.GetUnblocker())); | 393 base::Passed(&host_message_pipe), blocker.GetUnblocker())); |
388 // This will block, then run whatever the controller wants. | 394 // This will block, then run whatever the controller wants. |
389 blocker.Block(); | 395 blocker.Block(); |
390 | 396 |
391 app_context.Shutdown(); | 397 app_context.Shutdown(); |
392 | 398 |
393 return 0; | 399 return 0; |
394 } | 400 } |
395 | 401 |
396 } // namespace runner | 402 } // namespace runner |
397 } // namespace mojo | 403 } // namespace mojo |
OLD | NEW |