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/child_process.h" | 5 #include "mojo/runner/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/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
18 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
19 #include "base/synchronization/waitable_event.h" | 19 #include "base/synchronization/waitable_event.h" |
20 #include "base/thread_task_runner_handle.h" | 20 #include "base/thread_task_runner_handle.h" |
21 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
22 #include "base/threading/thread_checker.h" | 22 #include "base/threading/thread_checker.h" |
23 #include "mojo/edk/embedder/embedder.h" | |
24 #include "mojo/edk/embedder/platform_channel_pair.h" | |
25 #include "mojo/edk/embedder/process_delegate.h" | |
26 #include "mojo/edk/embedder/scoped_platform_handle.h" | |
27 #include "mojo/edk/embedder/simple_platform_support.h" | |
28 #include "mojo/message_pump/message_pump_mojo.h" | 23 #include "mojo/message_pump/message_pump_mojo.h" |
29 #include "mojo/public/cpp/bindings/binding.h" | 24 #include "mojo/public/cpp/bindings/binding.h" |
30 #include "mojo/public/cpp/system/core.h" | 25 #include "mojo/public/cpp/system/core.h" |
31 #include "mojo/runner/child_process.mojom.h" | 26 #include "mojo/runner/child_process.mojom.h" |
32 #include "mojo/runner/native_application_support.h" | 27 #include "mojo/runner/native_application_support.h" |
33 #include "mojo/runner/switches.h" | 28 #include "mojo/runner/switches.h" |
| 29 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" |
| 30 #include "third_party/mojo/src/mojo/edk/embedder/platform_channel_pair.h" |
| 31 #include "third_party/mojo/src/mojo/edk/embedder/process_delegate.h" |
| 32 #include "third_party/mojo/src/mojo/edk/embedder/scoped_platform_handle.h" |
34 | 33 |
35 #if defined(OS_LINUX) && !defined(OS_ANDROID) | 34 #if defined(OS_LINUX) && !defined(OS_ANDROID) |
36 #include "base/rand_util.h" | 35 #include "base/rand_util.h" |
37 #include "base/sys_info.h" | 36 #include "base/sys_info.h" |
38 #include "mojo/runner/linux_sandbox.h" | 37 #include "mojo/runner/linux_sandbox.h" |
39 #endif | 38 #endif |
40 | 39 |
41 namespace mojo { | 40 namespace mojo { |
42 namespace runner { | 41 namespace runner { |
43 | 42 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 base::Closure run_after_; | 84 base::Closure run_after_; |
86 | 85 |
87 DISALLOW_COPY_AND_ASSIGN(Blocker); | 86 DISALLOW_COPY_AND_ASSIGN(Blocker); |
88 }; | 87 }; |
89 | 88 |
90 // AppContext ------------------------------------------------------------------ | 89 // AppContext ------------------------------------------------------------------ |
91 | 90 |
92 class ChildControllerImpl; | 91 class ChildControllerImpl; |
93 | 92 |
94 // Should be created and initialized on the main thread. | 93 // Should be created and initialized on the main thread. |
| 94 // TODO(use_chrome_edk) |
| 95 //class AppContext : public edk::ProcessDelegate { |
95 class AppContext : public embedder::ProcessDelegate { | 96 class AppContext : public embedder::ProcessDelegate { |
96 public: | 97 public: |
97 AppContext() | 98 AppContext() |
98 : io_thread_("io_thread"), controller_thread_("controller_thread") {} | 99 : io_thread_("io_thread"), controller_thread_("controller_thread") {} |
99 ~AppContext() override {} | 100 ~AppContext() override {} |
100 | 101 |
101 void Init() { | 102 void Init() { |
102 // Initialize Mojo before starting any threads. | 103 // Initialize Mojo before starting any threads. |
103 embedder::Init(make_scoped_ptr(new embedder::SimplePlatformSupport())); | 104 embedder::Init(); |
104 | 105 |
105 // Create and start our I/O thread. | 106 // Create and start our I/O thread. |
106 base::Thread::Options io_thread_options(base::MessageLoop::TYPE_IO, 0); | 107 base::Thread::Options io_thread_options(base::MessageLoop::TYPE_IO, 0); |
107 CHECK(io_thread_.StartWithOptions(io_thread_options)); | 108 CHECK(io_thread_.StartWithOptions(io_thread_options)); |
108 io_runner_ = io_thread_.task_runner().get(); | 109 io_runner_ = io_thread_.task_runner().get(); |
109 CHECK(io_runner_.get()); | 110 CHECK(io_runner_.get()); |
110 | 111 |
111 // Create and start our controller thread. | 112 // Create and start our controller thread. |
112 base::Thread::Options controller_thread_options; | 113 base::Thread::Options controller_thread_options; |
113 controller_thread_options.message_loop_type = | 114 controller_thread_options.message_loop_type = |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 // This will block, then run whatever the controller wants. | 343 // This will block, then run whatever the controller wants. |
343 blocker.Block(); | 344 blocker.Block(); |
344 | 345 |
345 app_context.Shutdown(); | 346 app_context.Shutdown(); |
346 | 347 |
347 return 0; | 348 return 0; |
348 } | 349 } |
349 | 350 |
350 } // namespace runner | 351 } // namespace runner |
351 } // namespace mojo | 352 } // namespace mojo |
OLD | NEW |