| 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 "shell/app_child_process.h" | 5 #include "shell/app_child_process.h" |
| 6 | 6 |
| 7 #include <unistd.h> | 7 #include <unistd.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 // Should be created and initialized on the main thread. | 82 // Should be created and initialized on the main thread. |
| 83 class AppContext : public embedder::ProcessDelegate { | 83 class AppContext : public embedder::ProcessDelegate { |
| 84 public: | 84 public: |
| 85 AppContext() | 85 AppContext() |
| 86 : io_thread_("io_thread"), controller_thread_("controller_thread") {} | 86 : io_thread_("io_thread"), controller_thread_("controller_thread") {} |
| 87 ~AppContext() {} | 87 ~AppContext() {} |
| 88 | 88 |
| 89 void Init() { | 89 void Init() { |
| 90 // Initialize Mojo before starting any threads. | 90 // Initialize Mojo before starting any threads. |
| 91 embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>( | 91 embedder::Init(make_scoped_ptr(new embedder::SimplePlatformSupport())); |
| 92 new mojo::embedder::SimplePlatformSupport())); | |
| 93 | 92 |
| 94 // Create and start our I/O thread. | 93 // Create and start our I/O thread. |
| 95 base::Thread::Options io_thread_options(base::MessageLoop::TYPE_IO, 0); | 94 base::Thread::Options io_thread_options(base::MessageLoop::TYPE_IO, 0); |
| 96 CHECK(io_thread_.StartWithOptions(io_thread_options)); | 95 CHECK(io_thread_.StartWithOptions(io_thread_options)); |
| 97 io_runner_ = io_thread_.message_loop_proxy().get(); | 96 io_runner_ = io_thread_.message_loop_proxy().get(); |
| 98 CHECK(io_runner_.get()); | 97 CHECK(io_runner_.get()); |
| 99 | 98 |
| 100 // Create and start our controller thread. | 99 // Create and start our controller thread. |
| 101 base::Thread::Options controller_thread_options; | 100 base::Thread::Options controller_thread_options; |
| 102 controller_thread_options.message_loop_type = | 101 controller_thread_options.message_loop_type = |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 void DidCreateChannel(embedder::ChannelInfo* channel_info) { | 238 void DidCreateChannel(embedder::ChannelInfo* channel_info) { |
| 240 DVLOG(2) << "AppChildControllerImpl::DidCreateChannel()"; | 239 DVLOG(2) << "AppChildControllerImpl::DidCreateChannel()"; |
| 241 DCHECK(thread_checker_.CalledOnValidThread()); | 240 DCHECK(thread_checker_.CalledOnValidThread()); |
| 242 channel_info_ = channel_info; | 241 channel_info_ = channel_info; |
| 243 } | 242 } |
| 244 | 243 |
| 245 static void StartAppOnMainThread( | 244 static void StartAppOnMainThread( |
| 246 const base::FilePath& app_path, | 245 const base::FilePath& app_path, |
| 247 NativeRunner::CleanupBehavior cleanup_behavior, | 246 NativeRunner::CleanupBehavior cleanup_behavior, |
| 248 InterfaceRequest<Application> application_request) { | 247 InterfaceRequest<Application> application_request) { |
| 249 // TODO(vtl): This is copied from in_process_dynamic_service_runner.cc. | 248 // TODO(vtl): This is copied from in_process_native_runner.cc. |
| 250 DVLOG(2) << "Loading/running Mojo app from " << app_path.value() | 249 DVLOG(2) << "Loading/running Mojo app from " << app_path.value() |
| 251 << " out of process"; | 250 << " out of process"; |
| 252 | 251 |
| 253 // We intentionally don't unload the native library as its lifetime is the | 252 // We intentionally don't unload the native library as its lifetime is the |
| 254 // same as that of the process. | 253 // same as that of the process. |
| 255 LoadAndRunNativeApplication(app_path, cleanup_behavior, | 254 LoadAndRunNativeApplication(app_path, cleanup_behavior, |
| 256 application_request.Pass()); | 255 application_request.Pass()); |
| 257 } | 256 } |
| 258 | 257 |
| 259 base::ThreadChecker thread_checker_; | 258 base::ThreadChecker thread_checker_; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 289 base::Bind(&AppChildControllerImpl::Init, base::Unretained(&app_context), | 288 base::Bind(&AppChildControllerImpl::Init, base::Unretained(&app_context), |
| 290 base::Passed(platform_channel()), blocker.GetUnblocker())); | 289 base::Passed(platform_channel()), blocker.GetUnblocker())); |
| 291 // This will block, then run whatever the controller wants. | 290 // This will block, then run whatever the controller wants. |
| 292 blocker.Block(); | 291 blocker.Block(); |
| 293 | 292 |
| 294 app_context.Shutdown(); | 293 app_context.Shutdown(); |
| 295 } | 294 } |
| 296 | 295 |
| 297 } // namespace shell | 296 } // namespace shell |
| 298 } // namespace mojo | 297 } // namespace mojo |
| OLD | NEW |