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/app_child_process.h" | 5 #include "mojo/shell/app_child_process.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 95 |
96 void Init() { | 96 void Init() { |
97 // Initialize Mojo before starting any threads. | 97 // Initialize Mojo before starting any threads. |
98 embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>( | 98 embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>( |
99 new mojo::embedder::SimplePlatformSupport())); | 99 new mojo::embedder::SimplePlatformSupport())); |
100 | 100 |
101 // Create and start our I/O thread. | 101 // Create and start our I/O thread. |
102 base::Thread::Options io_thread_options(base::MessageLoop::TYPE_IO, 0); | 102 base::Thread::Options io_thread_options(base::MessageLoop::TYPE_IO, 0); |
103 CHECK(io_thread_.StartWithOptions(io_thread_options)); | 103 CHECK(io_thread_.StartWithOptions(io_thread_options)); |
104 io_runner_ = io_thread_.message_loop_proxy().get(); | 104 io_runner_ = io_thread_.message_loop_proxy().get(); |
105 CHECK(io_runner_); | 105 CHECK(io_runner_.get()); |
106 | 106 |
107 // Create and start our controller thread. | 107 // Create and start our controller thread. |
108 base::Thread::Options controller_thread_options; | 108 base::Thread::Options controller_thread_options; |
109 controller_thread_options.message_loop_type = | 109 controller_thread_options.message_loop_type = |
110 base::MessageLoop::TYPE_CUSTOM; | 110 base::MessageLoop::TYPE_CUSTOM; |
111 controller_thread_options.message_pump_factory = | 111 controller_thread_options.message_pump_factory = |
112 base::Bind(&common::MessagePumpMojo::Create); | 112 base::Bind(&common::MessagePumpMojo::Create); |
113 CHECK(controller_thread_.StartWithOptions(controller_thread_options)); | 113 CHECK(controller_thread_.StartWithOptions(controller_thread_options)); |
114 controller_runner_ = controller_thread_.message_loop_proxy().get(); | 114 controller_runner_ = controller_thread_.message_loop_proxy().get(); |
115 CHECK(controller_runner_); | 115 CHECK(controller_runner_.get()); |
116 } | 116 } |
117 | 117 |
118 void Shutdown() { | 118 void Shutdown() { |
119 controller_runner_->PostTask( | 119 controller_runner_->PostTask( |
120 FROM_HERE, | 120 FROM_HERE, |
121 base::Bind(&DestroyController, base::Passed(&controller_))); | 121 base::Bind(&DestroyController, base::Passed(&controller_))); |
122 } | 122 } |
123 | 123 |
124 base::SingleThreadTaskRunner* io_runner() const { | 124 base::SingleThreadTaskRunner* io_runner() const { |
125 return io_runner_.get(); | 125 return io_runner_.get(); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 base::Bind(&AppChildControllerImpl::Init, base::Unretained(&app_context), | 283 base::Bind(&AppChildControllerImpl::Init, base::Unretained(&app_context), |
284 base::Passed(platform_channel()), blocker.GetUnblocker())); | 284 base::Passed(platform_channel()), blocker.GetUnblocker())); |
285 // This will block, then run whatever the controller wants. | 285 // This will block, then run whatever the controller wants. |
286 blocker.Block(); | 286 blocker.Block(); |
287 | 287 |
288 app_context.Shutdown(); | 288 app_context.Shutdown(); |
289 } | 289 } |
290 | 290 |
291 } // namespace shell | 291 } // namespace shell |
292 } // namespace mojo | 292 } // namespace mojo |
OLD | NEW |