OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 IPC_IPC_CHANNEL_H_ | 5 #ifndef IPC_IPC_CHANNEL_H_ |
6 #define IPC_IPC_CHANNEL_H_ | 6 #define IPC_IPC_CHANNEL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #if defined(OS_POSIX) | 10 #if defined(OS_POSIX) |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 AttachmentBroker* broker); | 158 AttachmentBroker* broker); |
159 #endif | 159 #endif |
160 // TODO(erikchen): Remove default parameter for |broker|. It exists only to | 160 // TODO(erikchen): Remove default parameter for |broker|. It exists only to |
161 // make the upcoming refactor decomposable into smaller CLs. | 161 // make the upcoming refactor decomposable into smaller CLs. |
162 // http://crbug.com/493414. | 162 // http://crbug.com/493414. |
163 static scoped_ptr<Channel> CreateServer( | 163 static scoped_ptr<Channel> CreateServer( |
164 const IPC::ChannelHandle& channel_handle, | 164 const IPC::ChannelHandle& channel_handle, |
165 Listener* listener, | 165 Listener* listener, |
166 AttachmentBroker* broker = nullptr); | 166 AttachmentBroker* broker = nullptr); |
167 | 167 |
168 Channel() : attachment_broker_endpoint_(false) {} | |
169 ~Channel() override; | 168 ~Channel() override; |
170 | 169 |
171 // Connect the pipe. On the server side, this will initiate | 170 // Connect the pipe. On the server side, this will initiate |
172 // waiting for connections. On the client, it attempts to | 171 // waiting for connections. On the client, it attempts to |
173 // connect to a pre-existing pipe. Note, calling Connect() | 172 // connect to a pre-existing pipe. Note, calling Connect() |
174 // will not block the calling thread and may complete | 173 // will not block the calling thread and may complete |
175 // asynchronously. | 174 // asynchronously. |
176 virtual bool Connect() WARN_UNUSED_RESULT = 0; | 175 virtual bool Connect() WARN_UNUSED_RESULT = 0; |
177 | 176 |
178 // Close this Channel explicitly. May be called multiple times. | 177 // Close this Channel explicitly. May be called multiple times. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 #endif | 245 #endif |
247 | 246 |
248 #if defined(OS_ANDROID) | 247 #if defined(OS_ANDROID) |
249 // Most tests are single process and work the same on all platforms. However | 248 // Most tests are single process and work the same on all platforms. However |
250 // in some cases we want to test multi-process, and Android differs in that it | 249 // in some cases we want to test multi-process, and Android differs in that it |
251 // can't 'exec' after forking. This callback resets any data in the forked | 250 // can't 'exec' after forking. This callback resets any data in the forked |
252 // process such that it acts similar to if it was exec'd, for tests. | 251 // process such that it acts similar to if it was exec'd, for tests. |
253 static void NotifyProcessForkedForTesting(); | 252 static void NotifyProcessForkedForTesting(); |
254 #endif | 253 #endif |
255 | 254 |
256 void set_attachment_broker_endpoint(bool is_endpoint) { | |
257 attachment_broker_endpoint_ = is_endpoint; | |
258 } | |
259 | |
260 protected: | |
261 bool is_attachment_broker_endpoint() { return attachment_broker_endpoint_; } | |
262 | |
263 private: | |
264 // Whether this channel is used as an endpoint for sending and receiving | |
265 // brokerable attachment messages to/from the broker process. | |
266 bool attachment_broker_endpoint_; | |
267 }; | 255 }; |
268 | 256 |
269 #if defined(OS_POSIX) | 257 #if defined(OS_POSIX) |
270 // SocketPair() creates a pair of socket FDs suitable for using with | 258 // SocketPair() creates a pair of socket FDs suitable for using with |
271 // IPC::Channel. | 259 // IPC::Channel. |
272 IPC_EXPORT bool SocketPair(int* fd1, int* fd2); | 260 IPC_EXPORT bool SocketPair(int* fd1, int* fd2); |
273 #endif | 261 #endif |
274 | 262 |
275 } // namespace IPC | 263 } // namespace IPC |
276 | 264 |
277 #endif // IPC_IPC_CHANNEL_H_ | 265 #endif // IPC_IPC_CHANNEL_H_ |
OLD | NEW |