| 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 #ifndef MOJO_RUNNER_HOST_CHILD_PROCESS_HOST_H_ | 5 #ifndef MOJO_RUNNER_HOST_CHILD_PROCESS_HOST_H_ |
| 6 #define MOJO_RUNNER_HOST_CHILD_PROCESS_HOST_H_ | 6 #define MOJO_RUNNER_HOST_CHILD_PROCESS_HOST_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/process/process.h" | 13 #include "base/process/process.h" |
| 14 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
| 15 #include "mojo/edk/embedder/platform_channel_pair.h" | 15 #include "mojo/edk/embedder/platform_channel_pair.h" |
| 16 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 16 #include "mojo/public/cpp/system/message_pipe.h" | 17 #include "mojo/public/cpp/system/message_pipe.h" |
| 17 #include "mojo/runner/child/child_controller.mojom.h" | 18 #include "mojo/runner/child/child_controller.mojom.h" |
| 18 #include "mojo/runner/host/child_process_host.h" | 19 #include "mojo/runner/host/child_process_host.h" |
| 19 #include "third_party/mojo/src/mojo/edk/embedder/channel_info_forward.h" | |
| 20 #include "third_party/mojo/src/mojo/edk/embedder/platform_channel_pair.h" | |
| 21 #include "third_party/mojo/src/mojo/edk/embedder/scoped_platform_handle.h" | |
| 22 | 20 |
| 23 namespace base { | 21 namespace base { |
| 24 class TaskRunner; | 22 class TaskRunner; |
| 25 } | 23 } |
| 26 | 24 |
| 27 namespace mojo { | 25 namespace mojo { |
| 28 namespace runner { | 26 namespace runner { |
| 29 | 27 |
| 30 // This class represents a "child process host". Handles launching and | 28 // This class represents a "child process host". Handles launching and |
| 31 // connecting a platform-specific "pipe" to the child, and supports joining the | 29 // connecting a platform-specific "pipe" to the child, and supports joining the |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 protected: | 64 protected: |
| 67 // virtual for testing. | 65 // virtual for testing. |
| 68 virtual void DidStart( | 66 virtual void DidStart( |
| 69 const base::Callback<void(base::ProcessId)>& pid_available_callback); | 67 const base::Callback<void(base::ProcessId)>& pid_available_callback); |
| 70 | 68 |
| 71 private: | 69 private: |
| 72 void DoLaunch(); | 70 void DoLaunch(); |
| 73 | 71 |
| 74 void AppCompleted(int32_t result); | 72 void AppCompleted(int32_t result); |
| 75 | 73 |
| 76 // Callback for |embedder::CreateChannel()|. | |
| 77 void DidCreateChannel(embedder::ChannelInfo* channel_info); | |
| 78 | |
| 79 scoped_refptr<base::TaskRunner> launch_process_runner_; | 74 scoped_refptr<base::TaskRunner> launch_process_runner_; |
| 80 bool start_sandboxed_; | 75 bool start_sandboxed_; |
| 81 const base::FilePath app_path_; | 76 const base::FilePath app_path_; |
| 82 base::Process child_process_; | 77 base::Process child_process_; |
| 83 // Used for the ChildController binding. | 78 // Used for the ChildController binding. |
| 84 embedder::PlatformChannelPair platform_channel_pair_; | 79 edk::PlatformChannelPair platform_channel_pair_; |
| 85 ChildControllerPtr controller_; | 80 ChildControllerPtr controller_; |
| 86 embedder::ChannelInfo* channel_info_; | |
| 87 ChildController::StartAppCallback on_app_complete_; | 81 ChildController::StartAppCallback on_app_complete_; |
| 88 embedder::HandlePassingInformation handle_passing_info_; | 82 edk::HandlePassingInformation handle_passing_info_; |
| 89 | 83 |
| 90 // Used only when --use-new-edk is specified, as a communication channel for | 84 // Used as a communication channel for Broker. |
| 91 // Broker. | |
| 92 scoped_ptr<edk::PlatformChannelPair> serializer_platform_channel_pair_; | 85 scoped_ptr<edk::PlatformChannelPair> serializer_platform_channel_pair_; |
| 93 | 86 |
| 94 // Since Start() calls a method on another thread, we use an event to block | 87 // Since Start() calls a method on another thread, we use an event to block |
| 95 // the main thread if it tries to destruct |this| while launching the process. | 88 // the main thread if it tries to destruct |this| while launching the process. |
| 96 base::WaitableEvent start_child_process_event_; | 89 base::WaitableEvent start_child_process_event_; |
| 97 | 90 |
| 98 // A message pipe to the child process. Valid immediately after creation. | 91 // A message pipe to the child process. Valid immediately after creation. |
| 99 mojo::ScopedMessagePipeHandle child_message_pipe_; | 92 mojo::ScopedMessagePipeHandle child_message_pipe_; |
| 100 | 93 |
| 101 base::WeakPtrFactory<ChildProcessHost> weak_factory_; | 94 base::WeakPtrFactory<ChildProcessHost> weak_factory_; |
| 102 | 95 |
| 103 DISALLOW_COPY_AND_ASSIGN(ChildProcessHost); | 96 DISALLOW_COPY_AND_ASSIGN(ChildProcessHost); |
| 104 }; | 97 }; |
| 105 | 98 |
| 106 } // namespace runner | 99 } // namespace runner |
| 107 } // namespace mojo | 100 } // namespace mojo |
| 108 | 101 |
| 109 #endif // MOJO_RUNNER_HOST_CHILD_PROCESS_HOST_H_ | 102 #endif // MOJO_RUNNER_HOST_CHILD_PROCESS_HOST_H_ |
| OLD | NEW |