| 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 "services/shell/runner/host/child_process_base.h" | 5 #include "services/shell/runner/host/child_process_base.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/debug/stack_trace.h" | 8 #include "base/debug/stack_trace.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 sandbox->Seal(); | 55 sandbox->Seal(); |
| 56 return sandbox; | 56 return sandbox; |
| 57 } | 57 } |
| 58 #endif | 58 #endif |
| 59 | 59 |
| 60 // Should be created and initialized on the main thread and kept alive as long | 60 // Should be created and initialized on the main thread and kept alive as long |
| 61 // a Mojo application is running in the current process. | 61 // a Mojo application is running in the current process. |
| 62 class ScopedAppContext : public mojo::edk::ProcessDelegate { | 62 class ScopedAppContext : public mojo::edk::ProcessDelegate { |
| 63 public: | 63 public: |
| 64 ScopedAppContext() | 64 ScopedAppContext() |
| 65 : io_thread_("io_thread"), wait_for_shutdown_event_(true, false) { | 65 : io_thread_("io_thread"), |
| 66 wait_for_shutdown_event_( |
| 67 base::WaitableEvent::ResetPolicy::MANUAL, |
| 68 base::WaitableEvent::InitialState::NOT_SIGNALED) { |
| 66 // Initialize Mojo before starting any threads. | 69 // Initialize Mojo before starting any threads. |
| 67 mojo::edk::Init(); | 70 mojo::edk::Init(); |
| 68 | 71 |
| 69 // Create and start our I/O thread. | 72 // Create and start our I/O thread. |
| 70 base::Thread::Options io_thread_options(base::MessageLoop::TYPE_IO, 0); | 73 base::Thread::Options io_thread_options(base::MessageLoop::TYPE_IO, 0); |
| 71 CHECK(io_thread_.StartWithOptions(io_thread_options)); | 74 CHECK(io_thread_.StartWithOptions(io_thread_options)); |
| 72 io_runner_ = io_thread_.task_runner().get(); | 75 io_runner_ = io_thread_.task_runner().get(); |
| 73 CHECK(io_runner_.get()); | 76 CHECK(io_runner_.get()); |
| 74 | 77 |
| 75 mojo::edk::InitIPCSupport(this, io_runner_); | 78 mojo::edk::InitIPCSupport(this, io_runner_); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 *base::CommandLine::ForCurrentProcess(); | 120 *base::CommandLine::ForCurrentProcess(); |
| 118 if (command_line.HasSwitch(switches::kEnableSandbox)) | 121 if (command_line.HasSwitch(switches::kEnableSandbox)) |
| 119 sandbox = InitializeSandbox(); | 122 sandbox = InitializeSandbox(); |
| 120 #endif | 123 #endif |
| 121 | 124 |
| 122 ScopedAppContext app_context; | 125 ScopedAppContext app_context; |
| 123 callback.Run(GetShellClientRequestFromCommandLine()); | 126 callback.Run(GetShellClientRequestFromCommandLine()); |
| 124 } | 127 } |
| 125 | 128 |
| 126 } // namespace shell | 129 } // namespace shell |
| OLD | NEW |