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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 const IPC::ChannelHandle& channel_handle, | 158 const IPC::ChannelHandle& channel_handle, |
159 Listener* listener); | 159 Listener* listener); |
160 | 160 |
161 ~Channel() override; | 161 ~Channel() override; |
162 | 162 |
163 // Connect the pipe. On the server side, this will initiate | 163 // Connect the pipe. On the server side, this will initiate |
164 // waiting for connections. On the client, it attempts to | 164 // waiting for connections. On the client, it attempts to |
165 // connect to a pre-existing pipe. Note, calling Connect() | 165 // connect to a pre-existing pipe. Note, calling Connect() |
166 // will not block the calling thread and may complete | 166 // will not block the calling thread and may complete |
167 // asynchronously. | 167 // asynchronously. |
| 168 // |
| 169 // The subclass implementation must call WillConnect() at the beginning of its |
| 170 // implementation. |
168 virtual bool Connect() WARN_UNUSED_RESULT = 0; | 171 virtual bool Connect() WARN_UNUSED_RESULT = 0; |
169 | 172 |
170 // Close this Channel explicitly. May be called multiple times. | 173 // Close this Channel explicitly. May be called multiple times. |
171 // On POSIX calling close on an IPC channel that listens for connections will | 174 // On POSIX calling close on an IPC channel that listens for connections will |
172 // cause it to close any accepted connections, and it will stop listening for | 175 // cause it to close any accepted connections, and it will stop listening for |
173 // new connections. If you just want to close the currently accepted | 176 // new connections. If you just want to close the currently accepted |
174 // connection and listen for new ones, use ResetToAcceptingConnectionState. | 177 // connection and listen for new ones, use ResetToAcceptingConnectionState. |
175 virtual void Close() = 0; | 178 virtual void Close() = 0; |
176 | 179 |
177 // Get its own process id. This value is told to the peer. | 180 // Get its own process id. This value is told to the peer. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 ~OutputElement(); | 251 ~OutputElement(); |
249 size_t size() const { return message_ ? message_->size() : length_; } | 252 size_t size() const { return message_ ? message_->size() : length_; } |
250 const void* data() const { return message_ ? message_->data() : buffer_; } | 253 const void* data() const { return message_ ? message_->data() : buffer_; } |
251 Message* get_message() const { return message_.get(); } | 254 Message* get_message() const { return message_.get(); } |
252 | 255 |
253 private: | 256 private: |
254 scoped_ptr<Message> message_; | 257 scoped_ptr<Message> message_; |
255 void* buffer_; | 258 void* buffer_; |
256 size_t length_; | 259 size_t length_; |
257 }; | 260 }; |
| 261 |
| 262 // Endpoint overrides. |
| 263 void OnSetAttachmentBrokerEndpoint() override; |
| 264 |
| 265 // Subclasses must call this method at the beginning of their implementation |
| 266 // of Connect(). |
| 267 void WillConnect(); |
| 268 |
| 269 private: |
| 270 bool did_start_connect_ = false; |
258 }; | 271 }; |
259 | 272 |
260 #if defined(OS_POSIX) | 273 #if defined(OS_POSIX) |
261 // SocketPair() creates a pair of socket FDs suitable for using with | 274 // SocketPair() creates a pair of socket FDs suitable for using with |
262 // IPC::Channel. | 275 // IPC::Channel. |
263 IPC_EXPORT bool SocketPair(int* fd1, int* fd2); | 276 IPC_EXPORT bool SocketPair(int* fd1, int* fd2); |
264 #endif | 277 #endif |
265 | 278 |
266 } // namespace IPC | 279 } // namespace IPC |
267 | 280 |
268 #endif // IPC_IPC_CHANNEL_H_ | 281 #endif // IPC_IPC_CHANNEL_H_ |
OLD | NEW |