| 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_SHELL_RUNNER_HOST_CHILD_PROCESS_HOST_H_ | 5 #ifndef MOJO_SHELL_RUNNER_HOST_CHILD_PROCESS_HOST_H_ |
| 6 #define MOJO_SHELL_RUNNER_HOST_CHILD_PROCESS_HOST_H_ | 6 #define MOJO_SHELL_RUNNER_HOST_CHILD_PROCESS_HOST_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 explicit ChildProcessHost(ScopedHandle channel); | 57 explicit ChildProcessHost(ScopedHandle channel); |
| 58 virtual ~ChildProcessHost(); | 58 virtual ~ChildProcessHost(); |
| 59 | 59 |
| 60 // |Start()|s the child process; calls |DidStart()| (on the thread on which | 60 // |Start()|s the child process; calls |DidStart()| (on the thread on which |
| 61 // |Start()| was called) when the child has been started (or failed to start). | 61 // |Start()| was called) when the child has been started (or failed to start). |
| 62 void Start(const ProcessReadyCallback& callback); | 62 void Start(const ProcessReadyCallback& callback); |
| 63 | 63 |
| 64 // Waits for the child process to terminate, and returns its exit code. | 64 // Waits for the child process to terminate, and returns its exit code. |
| 65 int Join(); | 65 int Join(); |
| 66 | 66 |
| 67 // See |ChildController|: | 67 // See |mojom::ChildController|: |
| 68 void StartApp(InterfaceRequest<Application> application_request, | 68 void StartApp( |
| 69 const ChildController::StartAppCallback& on_app_complete); | 69 InterfaceRequest<mojom::Application> application_request, |
| 70 const mojom::ChildController::StartAppCallback& on_app_complete); |
| 70 void ExitNow(int32_t exit_code); | 71 void ExitNow(int32_t exit_code); |
| 71 | 72 |
| 72 protected: | 73 protected: |
| 73 void DidStart(); | 74 void DidStart(); |
| 74 | 75 |
| 75 private: | 76 private: |
| 76 // A thread-safe holder for the bootstrap message pipe to this child process. | 77 // A thread-safe holder for the bootstrap message pipe to this child process. |
| 77 // The pipe is established on an arbitrary thread and may not be connected | 78 // The pipe is established on an arbitrary thread and may not be connected |
| 78 // until the host's message loop has stopped running. | 79 // until the host's message loop has stopped running. |
| 79 class PipeHolder : public base::RefCountedThreadSafe<PipeHolder> { | 80 class PipeHolder : public base::RefCountedThreadSafe<PipeHolder> { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 scoped_refptr<base::TaskRunner> callback_task_runner, | 121 scoped_refptr<base::TaskRunner> callback_task_runner, |
| 121 const base::Closure& callback, | 122 const base::Closure& callback, |
| 122 ScopedMessagePipeHandle pipe); | 123 ScopedMessagePipeHandle pipe); |
| 123 | 124 |
| 124 scoped_refptr<base::TaskRunner> launch_process_runner_; | 125 scoped_refptr<base::TaskRunner> launch_process_runner_; |
| 125 bool start_sandboxed_; | 126 bool start_sandboxed_; |
| 126 const base::FilePath app_path_; | 127 const base::FilePath app_path_; |
| 127 base::Process child_process_; | 128 base::Process child_process_; |
| 128 // Used for the ChildController binding. | 129 // Used for the ChildController binding. |
| 129 embedder::PlatformChannelPair platform_channel_pair_; | 130 embedder::PlatformChannelPair platform_channel_pair_; |
| 130 ChildControllerPtr controller_; | 131 mojom::ChildControllerPtr controller_; |
| 131 embedder::ChannelInfo* channel_info_; | 132 embedder::ChannelInfo* channel_info_; |
| 132 ChildController::StartAppCallback on_app_complete_; | 133 mojom::ChildController::StartAppCallback on_app_complete_; |
| 133 embedder::HandlePassingInformation handle_passing_info_; | 134 embedder::HandlePassingInformation handle_passing_info_; |
| 134 | 135 |
| 135 // Used only when --use-new-edk is specified. Used to back the NodeChannel | 136 // Used only when --use-new-edk is specified. Used to back the NodeChannel |
| 136 // between the parent and child node. | 137 // between the parent and child node. |
| 137 scoped_ptr<edk::PlatformChannelPair> node_channel_; | 138 scoped_ptr<edk::PlatformChannelPair> node_channel_; |
| 138 | 139 |
| 139 // Since Start() calls a method on another thread, we use an event to block | 140 // Since Start() calls a method on another thread, we use an event to block |
| 140 // the main thread if it tries to destruct |this| while launching the process. | 141 // the main thread if it tries to destruct |this| while launching the process. |
| 141 base::WaitableEvent start_child_process_event_; | 142 base::WaitableEvent start_child_process_event_; |
| 142 | 143 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 153 | 154 |
| 154 base::WeakPtrFactory<ChildProcessHost> weak_factory_; | 155 base::WeakPtrFactory<ChildProcessHost> weak_factory_; |
| 155 | 156 |
| 156 DISALLOW_COPY_AND_ASSIGN(ChildProcessHost); | 157 DISALLOW_COPY_AND_ASSIGN(ChildProcessHost); |
| 157 }; | 158 }; |
| 158 | 159 |
| 159 } // namespace shell | 160 } // namespace shell |
| 160 } // namespace mojo | 161 } // namespace mojo |
| 161 | 162 |
| 162 #endif // MOJO_SHELL_RUNNER_HOST_CHILD_PROCESS_HOST_H_ | 163 #endif // MOJO_SHELL_RUNNER_HOST_CHILD_PROCESS_HOST_H_ |
| OLD | NEW |