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