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

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

Issue 1352913002: Remove Windows support from the EDK. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 3 months 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
« no previous file with comments | « mojo/edk/embedder/embedder.h ('k') | mojo/edk/embedder/platform_channel_pair_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "mojo/edk/embedder/scoped_platform_handle.h" 10 #include "mojo/edk/embedder/scoped_platform_handle.h"
12 #include "mojo/edk/system/system_impl_export.h" 11 #include "mojo/edk/system/system_impl_export.h"
13 #include "mojo/public/cpp/system/macros.h" 12 #include "mojo/public/cpp/system/macros.h"
14 13
15 namespace base { 14 namespace base {
16 class CommandLine; 15 class CommandLine;
17 } 16 }
18 17
19 namespace mojo { 18 namespace mojo {
20 namespace embedder { 19 namespace embedder {
21 20
22 // It would be nice to refactor base/process/launch.h to have a more platform- 21 // It would be nice to refactor base/process/launch.h to have a more platform-
23 // independent way of representing handles that are passed to child processes. 22 // independent way of representing handles that are passed to child processes.
24 #if defined(OS_WIN)
25 using HandlePassingInformation = base::HandlesToInheritVector;
26 #elif defined(OS_POSIX)
27 using HandlePassingInformation = base::FileHandleMappingVector; 23 using HandlePassingInformation = base::FileHandleMappingVector;
28 #else
29 #error "Unsupported."
30 #endif
31 24
32 // This is used to create a pair of |PlatformHandle|s that are connected by a 25 // This is used to create a pair of |PlatformHandle|s that are connected by a
33 // suitable (platform-specific) bidirectional "pipe" (e.g., socket on POSIX, 26 // suitable (platform-specific) bidirectional "pipe" (e.g., Unix domain socket).
34 // named pipe on Windows). The resulting handles can then be used in the same 27 // The resulting handles can then be used in the same process (e.g., in tests)
35 // process (e.g., in tests) or between processes. (The "server" handle is the 28 // or between processes. (The "server" handle is the one that will be used in
36 // one that will be used in the process that created the pair, whereas the 29 // the process that created the pair, whereas the "client" handle is the one
37 // "client" handle is the one that will be used in a different process.) 30 // that will be used in a different process.)
38 // 31 //
39 // This class provides facilities for passing the client handle to a child 32 // This class provides facilities for passing the client handle to a child
40 // process. The parent should call |PrepareToPassClientHandlelToChildProcess()| 33 // process. The parent should call |PrepareToPassClientHandlelToChildProcess()|
41 // to get the data needed to do this, spawn the child using that data, and then 34 // to get the data needed to do this, spawn the child using that data, and then
42 // call |ChildProcessLaunched()|. Note that on Windows this facility (will) only 35 // call |ChildProcessLaunched()|.
43 // work on Vista and later (TODO(vtl)).
44 // 36 //
45 // Note: |PlatformChannelPair()|, |PassClientHandleFromParentProcess()| and 37 // Note: |PlatformChannelPair()|, |PassClientHandleFromParentProcess()| and
46 // |PrepareToPassClientHandleToChildProcess()| have platform-specific 38 // |PrepareToPassClientHandleToChildProcess()| have platform-specific
47 // implementations. 39 // implementations.
48 // 40 //
49 // Note: On POSIX platforms, to write to the "pipe", use 41 // Note: On POSIX platforms, to write to the "pipe", use
50 // |PlatformChannel{Write,Writev}()| (from platform_channel_utils_posix.h) 42 // |PlatformChannel{Write,Writev}()| (from platform_channel_utils_posix.h)
51 // instead of |write()|, |writev()|, etc. Otherwise, you have to worry about 43 // instead of |write()|, |writev()|, etc. Otherwise, you have to worry about
52 // platform differences in suppressing |SIGPIPE|. 44 // platform differences in suppressing |SIGPIPE|.
53 class MOJO_SYSTEM_IMPL_EXPORT PlatformChannelPair { 45 class MOJO_SYSTEM_IMPL_EXPORT PlatformChannelPair {
54 public: 46 public:
55 PlatformChannelPair(); 47 PlatformChannelPair();
56 ~PlatformChannelPair(); 48 ~PlatformChannelPair();
57 49
58 ScopedPlatformHandle PassServerHandle(); 50 ScopedPlatformHandle PassServerHandle();
59 51
60 // For in-process use (e.g., in tests or to pass over another channel). 52 // For in-process use (e.g., in tests or to pass over another channel).
61 ScopedPlatformHandle PassClientHandle(); 53 ScopedPlatformHandle PassClientHandle();
62 54
63 // To be called in the child process, after the parent process called 55 // To be called in the child process, after the parent process called
64 // |PrepareToPassClientHandleToChildProcess()| and launched the child (using 56 // |PrepareToPassClientHandleToChildProcess()| and launched the child (using
65 // the provided data), to create a client handle connected to the server 57 // the provided data), to create a client handle connected to the server
66 // handle (in the parent process). 58 // handle (in the parent process).
67 static ScopedPlatformHandle PassClientHandleFromParentProcess( 59 static ScopedPlatformHandle PassClientHandleFromParentProcess(
68 const base::CommandLine& command_line); 60 const base::CommandLine& command_line);
69 61
70 // Prepares to pass the client channel to a new child process, to be launched 62 // 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 63 // using |LaunchProcess()| (from base/launch.h). Modifies |*command_line| and
72 // |*handle_passing_info| as needed. 64 // |*handle_passing_info| as needed.
73 // Note: For Windows, this method only works on Vista and later.
74 void PrepareToPassClientHandleToChildProcess( 65 void PrepareToPassClientHandleToChildProcess(
75 base::CommandLine* command_line, 66 base::CommandLine* command_line,
76 HandlePassingInformation* handle_passing_info) const; 67 HandlePassingInformation* handle_passing_info) const;
77 68
78 // To be called once the child process has been successfully launched, to do 69 // To be called once the child process has been successfully launched, to do
79 // any cleanup necessary. 70 // any cleanup necessary.
80 void ChildProcessLaunched(); 71 void ChildProcessLaunched();
81 72
82 private: 73 private:
83 static const char kMojoPlatformChannelHandleSwitch[]; 74 static const char kMojoPlatformChannelHandleSwitch[];
84 75
85 ScopedPlatformHandle server_handle_; 76 ScopedPlatformHandle server_handle_;
86 ScopedPlatformHandle client_handle_; 77 ScopedPlatformHandle client_handle_;
87 78
88 MOJO_DISALLOW_COPY_AND_ASSIGN(PlatformChannelPair); 79 MOJO_DISALLOW_COPY_AND_ASSIGN(PlatformChannelPair);
89 }; 80 };
90 81
91 } // namespace embedder 82 } // namespace embedder
92 } // namespace mojo 83 } // namespace mojo
93 84
94 #endif // MOJO_EDK_EMBEDDER_PLATFORM_CHANNEL_PAIR_H_ 85 #endif // MOJO_EDK_EMBEDDER_PLATFORM_CHANNEL_PAIR_H_
OLDNEW
« no previous file with comments | « mojo/edk/embedder/embedder.h ('k') | mojo/edk/embedder/platform_channel_pair_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698