Chromium Code Reviews| 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 SHELL_CHILD_PROCESS_HOST_H_ | 5 #ifndef SHELL_CHILD_PROCESS_HOST_H_ |
| 6 #define SHELL_CHILD_PROCESS_HOST_H_ | 6 #define SHELL_CHILD_PROCESS_HOST_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/process/process.h" | 9 #include "base/process/process.h" |
| 10 #include "mojo/edk/embedder/channel_info_forward.h" | 10 #include "mojo/edk/embedder/channel_info_forward.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 // child process. Currently runs a single app (loaded from the file system). | 23 // child process. Currently runs a single app (loaded from the file system). |
| 24 // | 24 // |
| 25 // This class is not thread-safe. It should be created/used/destroyed on a | 25 // This class is not thread-safe. It should be created/used/destroyed on a |
| 26 // single thread. | 26 // single thread. |
| 27 // | 27 // |
| 28 // Note: Does not currently work on Windows before Vista. | 28 // Note: Does not currently work on Windows before Vista. |
| 29 // Note: After |Start()|, |StartApp| must be called and this object must | 29 // Note: After |Start()|, |StartApp| must be called and this object must |
| 30 // remained alive until the |on_app_complete| callback is called. | 30 // remained alive until the |on_app_complete| callback is called. |
| 31 class ChildProcessHost { | 31 class ChildProcessHost { |
| 32 public: | 32 public: |
| 33 explicit ChildProcessHost(Context* context); | 33 // |name| is just for debugging ease. |
| 34 ChildProcessHost(Context* context, const std::string& name); | |
| 34 virtual ~ChildProcessHost(); | 35 virtual ~ChildProcessHost(); |
| 35 | 36 |
| 36 // |Start()|s the child process; calls |DidStart()| (on the thread on which | 37 // |Start()|s the child process; calls |DidStart()| (on the thread on which |
| 37 // |Start()| was called) when the child has been started (or failed to start). | 38 // |Start()| was called) when the child has been started (or failed to start). |
| 38 // After calling |Start()|, this object must not be destroyed until | 39 // After calling |Start()|, this object must not be destroyed until |
| 39 // |DidStart()| has been called. | 40 // |DidStart()| has been called. |
| 40 // TODO(vtl): Consider using weak pointers and removing this requirement. | 41 // TODO(vtl): Consider using weak pointers and removing this requirement. |
| 41 void Start(); | 42 void Start(); |
| 42 | 43 |
| 43 // Waits for the child process to terminate, and returns its exit code. | 44 // Waits for the child process to terminate, and returns its exit code. |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 58 | 59 |
| 59 private: | 60 private: |
| 60 bool DoLaunch(); | 61 bool DoLaunch(); |
| 61 | 62 |
| 62 void AppCompleted(int32_t result); | 63 void AppCompleted(int32_t result); |
| 63 | 64 |
| 64 // Callback for |embedder::CreateChannel()|. | 65 // Callback for |embedder::CreateChannel()|. |
| 65 void DidCreateChannel(embedder::ChannelInfo* channel_info); | 66 void DidCreateChannel(embedder::ChannelInfo* channel_info); |
| 66 | 67 |
| 67 Context* const context_; | 68 Context* const context_; |
| 69 std::string name_; | |
|
sky
2015/04/23 21:48:54
nit: const
jam
2015/04/23 22:18:44
Done.
| |
| 68 base::Process child_process_; | 70 base::Process child_process_; |
| 69 embedder::PlatformChannelPair platform_channel_pair_; | 71 embedder::PlatformChannelPair platform_channel_pair_; |
| 70 ChildControllerPtr controller_; | 72 ChildControllerPtr controller_; |
| 71 embedder::ChannelInfo* channel_info_; | 73 embedder::ChannelInfo* channel_info_; |
| 72 ChildController::StartAppCallback on_app_complete_; | 74 ChildController::StartAppCallback on_app_complete_; |
| 73 | 75 |
| 74 // Platform-specific "pipe" to the child process. Valid immediately after | 76 // Platform-specific "pipe" to the child process. Valid immediately after |
| 75 // creation. | 77 // creation. |
| 76 embedder::ScopedPlatformHandle platform_channel_; | 78 embedder::ScopedPlatformHandle platform_channel_; |
| 77 | 79 |
| 78 DISALLOW_COPY_AND_ASSIGN(ChildProcessHost); | 80 DISALLOW_COPY_AND_ASSIGN(ChildProcessHost); |
| 79 }; | 81 }; |
| 80 | 82 |
| 81 } // namespace shell | 83 } // namespace shell |
| 82 } // namespace mojo | 84 } // namespace mojo |
| 83 | 85 |
| 84 #endif // SHELL_CHILD_PROCESS_HOST_H_ | 86 #endif // SHELL_CHILD_PROCESS_HOST_H_ |
| OLD | NEW |