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

Side by Side Diff: ipc/ipc_channel.h

Issue 1286883003: Revert of IPC: Add attachment brokering support to the message header. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 | « ipc/ipc.gypi ('k') | 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 friend class ChannelTest; 45 friend class ChannelTest;
46 46
47 public: 47 public:
48 // Flags to test modes 48 // Flags to test modes
49 enum ModeFlags { 49 enum ModeFlags {
50 MODE_NO_FLAG = 0x0, 50 MODE_NO_FLAG = 0x0,
51 MODE_SERVER_FLAG = 0x1, 51 MODE_SERVER_FLAG = 0x1,
52 MODE_CLIENT_FLAG = 0x2, 52 MODE_CLIENT_FLAG = 0x2,
53 MODE_NAMED_FLAG = 0x4, 53 MODE_NAMED_FLAG = 0x4,
54 #if defined(OS_POSIX) 54 #if defined(OS_POSIX)
55 MODE_OPEN_ACCESS_FLAG = 0x8, // Don't restrict access based on client UID. 55 MODE_OPEN_ACCESS_FLAG = 0x8, // Don't restrict access based on client UID.
56 #endif 56 #endif
57 }; 57 };
58 58
59 // Some Standard Modes 59 // Some Standard Modes
60 // TODO(morrita): These are under deprecation work. You should use Create*() 60 // TODO(morrita): These are under deprecation work. You should use Create*()
61 // functions instead. 61 // functions instead.
62 enum Mode { 62 enum Mode {
63 MODE_NONE = MODE_NO_FLAG, 63 MODE_NONE = MODE_NO_FLAG,
64 MODE_SERVER = MODE_SERVER_FLAG, 64 MODE_SERVER = MODE_SERVER_FLAG,
65 MODE_CLIENT = MODE_CLIENT_FLAG, 65 MODE_CLIENT = MODE_CLIENT_FLAG,
66 MODE_NAMED_SERVER = MODE_SERVER_FLAG | MODE_NAMED_FLAG, 66 MODE_NAMED_SERVER = MODE_SERVER_FLAG | MODE_NAMED_FLAG,
67 MODE_NAMED_CLIENT = MODE_CLIENT_FLAG | MODE_NAMED_FLAG, 67 MODE_NAMED_CLIENT = MODE_CLIENT_FLAG | MODE_NAMED_FLAG,
68 #if defined(OS_POSIX) 68 #if defined(OS_POSIX)
69 MODE_OPEN_NAMED_SERVER = 69 MODE_OPEN_NAMED_SERVER = MODE_OPEN_ACCESS_FLAG | MODE_SERVER_FLAG |
70 MODE_OPEN_ACCESS_FLAG | MODE_SERVER_FLAG | MODE_NAMED_FLAG 70 MODE_NAMED_FLAG
71 #endif 71 #endif
72 }; 72 };
73 73
74 // Messages internal to the IPC implementation are defined here. 74 // Messages internal to the IPC implementation are defined here.
75 // Uses Maximum value of message type (uint16), to avoid conflicting 75 // Uses Maximum value of message type (uint16), to avoid conflicting
76 // with normal message types, which are enumeration constants starting from 0. 76 // with normal message types, which are enumeration constants starting from 0.
77 enum { 77 enum {
78 // The Hello message is sent by the peer when the channel is connected. 78 // The Hello message is sent by the peer when the channel is connected.
79 // The message contains just the process id (pid). 79 // The message contains just the process id (pid).
80 // The message has a special routing_id (MSG_ROUTING_NONE) 80 // The message has a special routing_id (MSG_ROUTING_NONE)
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // Send a message over the Channel to the listener on the other end. 188 // Send a message over the Channel to the listener on the other end.
189 // 189 //
190 // |message| must be allocated using operator new. This object will be 190 // |message| must be allocated using operator new. This object will be
191 // deleted once the contents of the Message have been sent. 191 // deleted once the contents of the Message have been sent.
192 bool Send(Message* message) override = 0; 192 bool Send(Message* message) override = 0;
193 193
194 // IsSendThreadSafe returns true iff it's safe to call |Send| from non-IO 194 // IsSendThreadSafe returns true iff it's safe to call |Send| from non-IO
195 // threads. This is constant for the lifetime of the |Channel|. 195 // threads. This is constant for the lifetime of the |Channel|.
196 virtual bool IsSendThreadSafe() const; 196 virtual bool IsSendThreadSafe() const;
197 197
198 // NaCl in Non-SFI mode runs on Linux directly, and the following functions 198 // NaCl in Non-SFI mode runs on Linux directly, and the following functions
199 // compiled on Linux are also needed. Please see also comments in 199 // compiled on Linux are also needed. Please see also comments in
200 // components/nacl_nonsfi.gyp for more details. 200 // components/nacl_nonsfi.gyp for more details.
201 #if defined(OS_POSIX) && !defined(OS_NACL_SFI) 201 #if defined(OS_POSIX) && !defined(OS_NACL_SFI)
202 // On POSIX an IPC::Channel wraps a socketpair(), this method returns the 202 // On POSIX an IPC::Channel wraps a socketpair(), this method returns the
203 // FD # for the client end of the socket. 203 // FD # for the client end of the socket.
204 // This method may only be called on the server side of a channel. 204 // This method may only be called on the server side of a channel.
205 // This method can be called on any thread. 205 // This method can be called on any thread.
206 virtual int GetClientFileDescriptor() const = 0; 206 virtual int GetClientFileDescriptor() const = 0;
207 207
208 // Same as GetClientFileDescriptor, but transfers the ownership of the 208 // Same as GetClientFileDescriptor, but transfers the ownership of the
209 // file descriptor to the caller. 209 // file descriptor to the caller.
210 // This method can be called on any thread. 210 // This method can be called on any thread.
(...skipping 22 matching lines...) Expand all
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.
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 };
263 }; 243 };
264 244
265 #if defined(OS_POSIX) 245 #if defined(OS_POSIX)
266 // SocketPair() creates a pair of socket FDs suitable for using with 246 // SocketPair() creates a pair of socket FDs suitable for using with
267 // IPC::Channel. 247 // IPC::Channel.
268 IPC_EXPORT bool SocketPair(int* fd1, int* fd2); 248 IPC_EXPORT bool SocketPair(int* fd1, int* fd2);
269 #endif 249 #endif
270 250
271 } // namespace IPC 251 } // namespace IPC
272 252
273 #endif // IPC_IPC_CHANNEL_H_ 253 #endif // IPC_IPC_CHANNEL_H_
OLDNEW
« no previous file with comments | « ipc/ipc.gypi ('k') | ipc/ipc_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698