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

Side by Side Diff: ipc/ipc_channel.h

Issue 1309003003: ipc: Add the inner class OutputElement to Channel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ipc_add_header3
Patch Set: Fix typo. 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 | « no previous file | ipc/ipc_channel.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 (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
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. |buffer| is freed via free(), so it
252 // must be malloced.
253 OutputElement(void* buffer, size_t length);
254 ~OutputElement();
255 size_t size() const { return message_ ? message_->size() : length_; }
256 const void* data() const { return message_ ? message_->data() : buffer_; }
257 const Message* get_message() const { return message_.get(); }
258
259 private:
260 scoped_ptr<const Message> message_;
261 void* buffer_;
262 size_t length_;
263 };
243 }; 264 };
244 265
245 #if defined(OS_POSIX) 266 #if defined(OS_POSIX)
246 // SocketPair() creates a pair of socket FDs suitable for using with 267 // SocketPair() creates a pair of socket FDs suitable for using with
247 // IPC::Channel. 268 // IPC::Channel.
248 IPC_EXPORT bool SocketPair(int* fd1, int* fd2); 269 IPC_EXPORT bool SocketPair(int* fd1, int* fd2);
249 #endif 270 #endif
250 271
251 } // namespace IPC 272 } // namespace IPC
252 273
253 #endif // IPC_IPC_CHANNEL_H_ 274 #endif // IPC_IPC_CHANNEL_H_
OLDNEW
« no previous file with comments | « no previous file | ipc/ipc_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698