Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: mojo/edk/embedder/platform_channel_pair.h

Issue 1387963004: Create a broker interface for the new Mojo EDK so that the browser can create and duplicate messa... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: presubmit whitespace error Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_PLATFORM_CHANNEL_PAIR_H_ 5 #ifndef MOJO_EDK_EMBEDDER_PLATFORM_CHANNEL_PAIR_H_
6 #define MOJO_EDK_EMBEDDER_PLATFORM_CHANNEL_PAIR_H_ 6 #define MOJO_EDK_EMBEDDER_PLATFORM_CHANNEL_PAIR_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/process/launch.h" 9 #include "base/process/launch.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // Note: |PlatformChannelPair()|, |PassClientHandleFromParentProcess()| and 45 // Note: |PlatformChannelPair()|, |PassClientHandleFromParentProcess()| and
46 // |PrepareToPassClientHandleToChildProcess()| have platform-specific 46 // |PrepareToPassClientHandleToChildProcess()| have platform-specific
47 // implementations. 47 // implementations.
48 // 48 //
49 // Note: On POSIX platforms, to write to the "pipe", use 49 // Note: On POSIX platforms, to write to the "pipe", use
50 // |PlatformChannel{Write,Writev}()| (from platform_channel_utils_posix.h) 50 // |PlatformChannel{Write,Writev}()| (from platform_channel_utils_posix.h)
51 // instead of |write()|, |writev()|, etc. Otherwise, you have to worry about 51 // instead of |write()|, |writev()|, etc. Otherwise, you have to worry about
52 // platform differences in suppressing |SIGPIPE|. 52 // platform differences in suppressing |SIGPIPE|.
53 class MOJO_SYSTEM_IMPL_EXPORT PlatformChannelPair { 53 class MOJO_SYSTEM_IMPL_EXPORT PlatformChannelPair {
54 public: 54 public:
55 PlatformChannelPair(); 55 // If |client_is_blocking| is true, then the client handle only supports
56 // blocking reads and writes. The default is nonblocking.
57 PlatformChannelPair(bool client_is_blocking = false);
56 ~PlatformChannelPair(); 58 ~PlatformChannelPair();
57 59
58 ScopedPlatformHandle PassServerHandle(); 60 ScopedPlatformHandle PassServerHandle();
59 61
60 // For in-process use (e.g., in tests or to pass over another channel). 62 // For in-process use (e.g., in tests or to pass over another channel).
61 ScopedPlatformHandle PassClientHandle(); 63 ScopedPlatformHandle PassClientHandle();
62 64
63 // To be called in the child process, after the parent process called 65 // To be called in the child process, after the parent process called
64 // |PrepareToPassClientHandleToChildProcess()| and launched the child (using 66 // |PrepareToPassClientHandleToChildProcess()| and launched the child (using
65 // the provided data), to create a client handle connected to the server 67 // the provided data), to create a client handle connected to the server
66 // handle (in the parent process). 68 // handle (in the parent process).
67 static ScopedPlatformHandle PassClientHandleFromParentProcess( 69 static ScopedPlatformHandle PassClientHandleFromParentProcess(
68 const base::CommandLine& command_line); 70 const base::CommandLine& command_line);
69 71
72 // Like above, but gets the handle from the passed in string.
73 static ScopedPlatformHandle PassClientHandleFromParentProcessFromString(
74 const std::string& value);
75
70 // Prepares to pass the client channel to a new child process, to be launched 76 // Prepares to pass the client channel to a new child process, to be launched
71 // using |LaunchProcess()| (from base/launch.h). Modifies |*command_line| and 77 // using |LaunchProcess()| (from base/launch.h). Modifies |*command_line| and
72 // |*handle_passing_info| as needed. 78 // |*handle_passing_info| as needed.
73 // Note: For Windows, this method only works on Vista and later. 79 // Note: For Windows, this method only works on Vista and later.
74 void PrepareToPassClientHandleToChildProcess( 80 void PrepareToPassClientHandleToChildProcess(
75 base::CommandLine* command_line, 81 base::CommandLine* command_line,
76 HandlePassingInformation* handle_passing_info) const; 82 HandlePassingInformation* handle_passing_info) const;
77 83
84 // Like above, but returns a string instead of changing the command line.
85 std::string PrepareToPassClientHandleToChildProcessAsString(
86 HandlePassingInformation* handle_passing_info) const;
87
78 // To be called once the child process has been successfully launched, to do 88 // To be called once the child process has been successfully launched, to do
79 // any cleanup necessary. 89 // any cleanup necessary.
80 void ChildProcessLaunched(); 90 void ChildProcessLaunched();
81 91
82 private: 92 private:
83 static const char kMojoPlatformChannelHandleSwitch[]; 93 static const char kMojoPlatformChannelHandleSwitch[];
84 94
85 ScopedPlatformHandle server_handle_; 95 ScopedPlatformHandle server_handle_;
86 ScopedPlatformHandle client_handle_; 96 ScopedPlatformHandle client_handle_;
87 97
88 MOJO_DISALLOW_COPY_AND_ASSIGN(PlatformChannelPair); 98 MOJO_DISALLOW_COPY_AND_ASSIGN(PlatformChannelPair);
89 }; 99 };
90 100
91 } // namespace edk 101 } // namespace edk
92 } // namespace mojo 102 } // namespace mojo
93 103
94 #endif // MOJO_EDK_EMBEDDER_PLATFORM_CHANNEL_PAIR_H_ 104 #endif // MOJO_EDK_EMBEDDER_PLATFORM_CHANNEL_PAIR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698