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

Side by Side Diff: ipc/ipc_message.h

Issue 883093003: IPC::Message Refactoring: Move POSIX specific bits to PlatformFileAttachment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing Windows build error Created 5 years, 10 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_channel_posix.cc ('k') | ipc/ipc_message.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_MESSAGE_H_ 5 #ifndef IPC_IPC_MESSAGE_H_
6 #define IPC_IPC_MESSAGE_H_ 6 #define IPC_IPC_MESSAGE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/files/file.h" 11 #include "base/debug/trace_event.h"
12 #include "base/memory/ref_counted.h"
12 #include "base/pickle.h" 13 #include "base/pickle.h"
13 #include "base/trace_event/trace_event.h" 14 #include "base/trace_event/trace_event.h"
14 #include "ipc/ipc_export.h" 15 #include "ipc/ipc_export.h"
15 16
16 #if !defined(NDEBUG) 17 #if !defined(NDEBUG)
17 #define IPC_MESSAGE_LOG_ENABLED 18 #define IPC_MESSAGE_LOG_ENABLED
18 #endif 19 #endif
19 20
20 #if defined(OS_POSIX)
21 #include "base/memory/ref_counted.h"
22 #endif
23
24 namespace IPC { 21 namespace IPC {
25 22
26 //------------------------------------------------------------------------------ 23 //------------------------------------------------------------------------------
27 24
28 struct LogData; 25 struct LogData;
26 class MessageAttachment;
29 class MessageAttachmentSet; 27 class MessageAttachmentSet;
30 28
31 class IPC_EXPORT Message : public Pickle { 29 class IPC_EXPORT Message : public Pickle {
32 public: 30 public:
33 enum PriorityValue { 31 enum PriorityValue {
34 PRIORITY_LOW = 1, 32 PRIORITY_LOW = 1,
35 PRIORITY_NORMAL, 33 PRIORITY_NORMAL,
36 PRIORITY_HIGH 34 PRIORITY_HIGH
37 }; 35 };
38 36
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // Used for async messages with no parameters. 160 // Used for async messages with no parameters.
163 static void Log(std::string* name, const Message* msg, std::string* l) { 161 static void Log(std::string* name, const Message* msg, std::string* l) {
164 } 162 }
165 163
166 // Find the end of the message data that starts at range_start. Returns NULL 164 // Find the end of the message data that starts at range_start. Returns NULL
167 // if the entire message is not found in the given data range. 165 // if the entire message is not found in the given data range.
168 static const char* FindNext(const char* range_start, const char* range_end) { 166 static const char* FindNext(const char* range_start, const char* range_end) {
169 return Pickle::FindNext(sizeof(Header), range_start, range_end); 167 return Pickle::FindNext(sizeof(Header), range_start, range_end);
170 } 168 }
171 169
172 #if defined(OS_POSIX) 170 // WriteAttachment appends |attachment| to the end of the set. It returns
173 // On POSIX, a message supports reading / writing FileDescriptor objects. 171 // false iff the set is full.
174 // This is used to pass a file descriptor to the peer of an IPC channel. 172 bool WriteAttachment(scoped_refptr<MessageAttachment> attachment);
175 173 // ReadAttachment parses an attachment given the parsing state |iter| and
176 // Add a descriptor to the end of the set. Returns false if the set is full. 174 // writes it to |*attachment|. It returns true on success.
177 bool WriteFile(base::ScopedFD descriptor); 175 bool ReadAttachment(PickleIterator* iter,
178 bool WriteBorrowingFile(const base::PlatformFile& descriptor); 176 scoped_refptr<MessageAttachment>* attachment) const;
179 177 // Returns true if there are any attachment in this message.
180 // Get a file descriptor from the message. Returns false on error. 178 bool HasAttachments() const;
181 // iter: a Pickle iterator to the current location in the message.
182 bool ReadFile(PickleIterator* iter, base::ScopedFD* file) const;
183
184 // Returns true if there are any file descriptors in this message.
185 bool HasFileDescriptors() const;
186 #endif
187 179
188 #ifdef IPC_MESSAGE_LOG_ENABLED 180 #ifdef IPC_MESSAGE_LOG_ENABLED
189 // Adds the outgoing time from Time::Now() at the end of the message and sets 181 // Adds the outgoing time from Time::Now() at the end of the message and sets
190 // a bit to indicate that it's been added. 182 // a bit to indicate that it's been added.
191 void set_sent_time(int64 time); 183 void set_sent_time(int64 time);
192 int64 sent_time() const; 184 int64 sent_time() const;
193 185
194 void set_received_time(int64 time) const; 186 void set_received_time(int64 time) const;
195 int64 received_time() const { return received_time_; } 187 int64 received_time() const { return received_time_; }
196 void set_output_params(const std::string& op) const { output_params_ = op; } 188 void set_output_params(const std::string& op) const { output_params_ = op; }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 MSG_ROUTING_NONE = -2, 273 MSG_ROUTING_NONE = -2,
282 274
283 // indicates a general message not sent to a particular tab. 275 // indicates a general message not sent to a particular tab.
284 MSG_ROUTING_CONTROL = kint32max, 276 MSG_ROUTING_CONTROL = kint32max,
285 }; 277 };
286 278
287 #define IPC_REPLY_ID 0xFFFFFFF0 // Special message id for replies 279 #define IPC_REPLY_ID 0xFFFFFFF0 // Special message id for replies
288 #define IPC_LOGGING_ID 0xFFFFFFF1 // Special message id for logging 280 #define IPC_LOGGING_ID 0xFFFFFFF1 // Special message id for logging
289 281
290 #endif // IPC_IPC_MESSAGE_H_ 282 #endif // IPC_IPC_MESSAGE_H_
OLDNEW
« no previous file with comments | « ipc/ipc_channel_posix.cc ('k') | ipc/ipc_message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698