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_MESSAGE_H_ | 5 #ifndef IPC_IPC_MESSAGE_H_ |
6 #define IPC_IPC_MESSAGE_H_ | 6 #define IPC_IPC_MESSAGE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/pickle.h" | 15 #include "base/pickle.h" |
16 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "ipc/ipc_export.h" | 18 #include "ipc/ipc_export.h" |
19 #include "ipc/ipc_features.h" | 19 |
| 20 #if !defined(NDEBUG) |
| 21 #define IPC_MESSAGE_LOG_ENABLED |
| 22 #endif |
20 | 23 |
21 namespace IPC { | 24 namespace IPC { |
22 | 25 |
23 namespace internal { | 26 namespace internal { |
24 class ChannelReader; | 27 class ChannelReader; |
25 } // namespace internal | 28 } // namespace internal |
26 | 29 |
27 //------------------------------------------------------------------------------ | 30 //------------------------------------------------------------------------------ |
28 | 31 |
29 struct LogData; | 32 struct LogData; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 bool WriteAttachment( | 200 bool WriteAttachment( |
198 scoped_refptr<base::Pickle::Attachment> attachment) override; | 201 scoped_refptr<base::Pickle::Attachment> attachment) override; |
199 // ReadAttachment parses an attachment given the parsing state |iter| and | 202 // ReadAttachment parses an attachment given the parsing state |iter| and |
200 // writes it to |*attachment|. It returns true on success. | 203 // writes it to |*attachment|. It returns true on success. |
201 bool ReadAttachment( | 204 bool ReadAttachment( |
202 base::PickleIterator* iter, | 205 base::PickleIterator* iter, |
203 scoped_refptr<base::Pickle::Attachment>* attachment) const override; | 206 scoped_refptr<base::Pickle::Attachment>* attachment) const override; |
204 // Returns true if there are any attachment in this message. | 207 // Returns true if there are any attachment in this message. |
205 bool HasAttachments() const override; | 208 bool HasAttachments() const override; |
206 | 209 |
207 #if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) | 210 #ifdef IPC_MESSAGE_LOG_ENABLED |
208 // Adds the outgoing time from Time::Now() at the end of the message and sets | 211 // Adds the outgoing time from Time::Now() at the end of the message and sets |
209 // a bit to indicate that it's been added. | 212 // a bit to indicate that it's been added. |
210 void set_sent_time(int64_t time); | 213 void set_sent_time(int64_t time); |
211 int64_t sent_time() const; | 214 int64_t sent_time() const; |
212 | 215 |
213 void set_received_time(int64_t time) const; | 216 void set_received_time(int64_t time) const; |
214 int64_t received_time() const { return received_time_; } | 217 int64_t received_time() const { return received_time_; } |
215 void set_output_params(const std::string& op) const { output_params_ = op; } | 218 void set_output_params(const std::string& op) const { output_params_ = op; } |
216 const std::string& output_params() const { return output_params_; } | 219 const std::string& output_params() const { return output_params_; } |
217 // The following four functions are needed so we can log sync messages with | 220 // The following four functions are needed so we can log sync messages with |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 void EnsureMessageAttachmentSet(); | 268 void EnsureMessageAttachmentSet(); |
266 | 269 |
267 MessageAttachmentSet* attachment_set() { | 270 MessageAttachmentSet* attachment_set() { |
268 EnsureMessageAttachmentSet(); | 271 EnsureMessageAttachmentSet(); |
269 return attachment_set_.get(); | 272 return attachment_set_.get(); |
270 } | 273 } |
271 const MessageAttachmentSet* attachment_set() const { | 274 const MessageAttachmentSet* attachment_set() const { |
272 return attachment_set_.get(); | 275 return attachment_set_.get(); |
273 } | 276 } |
274 | 277 |
275 #if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) | 278 #ifdef IPC_MESSAGE_LOG_ENABLED |
276 // Used for logging. | 279 // Used for logging. |
277 mutable int64_t received_time_; | 280 mutable int64_t received_time_; |
278 mutable std::string output_params_; | 281 mutable std::string output_params_; |
279 mutable LogData* log_data_; | 282 mutable LogData* log_data_; |
280 mutable bool dont_log_; | 283 mutable bool dont_log_; |
281 #endif | 284 #endif |
282 | 285 |
283 FRIEND_TEST_ALL_PREFIXES(IPCMessageTest, FindNext); | 286 FRIEND_TEST_ALL_PREFIXES(IPCMessageTest, FindNext); |
284 FRIEND_TEST_ALL_PREFIXES(IPCMessageTest, FindNextOverflow); | 287 FRIEND_TEST_ALL_PREFIXES(IPCMessageTest, FindNextOverflow); |
285 }; | 288 }; |
286 | 289 |
287 //------------------------------------------------------------------------------ | 290 //------------------------------------------------------------------------------ |
288 | 291 |
289 } // namespace IPC | 292 } // namespace IPC |
290 | 293 |
291 enum SpecialRoutingIDs { | 294 enum SpecialRoutingIDs { |
292 // indicates that we don't have a routing ID yet. | 295 // indicates that we don't have a routing ID yet. |
293 MSG_ROUTING_NONE = -2, | 296 MSG_ROUTING_NONE = -2, |
294 | 297 |
295 // indicates a general message not sent to a particular tab. | 298 // indicates a general message not sent to a particular tab. |
296 MSG_ROUTING_CONTROL = INT32_MAX, | 299 MSG_ROUTING_CONTROL = INT32_MAX, |
297 }; | 300 }; |
298 | 301 |
299 #define IPC_REPLY_ID 0xFFFFFFF0 // Special message id for replies | 302 #define IPC_REPLY_ID 0xFFFFFFF0 // Special message id for replies |
300 #define IPC_LOGGING_ID 0xFFFFFFF1 // Special message id for logging | 303 #define IPC_LOGGING_ID 0xFFFFFFF1 // Special message id for logging |
301 | 304 |
302 #endif // IPC_IPC_MESSAGE_H_ | 305 #endif // IPC_IPC_MESSAGE_H_ |
OLD | NEW |