| 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_SYSTEM_EMBEDDER_PLATFORM_CHANNEL_PAIR_H_ | 5 #ifndef MOJO_SYSTEM_EMBEDDER_PLATFORM_CHANNEL_PAIR_H_ |
| 6 #define MOJO_SYSTEM_EMBEDDER_PLATFORM_CHANNEL_PAIR_H_ | 6 #define MOJO_SYSTEM_EMBEDDER_PLATFORM_CHANNEL_PAIR_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/process/launch.h" | 10 #include "base/process/launch.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "mojo/system/embedder/scoped_platform_handle.h" | 12 #include "mojo/system/embedder/scoped_platform_handle.h" |
| 13 #include "mojo/system/system_impl_export.h" | 13 #include "mojo/system/system_impl_export.h" |
| 14 | 14 |
| 15 namespace base { |
| 15 class CommandLine; | 16 class CommandLine; |
| 17 } |
| 16 | 18 |
| 17 namespace mojo { | 19 namespace mojo { |
| 18 namespace embedder { | 20 namespace embedder { |
| 19 | 21 |
| 20 // It would be nice to refactor base/process/launch.h to have a more platform- | 22 // It would be nice to refactor base/process/launch.h to have a more platform- |
| 21 // independent way of representing handles that are passed to child processes. | 23 // independent way of representing handles that are passed to child processes. |
| 22 #if defined(OS_WIN) | 24 #if defined(OS_WIN) |
| 23 typedef base::HandlesToInheritVector HandlePassingInformation; | 25 typedef base::HandlesToInheritVector HandlePassingInformation; |
| 24 #elif defined(OS_POSIX) | 26 #elif defined(OS_POSIX) |
| 25 typedef base::FileHandleMappingVector HandlePassingInformation; | 27 typedef base::FileHandleMappingVector HandlePassingInformation; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 51 ScopedPlatformHandle PassServerHandle(); | 53 ScopedPlatformHandle PassServerHandle(); |
| 52 | 54 |
| 53 // For in-process use (e.g., in tests or to pass over another channel). | 55 // For in-process use (e.g., in tests or to pass over another channel). |
| 54 ScopedPlatformHandle PassClientHandle(); | 56 ScopedPlatformHandle PassClientHandle(); |
| 55 | 57 |
| 56 // To be called in the child process, after the parent process called | 58 // To be called in the child process, after the parent process called |
| 57 // |PrepareToPassClientHandleToChildProcess()| and launched the child (using | 59 // |PrepareToPassClientHandleToChildProcess()| and launched the child (using |
| 58 // the provided data), to create a client handle connected to the server | 60 // the provided data), to create a client handle connected to the server |
| 59 // handle (in the parent process). | 61 // handle (in the parent process). |
| 60 static ScopedPlatformHandle PassClientHandleFromParentProcess( | 62 static ScopedPlatformHandle PassClientHandleFromParentProcess( |
| 61 const CommandLine& command_line); | 63 const base::CommandLine& command_line); |
| 62 | 64 |
| 63 // Prepares to pass the client channel to a new child process, to be launched | 65 // Prepares to pass the client channel to a new child process, to be launched |
| 64 // using |LaunchProcess()| (from base/launch.h). Modifies |*command_line| and | 66 // using |LaunchProcess()| (from base/launch.h). Modifies |*command_line| and |
| 65 // |*handle_passing_info| as needed. | 67 // |*handle_passing_info| as needed. |
| 66 // Note: For Windows, this method only works on Vista and later. | 68 // Note: For Windows, this method only works on Vista and later. |
| 67 void PrepareToPassClientHandleToChildProcess( | 69 void PrepareToPassClientHandleToChildProcess( |
| 68 CommandLine* command_line, | 70 base::CommandLine* command_line, |
| 69 HandlePassingInformation* handle_passing_info) const; | 71 HandlePassingInformation* handle_passing_info) const; |
| 70 | 72 |
| 71 // To be called once the child process has been successfully launched, to do | 73 // To be called once the child process has been successfully launched, to do |
| 72 // any cleanup necessary. | 74 // any cleanup necessary. |
| 73 void ChildProcessLaunched(); | 75 void ChildProcessLaunched(); |
| 74 | 76 |
| 75 private: | 77 private: |
| 76 static const char kMojoPlatformChannelHandleSwitch[]; | 78 static const char kMojoPlatformChannelHandleSwitch[]; |
| 77 | 79 |
| 78 ScopedPlatformHandle server_handle_; | 80 ScopedPlatformHandle server_handle_; |
| 79 ScopedPlatformHandle client_handle_; | 81 ScopedPlatformHandle client_handle_; |
| 80 | 82 |
| 81 DISALLOW_COPY_AND_ASSIGN(PlatformChannelPair); | 83 DISALLOW_COPY_AND_ASSIGN(PlatformChannelPair); |
| 82 }; | 84 }; |
| 83 | 85 |
| 84 } // namespace embedder | 86 } // namespace embedder |
| 85 } // namespace mojo | 87 } // namespace mojo |
| 86 | 88 |
| 87 #endif // MOJO_SYSTEM_EMBEDDER_PLATFORM_CHANNEL_PAIR_H_ | 89 #endif // MOJO_SYSTEM_EMBEDDER_PLATFORM_CHANNEL_PAIR_H_ |
| OLD | NEW |