| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MOJO_EDK_EMBEDDER_NAMED_PLATFORM_CHANNEL_PAIR_H_ | |
| 6 #define MOJO_EDK_EMBEDDER_NAMED_PLATFORM_CHANNEL_PAIR_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "base/strings/string16.h" | |
| 12 #include "build/build_config.h" | |
| 13 #include "mojo/edk/embedder/scoped_platform_handle.h" | |
| 14 #include "mojo/edk/system/system_impl_export.h" | |
| 15 | |
| 16 namespace base { | |
| 17 class CommandLine; | |
| 18 } | |
| 19 | |
| 20 namespace mojo { | |
| 21 namespace edk { | |
| 22 | |
| 23 // This is used to create a named bidirectional pipe to connect new child | |
| 24 // processes. The resulting server handle should be passed to the EDK, and the | |
| 25 // child end passed as a pipe name on the command line to the child process. The | |
| 26 // child process can then retrieve the pipe name from the command line and | |
| 27 // resolve it into a client handle. | |
| 28 class MOJO_SYSTEM_IMPL_EXPORT NamedPlatformChannelPair { | |
| 29 public: | |
| 30 NamedPlatformChannelPair(); | |
| 31 ~NamedPlatformChannelPair(); | |
| 32 | |
| 33 // Note: It is NOT acceptable to use this handle as a generic pipe channel. It | |
| 34 // MUST be passed to mojo::edk::ChildProcessLaunched() only. | |
| 35 ScopedPlatformHandle PassServerHandle(); | |
| 36 | |
| 37 // To be called in the child process, after the parent process called | |
| 38 // |PrepareToPassClientHandleToChildProcess()| and launched the child (using | |
| 39 // the provided data), to create a client handle connected to the server | |
| 40 // handle (in the parent process). | |
| 41 static ScopedPlatformHandle PassClientHandleFromParentProcess( | |
| 42 const base::CommandLine& command_line); | |
| 43 | |
| 44 // Prepares to pass the client channel to a new child process, to be launched | |
| 45 // using |LaunchProcess()| (from base/launch.h). Modifies |*command_line| and | |
| 46 // |*handle_passing_info| as needed. | |
| 47 // Note: For Windows, this method only works on Vista and later. | |
| 48 void PrepareToPassClientHandleToChildProcess( | |
| 49 base::CommandLine* command_line) const; | |
| 50 | |
| 51 private: | |
| 52 ScopedPlatformHandle server_handle_; | |
| 53 | |
| 54 #if defined(OS_WIN) | |
| 55 base::string16 pipe_name_; | |
| 56 #endif | |
| 57 | |
| 58 DISALLOW_COPY_AND_ASSIGN(NamedPlatformChannelPair); | |
| 59 }; | |
| 60 | |
| 61 } // namespace edk | |
| 62 } // namespace mojo | |
| 63 | |
| 64 #endif // MOJO_EDK_EMBEDDER_NAMED_PLATFORM_CHANNEL_PAIR_H_ | |
| OLD | NEW |