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

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: 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
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/debug/trace_event.h" 11 #include "base/debug/trace_event.h"
12 #include "base/files/file.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/pickle.h" 13 #include "base/pickle.h"
14 #include "ipc/ipc_export.h" 14 #include "ipc/ipc_export.h"
15 15
16 #if !defined(NDEBUG) 16 #if !defined(NDEBUG)
17 #define IPC_MESSAGE_LOG_ENABLED 17 #define IPC_MESSAGE_LOG_ENABLED
18 #endif 18 #endif
19 19
20 #if defined(OS_POSIX)
21 #include "base/memory/ref_counted.h"
22 #endif
23
24 namespace IPC { 20 namespace IPC {
25 21
26 //------------------------------------------------------------------------------ 22 //------------------------------------------------------------------------------
27 23
28 struct LogData; 24 struct LogData;
25 class MessageAttachment;
29 class MessageAttachmentSet; 26 class MessageAttachmentSet;
30 27
31 class IPC_EXPORT Message : public Pickle { 28 class IPC_EXPORT Message : public Pickle {
32 public: 29 public:
33 enum PriorityValue { 30 enum PriorityValue {
34 PRIORITY_LOW = 1, 31 PRIORITY_LOW = 1,
35 PRIORITY_NORMAL, 32 PRIORITY_NORMAL,
36 PRIORITY_HIGH 33 PRIORITY_HIGH
37 }; 34 };
38 35
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // Used for async messages with no parameters. 159 // Used for async messages with no parameters.
163 static void Log(std::string* name, const Message* msg, std::string* l) { 160 static void Log(std::string* name, const Message* msg, std::string* l) {
164 } 161 }
165 162
166 // Find the end of the message data that starts at range_start. Returns NULL 163 // 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. 164 // 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) { 165 static const char* FindNext(const char* range_start, const char* range_end) {
169 return Pickle::FindNext(sizeof(Header), range_start, range_end); 166 return Pickle::FindNext(sizeof(Header), range_start, range_end);
170 } 167 }
171 168
172 #if defined(OS_POSIX) 169 bool WriteAttachment(scoped_refptr<MessageAttachment> attachment);
agl 2015/01/30 19:34:02 comments for these? // WriteAttachment appends |a
Hajime Morrita 2015/01/30 21:01:29 Thank you for the suggestion! Adopted.
173 // On POSIX, a message supports reading / writing FileDescriptor objects. 170 bool ReadAttachment(PickleIterator* iter,
agl 2015/01/30 19:34:02 // ReadAttachment parses an attachment given the p
Hajime Morrita 2015/01/30 21:01:29 Done.
174 // This is used to pass a file descriptor to the peer of an IPC channel. 171 scoped_refptr<MessageAttachment>* attachment) const;
175 172 // Returns true if there are any attachment in this message.
176 // Add a descriptor to the end of the set. Returns false if the set is full. 173 bool HasAttachments() const;
177 bool WriteFile(base::ScopedFD descriptor);
178 bool WriteBorrowingFile(const base::PlatformFile& descriptor);
179
180 // Get a file descriptor from the message. Returns false on error.
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 174
188 #ifdef IPC_MESSAGE_LOG_ENABLED 175 #ifdef IPC_MESSAGE_LOG_ENABLED
189 // Adds the outgoing time from Time::Now() at the end of the message and sets 176 // 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. 177 // a bit to indicate that it's been added.
191 void set_sent_time(int64 time); 178 void set_sent_time(int64 time);
192 int64 sent_time() const; 179 int64 sent_time() const;
193 180
194 void set_received_time(int64 time) const; 181 void set_received_time(int64 time) const;
195 int64 received_time() const { return received_time_; } 182 int64 received_time() const { return received_time_; }
196 void set_output_params(const std::string& op) const { output_params_ = op; } 183 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, 268 MSG_ROUTING_NONE = -2,
282 269
283 // indicates a general message not sent to a particular tab. 270 // indicates a general message not sent to a particular tab.
284 MSG_ROUTING_CONTROL = kint32max, 271 MSG_ROUTING_CONTROL = kint32max,
285 }; 272 };
286 273
287 #define IPC_REPLY_ID 0xFFFFFFF0 // Special message id for replies 274 #define IPC_REPLY_ID 0xFFFFFFF0 // Special message id for replies
288 #define IPC_LOGGING_ID 0xFFFFFFF1 // Special message id for logging 275 #define IPC_LOGGING_ID 0xFFFFFFF1 // Special message id for logging
289 276
290 #endif // IPC_IPC_MESSAGE_H_ 277 #endif // IPC_IPC_MESSAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698