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_CHILD_PROCESS_HOST_H_ | 5 #ifndef SHELL_CHILD_PROCESS_HOST_H_ |
6 #define MOJO_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_handle.h" | 9 #include "base/process/process_handle.h" |
10 #include "mojo/edk/embedder/platform_channel_pair.h" | 10 #include "mojo/edk/embedder/platform_channel_pair.h" |
11 #include "mojo/edk/embedder/scoped_platform_handle.h" | 11 #include "mojo/edk/embedder/scoped_platform_handle.h" |
12 #include "mojo/shell/child_process.h" // For |ChildProcess::Type|. | 12 #include "shell/child_process.h" // For |ChildProcess::Type|. |
13 | 13 |
14 namespace mojo { | 14 namespace mojo { |
15 namespace shell { | 15 namespace shell { |
16 | 16 |
17 class Context; | 17 class Context; |
18 | 18 |
19 // (Base) class for a "child process host". Handles launching and connecting a | 19 // (Base) class for a "child process host". Handles launching and connecting a |
20 // platform-specific "pipe" to the child, and supports joining the child | 20 // platform-specific "pipe" to the child, and supports joining the child |
21 // process. Intended for use as a base class, but may be used on its own in | 21 // process. Intended for use as a base class, but may be used on its own in |
22 // simple cases. | 22 // simple cases. |
(...skipping 25 matching lines...) Expand all Loading... |
48 // Waits for the child process to terminate, and returns its exit code. | 48 // Waits for the child process to terminate, and returns its exit code. |
49 // Note: If |Start()| has been called, this must not be called until the | 49 // Note: If |Start()| has been called, this must not be called until the |
50 // callback has been called. | 50 // callback has been called. |
51 int Join(); | 51 int Join(); |
52 | 52 |
53 embedder::ScopedPlatformHandle* platform_channel() { | 53 embedder::ScopedPlatformHandle* platform_channel() { |
54 return &platform_channel_; | 54 return &platform_channel_; |
55 } | 55 } |
56 | 56 |
57 protected: | 57 protected: |
58 Context* context() const { | 58 Context* context() const { return context_; } |
59 return context_; | |
60 } | |
61 | 59 |
62 private: | 60 private: |
63 bool DoLaunch(); | 61 bool DoLaunch(); |
64 void DidLaunch(bool success); | 62 void DidLaunch(bool success); |
65 | 63 |
66 Context* const context_; | 64 Context* const context_; |
67 Delegate* const delegate_; | 65 Delegate* const delegate_; |
68 const ChildProcess::Type type_; | 66 const ChildProcess::Type type_; |
69 | 67 |
70 base::ProcessHandle child_process_handle_; | 68 base::ProcessHandle child_process_handle_; |
71 | 69 |
72 embedder::PlatformChannelPair platform_channel_pair_; | 70 embedder::PlatformChannelPair platform_channel_pair_; |
73 | 71 |
74 // Platform-specific "pipe" to the child process. Valid immediately after | 72 // Platform-specific "pipe" to the child process. Valid immediately after |
75 // creation. | 73 // creation. |
76 embedder::ScopedPlatformHandle platform_channel_; | 74 embedder::ScopedPlatformHandle platform_channel_; |
77 | 75 |
78 DISALLOW_COPY_AND_ASSIGN(ChildProcessHost); | 76 DISALLOW_COPY_AND_ASSIGN(ChildProcessHost); |
79 }; | 77 }; |
80 | 78 |
81 } // namespace shell | 79 } // namespace shell |
82 } // namespace mojo | 80 } // namespace mojo |
83 | 81 |
84 #endif // MOJO_SHELL_CHILD_PROCESS_HOST_H_ | 82 #endif // SHELL_CHILD_PROCESS_HOST_H_ |
OLD | NEW |