| 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 <memory> | 10 #include <memory> |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 // |Init()| sets up the basic Mojo system environment, making the |Mojo...()| | 34 // |Init()| sets up the basic Mojo system environment, making the |Mojo...()| |
| 35 // functions available and functional. This is never shut down (except in tests | 35 // functions available and functional. This is never shut down (except in tests |
| 36 // -- see test_embedder.h). | 36 // -- see test_embedder.h). |
| 37 | 37 |
| 38 // Allows changing the default max message size. Must be called before Init. | 38 // Allows changing the default max message size. Must be called before Init. |
| 39 MOJO_SYSTEM_IMPL_EXPORT void SetMaxMessageSize(size_t bytes); | 39 MOJO_SYSTEM_IMPL_EXPORT void SetMaxMessageSize(size_t bytes); |
| 40 | 40 |
| 41 // Called in the parent process for each child process that is launched. | 41 // Called in the parent process for each child process that is launched. |
| 42 MOJO_SYSTEM_IMPL_EXPORT void ChildProcessLaunched( | 42 MOJO_SYSTEM_IMPL_EXPORT void ChildProcessLaunched( |
| 43 base::ProcessHandle child_process, ScopedPlatformHandle server_pipe); | 43 base::ProcessHandle child_process, |
| 44 ScopedPlatformHandle server_pipe, |
| 45 const std::string& child_token); |
| 46 |
| 47 // Called in the parent process when a child process fails to launch. |
| 48 // Exactly one of ChildProcessLaunched() or ChildProcessLaunchFailed() must be |
| 49 // called per child process launch attempt. |
| 50 MOJO_SYSTEM_IMPL_EXPORT void ChildProcessLaunchFailed( |
| 51 const std::string& child_token); |
| 44 | 52 |
| 45 // Should be called as early as possible in the child process with the handle | 53 // Should be called as early as possible in the child process with the handle |
| 46 // that the parent received from ChildProcessLaunched. | 54 // that the parent received from ChildProcessLaunched. |
| 47 MOJO_SYSTEM_IMPL_EXPORT void SetParentPipeHandle(ScopedPlatformHandle pipe); | 55 MOJO_SYSTEM_IMPL_EXPORT void SetParentPipeHandle(ScopedPlatformHandle pipe); |
| 48 | 56 |
| 49 // Same as above but extracts the pipe handle from the command line. See | 57 // Same as above but extracts the pipe handle from the command line. See |
| 50 // PlatformChannelPair for details. | 58 // PlatformChannelPair for details. |
| 51 MOJO_SYSTEM_IMPL_EXPORT void SetParentPipeHandleFromCommandLine(); | 59 MOJO_SYSTEM_IMPL_EXPORT void SetParentPipeHandleFromCommandLine(); |
| 52 | 60 |
| 53 // Must be called first, or just after setting configuration parameters, to | 61 // Must be called first, or just after setting configuration parameters, to |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 // the channel must also be passed to this function. Either endpoint can be in | 151 // the channel must also be passed to this function. Either endpoint can be in |
| 144 // any process. | 152 // any process. |
| 145 // | 153 // |
| 146 // Note that the channel is only used to negotiate pipe connection, not as the | 154 // Note that the channel is only used to negotiate pipe connection, not as the |
| 147 // transport for messages on the pipe. | 155 // transport for messages on the pipe. |
| 148 MOJO_SYSTEM_IMPL_EXPORT ScopedMessagePipeHandle | 156 MOJO_SYSTEM_IMPL_EXPORT ScopedMessagePipeHandle |
| 149 CreateMessagePipe(ScopedPlatformHandle platform_handle); | 157 CreateMessagePipe(ScopedPlatformHandle platform_handle); |
| 150 | 158 |
| 151 // Creates a message pipe from a token. A child embedder must also have this | 159 // Creates a message pipe from a token. A child embedder must also have this |
| 152 // token and call CreateChildMessagePipe() with it in order for the pipe to get | 160 // token and call CreateChildMessagePipe() with it in order for the pipe to get |
| 153 // connected. | 161 // connected. |child_token| identifies the child process and should be the same |
| 162 // as the token passed into ChildProcessLaunched(). If they are different, the |
| 163 // returned message pipe will not be signaled of peer closure if the child |
| 164 // process dies before establishing connection to the pipe. |
| 154 MOJO_SYSTEM_IMPL_EXPORT ScopedMessagePipeHandle | 165 MOJO_SYSTEM_IMPL_EXPORT ScopedMessagePipeHandle |
| 155 CreateParentMessagePipe(const std::string& token); | 166 CreateParentMessagePipe(const std::string& token, |
| 167 const std::string& child_token); |
| 156 | 168 |
| 157 // Creates a message pipe from a token in a child process. The parent must also | 169 // Creates a message pipe from a token in a child process. The parent must also |
| 158 // have this token and call CreateParentMessagePipe() with it in order for the | 170 // have this token and call CreateParentMessagePipe() with it in order for the |
| 159 // pipe to get connected. | 171 // pipe to get connected. |
| 160 MOJO_SYSTEM_IMPL_EXPORT ScopedMessagePipeHandle | 172 MOJO_SYSTEM_IMPL_EXPORT ScopedMessagePipeHandle |
| 161 CreateChildMessagePipe(const std::string& token); | 173 CreateChildMessagePipe(const std::string& token); |
| 162 | 174 |
| 163 // Generates a random ASCII token string for use with CreateParentMessagePipe() | 175 // Generates a random ASCII token string for use with CreateParentMessagePipe() |
| 164 // and CreateChildMessagePipe() above. The generated token is suitably random so | 176 // and CreateChildMessagePipe() above. The generated token is suitably random so |
| 165 // as to not have to worry about collisions with other generated tokens. | 177 // as to not have to worry about collisions with other generated tokens. |
| 166 MOJO_SYSTEM_IMPL_EXPORT std::string GenerateRandomToken(); | 178 MOJO_SYSTEM_IMPL_EXPORT std::string GenerateRandomToken(); |
| 167 | 179 |
| 168 } // namespace edk | 180 } // namespace edk |
| 169 } // namespace mojo | 181 } // namespace mojo |
| 170 | 182 |
| 171 #endif // MOJO_EDK_EMBEDDER_EMBEDDER_H_ | 183 #endif // MOJO_EDK_EMBEDDER_EMBEDDER_H_ |
| OLD | NEW |