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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 // details. | 221 // details. |
222 virtual void Flush(); | 222 virtual void Flush(); |
223 | 223 |
224 // Close this Channel explicitly. May be called multiple times. | 224 // Close this Channel explicitly. May be called multiple times. |
225 // On POSIX calling close on an IPC channel that listens for connections will | 225 // On POSIX calling close on an IPC channel that listens for connections will |
226 // cause it to close any accepted connections, and it will stop listening for | 226 // cause it to close any accepted connections, and it will stop listening for |
227 // new connections. If you just want to close the currently accepted | 227 // new connections. If you just want to close the currently accepted |
228 // connection and listen for new ones, use ResetToAcceptingConnectionState. | 228 // connection and listen for new ones, use ResetToAcceptingConnectionState. |
229 virtual void Close() = 0; | 229 virtual void Close() = 0; |
230 | 230 |
231 // Get its own process id. This value is told to the peer. | |
232 virtual base::ProcessId GetSelfPID() const = 0; | |
233 | |
234 // Gets a helper for associating Mojo interfaces with this Channel. | 231 // Gets a helper for associating Mojo interfaces with this Channel. |
235 // | 232 // |
236 // NOTE: Not all implementations support this. | 233 // NOTE: Not all implementations support this. |
237 virtual AssociatedInterfaceSupport* GetAssociatedInterfaceSupport(); | 234 virtual AssociatedInterfaceSupport* GetAssociatedInterfaceSupport(); |
238 | 235 |
239 // Overridden from ipc::Sender. | 236 // Overridden from ipc::Sender. |
240 // Send a message over the Channel to the listener on the other end. | 237 // Send a message over the Channel to the listener on the other end. |
241 // | 238 // |
242 // |message| must be allocated using operator new. This object will be | 239 // |message| must be allocated using operator new. This object will be |
243 // deleted once the contents of the Message have been sent. | 240 // deleted once the contents of the Message have been sent. |
244 bool Send(Message* message) override = 0; | 241 bool Send(Message* message) override = 0; |
245 | 242 |
246 // NaCl in Non-SFI mode runs on Linux directly, and the following functions | |
247 // compiled on Linux are also needed. Please see also comments in | |
248 // components/nacl_nonsfi.gyp for more details. | |
249 #if defined(OS_POSIX) && !defined(OS_NACL_SFI) | |
250 // On POSIX an IPC::Channel wraps a socketpair(), this method returns the | |
251 // FD # for the client end of the socket. | |
252 // This method may only be called on the server side of a channel. | |
253 // This method can be called on any thread. | |
254 virtual int GetClientFileDescriptor() const = 0; | |
255 | |
256 // Same as GetClientFileDescriptor, but transfers the ownership of the | |
257 // file descriptor to the caller. | |
258 // This method can be called on any thread. | |
259 virtual base::ScopedFD TakeClientFileDescriptor() = 0; | |
260 #endif | |
261 | |
262 #if !defined(OS_NACL_SFI) | 243 #if !defined(OS_NACL_SFI) |
263 // Generates a channel ID that's non-predictable and unique. | 244 // Generates a channel ID that's non-predictable and unique. |
264 static std::string GenerateUniqueRandomChannelID(); | 245 static std::string GenerateUniqueRandomChannelID(); |
265 | |
266 // Generates a channel ID that, if passed to the client as a shared secret, | |
Tom Sepez
2016/11/09 00:31:00
This was used to avoid a fairly serious bug where
Sam McNally
2016/11/09 05:06:30
In most cases, pipe names aren't used: for normal
| |
267 // will validate that the client's authenticity. On platforms that do not | |
268 // require additional this is simply calls GenerateUniqueRandomChannelID(). | |
269 // For portability the prefix should not include the \ character. | |
270 static std::string GenerateVerifiedChannelID(const std::string& prefix); | |
271 #endif | 246 #endif |
272 | 247 |
273 // Deprecated: Create a mojo::MessagePipe directly and release() its handles | 248 // Deprecated: Create a mojo::MessagePipe directly and release() its handles |
274 // instead. | 249 // instead. |
275 // | 250 // |
276 // Generates a pair of channel handles that can be used as the client and | 251 // Generates a pair of channel handles that can be used as the client and |
277 // server ends of a ChannelMojo. |name_postfix| is ignored. | 252 // server ends of a ChannelMojo. |name_postfix| is ignored. |
278 static void GenerateMojoChannelHandlePair( | 253 static void GenerateMojoChannelHandlePair( |
279 const std::string& name_postfix, | 254 const std::string& name_postfix, |
280 IPC::ChannelHandle* handle0, | 255 IPC::ChannelHandle* handle0, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 // of Connect(). | 291 // of Connect(). |
317 void WillConnect(); | 292 void WillConnect(); |
318 | 293 |
319 private: | 294 private: |
320 bool did_start_connect_ = false; | 295 bool did_start_connect_ = false; |
321 }; | 296 }; |
322 | 297 |
323 } // namespace IPC | 298 } // namespace IPC |
324 | 299 |
325 #endif // IPC_IPC_CHANNEL_H_ | 300 #endif // IPC_IPC_CHANNEL_H_ |
OLD | NEW |