| 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/debug/debugger.h" | 11 #include "base/debug/debugger.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
| 19 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
| 20 #include "base/synchronization/waitable_event.h" | 20 #include "base/synchronization/waitable_event.h" |
| 21 #include "base/thread_task_runner_handle.h" | |
| 22 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
| 23 #include "base/threading/thread_checker.h" | 22 #include "base/threading/thread_checker.h" |
| 24 #include "mojo/common/message_pump_mojo.h" | 23 #include "mojo/common/message_pump_mojo.h" |
| 25 #include "mojo/edk/embedder/embedder.h" | 24 #include "mojo/edk/embedder/embedder.h" |
| 26 #include "mojo/edk/embedder/platform_channel_pair.h" | 25 #include "mojo/edk/embedder/platform_channel_pair.h" |
| 27 #include "mojo/edk/embedder/process_delegate.h" | 26 #include "mojo/edk/embedder/process_delegate.h" |
| 28 #include "mojo/edk/embedder/scoped_platform_handle.h" | 27 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 29 #include "mojo/edk/embedder/simple_platform_support.h" | 28 #include "mojo/edk/embedder/simple_platform_support.h" |
| 30 #include "mojo/public/cpp/system/core.h" | 29 #include "mojo/public/cpp/system/core.h" |
| 31 #include "mojo/runner/child_process.mojom.h" | 30 #include "mojo/runner/child_process.mojom.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 const Blocker::Unblocker& unblocker) { | 184 const Blocker::Unblocker& unblocker) { |
| 186 DCHECK(app_context); | 185 DCHECK(app_context); |
| 187 DCHECK(platform_channel.is_valid()); | 186 DCHECK(platform_channel.is_valid()); |
| 188 | 187 |
| 189 DCHECK(!app_context->controller()); | 188 DCHECK(!app_context->controller()); |
| 190 | 189 |
| 191 scoped_ptr<ChildControllerImpl> impl( | 190 scoped_ptr<ChildControllerImpl> impl( |
| 192 new ChildControllerImpl(app_context, unblocker)); | 191 new ChildControllerImpl(app_context, unblocker)); |
| 193 | 192 |
| 194 ScopedMessagePipeHandle host_message_pipe(embedder::CreateChannel( | 193 ScopedMessagePipeHandle host_message_pipe(embedder::CreateChannel( |
| 195 platform_channel.Pass(), | 194 platform_channel.Pass(), app_context->io_runner(), |
| 196 app_context->io_runner(), | |
| 197 base::Bind(&ChildControllerImpl::DidCreateChannel, | 195 base::Bind(&ChildControllerImpl::DidCreateChannel, |
| 198 base::Unretained(impl.get())), | 196 base::Unretained(impl.get())), |
| 199 base::ThreadTaskRunnerHandle::Get())); | 197 base::MessageLoopProxy::current())); |
| 200 | 198 |
| 201 impl->Bind(host_message_pipe.Pass()); | 199 impl->Bind(host_message_pipe.Pass()); |
| 202 | 200 |
| 203 app_context->set_controller(impl.Pass()); | 201 app_context->set_controller(impl.Pass()); |
| 204 } | 202 } |
| 205 | 203 |
| 206 void Bind(ScopedMessagePipeHandle handle) { binding_.Bind(handle.Pass()); } | 204 void Bind(ScopedMessagePipeHandle handle) { binding_.Bind(handle.Pass()); } |
| 207 | 205 |
| 208 // |ErrorHandler| methods: | 206 // |ErrorHandler| methods: |
| 209 void OnConnectionError() override { | 207 void OnConnectionError() override { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 // This will block, then run whatever the controller wants. | 312 // This will block, then run whatever the controller wants. |
| 315 blocker.Block(); | 313 blocker.Block(); |
| 316 | 314 |
| 317 app_context.Shutdown(); | 315 app_context.Shutdown(); |
| 318 | 316 |
| 319 return 0; | 317 return 0; |
| 320 } | 318 } |
| 321 | 319 |
| 322 } // namespace runner | 320 } // namespace runner |
| 323 } // namespace mojo | 321 } // namespace mojo |
| OLD | NEW |