| 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_CHILD_PROCESS_HOST_H_ | 5 #ifndef MOJO_RUNNER_CHILD_PROCESS_HOST_H_ |
| 6 #define MOJO_RUNNER_CHILD_PROCESS_HOST_H_ | 6 #define MOJO_RUNNER_CHILD_PROCESS_HOST_H_ |
| 7 | 7 |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/process/process.h" | 10 #include "base/process/process.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // This class is not thread-safe. It should be created/used/destroyed on a | 26 // This class is not thread-safe. It should be created/used/destroyed on a |
| 27 // single thread. | 27 // single thread. |
| 28 // | 28 // |
| 29 // Note: Does not currently work on Windows before Vista. | 29 // Note: Does not currently work on Windows before Vista. |
| 30 // Note: After |Start()|, |StartApp| must be called and this object must | 30 // Note: After |Start()|, |StartApp| must be called and this object must |
| 31 // remained alive until the |on_app_complete| callback is called. | 31 // remained alive until the |on_app_complete| callback is called. |
| 32 class ChildProcessHost { | 32 class ChildProcessHost { |
| 33 public: | 33 public: |
| 34 // |name| is just for debugging ease. We will spawn off a process so that it | 34 // |name| is just for debugging ease. We will spawn off a process so that it |
| 35 // can be sandboxed if |start_sandboxed| is true. |app_path| is a path to the | 35 // can be sandboxed if |start_sandboxed| is true. |app_path| is a path to the |
| 36 // mojo application we wish to start. |clean_app_path| cleans up transient | 36 // mojo application we wish to start. |
| 37 // applications after execution. | |
| 38 ChildProcessHost(Context* context, | 37 ChildProcessHost(Context* context, |
| 39 bool start_sandboxed, | 38 bool start_sandboxed, |
| 40 const base::FilePath& app_path, | 39 const base::FilePath& app_path); |
| 41 bool clean_app_path); | |
| 42 virtual ~ChildProcessHost(); | 40 virtual ~ChildProcessHost(); |
| 43 | 41 |
| 44 // |Start()|s the child process; calls |DidStart()| (on the thread on which | 42 // |Start()|s the child process; calls |DidStart()| (on the thread on which |
| 45 // |Start()| was called) when the child has been started (or failed to start). | 43 // |Start()| was called) when the child has been started (or failed to start). |
| 46 // After calling |Start()|, this object must not be destroyed until | 44 // After calling |Start()|, this object must not be destroyed until |
| 47 // |DidStart()| has been called. | 45 // |DidStart()| has been called. |
| 48 // TODO(vtl): Consider using weak pointers and removing this requirement. | 46 // TODO(vtl): Consider using weak pointers and removing this requirement. |
| 49 void Start(); | 47 void Start(); |
| 50 | 48 |
| 51 // Waits for the child process to terminate, and returns its exit code. | 49 // Waits for the child process to terminate, and returns its exit code. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 66 bool DoLaunch(); | 64 bool DoLaunch(); |
| 67 | 65 |
| 68 void AppCompleted(int32_t result); | 66 void AppCompleted(int32_t result); |
| 69 | 67 |
| 70 // Callback for |embedder::CreateChannel()|. | 68 // Callback for |embedder::CreateChannel()|. |
| 71 void DidCreateChannel(embedder::ChannelInfo* channel_info); | 69 void DidCreateChannel(embedder::ChannelInfo* channel_info); |
| 72 | 70 |
| 73 Context* const context_; | 71 Context* const context_; |
| 74 bool start_sandboxed_; | 72 bool start_sandboxed_; |
| 75 const base::FilePath app_path_; | 73 const base::FilePath app_path_; |
| 76 bool clean_app_path_; | |
| 77 base::Process child_process_; | 74 base::Process child_process_; |
| 78 embedder::PlatformChannelPair platform_channel_pair_; | 75 embedder::PlatformChannelPair platform_channel_pair_; |
| 79 ChildControllerPtr controller_; | 76 ChildControllerPtr controller_; |
| 80 embedder::ChannelInfo* channel_info_; | 77 embedder::ChannelInfo* channel_info_; |
| 81 ChildController::StartAppCallback on_app_complete_; | 78 ChildController::StartAppCallback on_app_complete_; |
| 82 | 79 |
| 83 // Platform-specific "pipe" to the child process. Valid immediately after | 80 // Platform-specific "pipe" to the child process. Valid immediately after |
| 84 // creation. | 81 // creation. |
| 85 embedder::ScopedPlatformHandle platform_channel_; | 82 embedder::ScopedPlatformHandle platform_channel_; |
| 86 | 83 |
| 87 DISALLOW_COPY_AND_ASSIGN(ChildProcessHost); | 84 DISALLOW_COPY_AND_ASSIGN(ChildProcessHost); |
| 88 }; | 85 }; |
| 89 | 86 |
| 90 } // namespace runner | 87 } // namespace runner |
| 91 } // namespace mojo | 88 } // namespace mojo |
| 92 | 89 |
| 93 #endif // MOJO_RUNNER_CHILD_PROCESS_HOST_H_ | 90 #endif // MOJO_RUNNER_CHILD_PROCESS_HOST_H_ |
| OLD | NEW |