| 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> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 // Basic configuration/initialization ------------------------------------------ | 27 // Basic configuration/initialization ------------------------------------------ |
| 28 | 28 |
| 29 // |Init()| sets up the basic Mojo system environment, making the |Mojo...()| | 29 // |Init()| sets up the basic Mojo system environment, making the |Mojo...()| |
| 30 // functions available and functional. This is never shut down (except in tests | 30 // functions available and functional. This is never shut down (except in tests |
| 31 // -- see test_embedder.h). | 31 // -- see test_embedder.h). |
| 32 | 32 |
| 33 // Allows changing the default max message size. Must be called before Init. | 33 // Allows changing the default max message size. Must be called before Init. |
| 34 MOJO_SYSTEM_IMPL_EXPORT void SetMaxMessageSize(size_t bytes); | 34 MOJO_SYSTEM_IMPL_EXPORT void SetMaxMessageSize(size_t bytes); |
| 35 | 35 |
| 36 // Must be called before Init in the parent (unsandboxed) process. | |
| 37 MOJO_SYSTEM_IMPL_EXPORT void PreInitializeParentProcess(); | |
| 38 | |
| 39 // Must be called before Init in the child (sandboxed) process. | |
| 40 MOJO_SYSTEM_IMPL_EXPORT void PreInitializeChildProcess(); | |
| 41 | |
| 42 // Called in the parent process for each child process that is launched. The | 36 // Called in the parent process for each child process that is launched. The |
| 43 // returned handle must be sent to the child process which then calls | 37 // returned handle must be sent to the child process which then calls |
| 44 // SetParentPipeHandle. | 38 // SetParentPipeHandle. |
| 45 MOJO_SYSTEM_IMPL_EXPORT ScopedPlatformHandle ChildProcessLaunched( | 39 MOJO_SYSTEM_IMPL_EXPORT ScopedPlatformHandle ChildProcessLaunched( |
| 46 base::ProcessHandle child_process); | 40 base::ProcessHandle child_process); |
| 47 // Like above, except used when the embedder establishes the pipe between the | 41 // Like above, except used when the embedder establishes the pipe between the |
| 48 // parent and child processes itself. | 42 // parent and child processes itself. |
| 49 MOJO_SYSTEM_IMPL_EXPORT void ChildProcessLaunched( | 43 MOJO_SYSTEM_IMPL_EXPORT void ChildProcessLaunched( |
| 50 base::ProcessHandle child_process, ScopedPlatformHandle server_pipe); | 44 base::ProcessHandle child_process, ScopedPlatformHandle server_pipe); |
| 51 | 45 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // Like |ShutdownIPCSupportOnIOThread()|, but may be called from any thread, | 110 // Like |ShutdownIPCSupportOnIOThread()|, but may be called from any thread, |
| 117 // signalling shutdown completion via the process delegate's | 111 // signalling shutdown completion via the process delegate's |
| 118 // |OnShutdownComplete()|. | 112 // |OnShutdownComplete()|. |
| 119 MOJO_SYSTEM_IMPL_EXPORT void ShutdownIPCSupport(); | 113 MOJO_SYSTEM_IMPL_EXPORT void ShutdownIPCSupport(); |
| 120 | 114 |
| 121 // Unused. Crashes. Only here for linking. | 115 // Unused. Crashes. Only here for linking. |
| 122 MOJO_SYSTEM_IMPL_EXPORT ScopedMessagePipeHandle | 116 MOJO_SYSTEM_IMPL_EXPORT ScopedMessagePipeHandle |
| 123 CreateMessagePipe(ScopedPlatformHandle platform_handle); | 117 CreateMessagePipe(ScopedPlatformHandle platform_handle); |
| 124 | 118 |
| 125 // Creates a message pipe over an arbitrary platform channel. In order for this | 119 // 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 | 120 // to work properly each end of the channel must be passed to this function. |
| 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. | 121 // |callback| must be safe to call from any thread. |
| 138 MOJO_SYSTEM_IMPL_EXPORT void | 122 MOJO_SYSTEM_IMPL_EXPORT void |
| 139 CreateMessagePipe( | 123 CreateMessagePipe( |
| 140 ScopedPlatformHandle platform_handle, | 124 ScopedPlatformHandle platform_handle, |
| 141 const base::Callback<void(ScopedMessagePipeHandle)>& callback); | 125 const base::Callback<void(ScopedMessagePipeHandle)>& callback); |
| 142 | 126 |
| 143 // Creates a message pipe from a token. A child embedder must also have this | 127 // 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 | 128 // token and call CreateChildMessagePipe() with it in order for the pipe to get |
| 145 // connected. | 129 // connected. |
| 146 // | 130 // |
| (...skipping 15 matching lines...) Expand all Loading... |
| 162 | 146 |
| 163 // Generates a random ASCII token string for use with CreateParentMessagePipe() | 147 // Generates a random ASCII token string for use with CreateParentMessagePipe() |
| 164 // and CreateChildMessagePipe() above. The generated token is suitably random so | 148 // and CreateChildMessagePipe() above. The generated token is suitably random so |
| 165 // as to not have to worry about collisions with other generated tokens. | 149 // as to not have to worry about collisions with other generated tokens. |
| 166 MOJO_SYSTEM_IMPL_EXPORT std::string GenerateRandomToken(); | 150 MOJO_SYSTEM_IMPL_EXPORT std::string GenerateRandomToken(); |
| 167 | 151 |
| 168 } // namespace edk | 152 } // namespace edk |
| 169 } // namespace mojo | 153 } // namespace mojo |
| 170 | 154 |
| 171 #endif // MOJO_EDK_EMBEDDER_EMBEDDER_H_ | 155 #endif // MOJO_EDK_EMBEDDER_EMBEDDER_H_ |
| OLD | NEW |