Chromium Code Reviews| 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 static void SetGlobalPid(int pid); | 233 static void SetGlobalPid(int pid); |
| 234 #endif | 234 #endif |
| 235 | 235 |
| 236 #if defined(OS_ANDROID) | 236 #if defined(OS_ANDROID) |
| 237 // Most tests are single process and work the same on all platforms. However | 237 // Most tests are single process and work the same on all platforms. However |
| 238 // in some cases we want to test multi-process, and Android differs in that it | 238 // in some cases we want to test multi-process, and Android differs in that it |
| 239 // can't 'exec' after forking. This callback resets any data in the forked | 239 // can't 'exec' after forking. This callback resets any data in the forked |
| 240 // process such that it acts similar to if it was exec'd, for tests. | 240 // process such that it acts similar to if it was exec'd, for tests. |
| 241 static void NotifyProcessForkedForTesting(); | 241 static void NotifyProcessForkedForTesting(); |
| 242 #endif | 242 #endif |
| 243 | |
| 244 protected: | |
| 245 // An OutputElement is a wrapper around a Message or raw buffer while it is | |
| 246 // waiting to be passed to the system's underlying IPC mechanism. | |
| 247 class OutputElement { | |
| 248 public: | |
| 249 // Takes ownership of message. | |
| 250 OutputElement(Message* message); | |
| 251 // Takes ownership of the buffer. | |
|
Tom Sepez
2015/09/10 15:41:05
add note: buffer is free via system free, must be
erikchen
2015/09/10 18:43:59
Done.
| |
| 252 OutputElement(void* buffer, size_t length); | |
| 253 ~OutputElement(); | |
| 254 size_t size() const; | |
| 255 const void* data() const; | |
| 256 const Message* get_message() const { return message_.get(); } | |
| 257 | |
| 258 private: | |
| 259 scoped_ptr<const Message> message_; | |
| 260 void* buffer_; | |
| 261 size_t length_; | |
| 262 }; | |
| 243 }; | 263 }; |
| 244 | 264 |
| 245 #if defined(OS_POSIX) | 265 #if defined(OS_POSIX) |
| 246 // SocketPair() creates a pair of socket FDs suitable for using with | 266 // SocketPair() creates a pair of socket FDs suitable for using with |
| 247 // IPC::Channel. | 267 // IPC::Channel. |
| 248 IPC_EXPORT bool SocketPair(int* fd1, int* fd2); | 268 IPC_EXPORT bool SocketPair(int* fd1, int* fd2); |
| 249 #endif | 269 #endif |
| 250 | 270 |
| 251 } // namespace IPC | 271 } // namespace IPC |
| 252 | 272 |
| 253 #endif // IPC_IPC_CHANNEL_H_ | 273 #endif // IPC_IPC_CHANNEL_H_ |
| OLD | NEW |