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_EDK_EMBEDDER_EMBEDDER_H_ | 5 #ifndef MOJO_EDK_EMBEDDER_EMBEDDER_H_ |
6 #define MOJO_EDK_EMBEDDER_EMBEDDER_H_ | 6 #define MOJO_EDK_EMBEDDER_EMBEDDER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/command_line.h" | |
Anand Mistry (off Chromium)
2016/01/28 02:26:24
You don't use base::CommandLine anywhere in this f
| |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
15 #include "base/process/process_handle.h" | 16 #include "base/process/process_handle.h" |
16 #include "base/task_runner.h" | 17 #include "base/task_runner.h" |
17 #include "mojo/edk/embedder/scoped_platform_handle.h" | 18 #include "mojo/edk/embedder/scoped_platform_handle.h" |
18 #include "mojo/edk/system/system_impl_export.h" | 19 #include "mojo/edk/system/system_impl_export.h" |
19 #include "mojo/public/cpp/system/message_pipe.h" | 20 #include "mojo/public/cpp/system/message_pipe.h" |
20 | 21 |
21 namespace mojo { | 22 namespace mojo { |
22 namespace edk { | 23 namespace edk { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 // called on the I/O thread (given to |InitIPCSupport()|). This completes | 111 // called on the I/O thread (given to |InitIPCSupport()|). This completes |
111 // synchronously and does not result in a call to the process delegate's | 112 // synchronously and does not result in a call to the process delegate's |
112 // |OnShutdownComplete()|. | 113 // |OnShutdownComplete()|. |
113 MOJO_SYSTEM_IMPL_EXPORT void ShutdownIPCSupportOnIOThread(); | 114 MOJO_SYSTEM_IMPL_EXPORT void ShutdownIPCSupportOnIOThread(); |
114 | 115 |
115 // Like |ShutdownIPCSupportOnIOThread()|, but may be called from any thread, | 116 // Like |ShutdownIPCSupportOnIOThread()|, but may be called from any thread, |
116 // signalling shutdown completion via the process delegate's | 117 // signalling shutdown completion via the process delegate's |
117 // |OnShutdownComplete()|. | 118 // |OnShutdownComplete()|. |
118 MOJO_SYSTEM_IMPL_EXPORT void ShutdownIPCSupport(); | 119 MOJO_SYSTEM_IMPL_EXPORT void ShutdownIPCSupport(); |
119 | 120 |
120 // Creates a message pipe from a platform handle. Safe to call from any thread. | 121 // Unused. Crashes. Only here for linking. |
121 MOJO_SYSTEM_IMPL_EXPORT ScopedMessagePipeHandle | 122 MOJO_SYSTEM_IMPL_EXPORT ScopedMessagePipeHandle |
122 CreateMessagePipe(ScopedPlatformHandle platform_handle); | 123 CreateMessagePipe(ScopedPlatformHandle platform_handle); |
123 | 124 |
125 // Creates a message pipe over an arbitrary platform channel. In order for this | |
126 // to work properly each end of the channel must be passed to this function: one | |
127 // end in a parent process and one end in a child process. In a child process, | |
128 // either PreInitializeChildProcess() or SetParentPipe() must have been been | |
129 // called at least once already. | |
130 // | |
131 // Note: This only exists for backwards compatibility with embedders that rely | |
132 // on mojo::embedder::CreateChannel() behavior. If you have a means of passing | |
133 // platform handles around, you can probably also pass strings around. If you | |
134 // can pass strings around, use CreateParentMessagePipe() and | |
135 // CreateChlidMessagePipe() instead (see below.) | |
136 // | |
137 // |callback| must be safe to call from any thread. | |
138 MOJO_SYSTEM_IMPL_EXPORT void | |
139 CreateMessagePipe( | |
140 ScopedPlatformHandle platform_handle, | |
141 const base::Callback<void(ScopedMessagePipeHandle)>& callback); | |
142 | |
143 // Creates a message pipe from a token. A child embedder must also have this | |
144 // token and call CreateChildMessagePipe() with it in order for the pipe to get | |
145 // connected. | |
146 // | |
147 // |callback| must be safe to call from any thread. | |
148 MOJO_SYSTEM_IMPL_EXPORT void | |
149 CreateParentMessagePipe( | |
150 const std::string& token, | |
151 const base::Callback<void(ScopedMessagePipeHandle)>& callback); | |
152 | |
153 // Creates a message pipe from a token in a child process. The parent must also | |
154 // have this token and call CreateParentMessagePipe() with it in order for the | |
155 // pipe to get connected. | |
156 // | |
157 // |callback| must be safe to call from any thread. | |
158 MOJO_SYSTEM_IMPL_EXPORT void | |
159 CreateChildMessagePipe( | |
160 const std::string& token, | |
161 const base::Callback<void(ScopedMessagePipeHandle)>& callback); | |
162 | |
163 // Generates a random ASCII token string for use with CreateParentMessagePipe() | |
164 // and CreateChildMessagePipe() above. The generated token is suitably random so | |
165 // as to not have to worry about collisions with other generated tokens. | |
166 MOJO_SYSTEM_IMPL_EXPORT std::string GenerateRandomToken(); | |
167 | |
124 } // namespace edk | 168 } // namespace edk |
125 } // namespace mojo | 169 } // namespace mojo |
126 | 170 |
127 #endif // MOJO_EDK_EMBEDDER_EMBEDDER_H_ | 171 #endif // MOJO_EDK_EMBEDDER_EMBEDDER_H_ |
OLD | NEW |