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_UTILS_H_ | 5 #ifndef IPC_IPC_MESSAGE_UTILS_H_ |
6 #define IPC_IPC_MESSAGE_UTILS_H_ | 6 #define IPC_IPC_MESSAGE_UTILS_H_ |
7 | 7 |
8 #include <limits.h> | 8 #include <limits.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 base::PickleIterator* iter, | 1093 base::PickleIterator* iter, |
1094 param_type* r); | 1094 param_type* r); |
1095 static void Log(const param_type& p, std::string* l); | 1095 static void Log(const param_type& p, std::string* l); |
1096 }; | 1096 }; |
1097 #endif // defined(OS_WIN) | 1097 #endif // defined(OS_WIN) |
1098 | 1098 |
1099 //----------------------------------------------------------------------------- | 1099 //----------------------------------------------------------------------------- |
1100 // Generic message subclasses | 1100 // Generic message subclasses |
1101 | 1101 |
1102 // defined in ipc_logging.cc | 1102 // defined in ipc_logging.cc |
1103 IPC_EXPORT void GenerateLogData(const std::string& channel, | 1103 IPC_EXPORT void GenerateLogData(const Message& message, |
1104 const Message& message, | 1104 LogData* data, |
1105 LogData* data, bool get_params); | 1105 bool get_params); |
1106 | |
1107 | 1106 |
1108 #if defined(IPC_MESSAGE_LOG_ENABLED) | 1107 #if defined(IPC_MESSAGE_LOG_ENABLED) |
1109 inline void AddOutputParamsToLog(const Message* msg, std::string* l) { | 1108 inline void AddOutputParamsToLog(const Message* msg, std::string* l) { |
1110 const std::string& output_params = msg->output_params(); | 1109 const std::string& output_params = msg->output_params(); |
1111 if (!l->empty() && !output_params.empty()) | 1110 if (!l->empty() && !output_params.empty()) |
1112 l->append(", "); | 1111 l->append(", "); |
1113 | 1112 |
1114 l->append(output_params); | 1113 l->append(output_params); |
1115 } | 1114 } |
1116 | 1115 |
1117 template <class ReplyParamType> | 1116 template <class ReplyParamType> |
1118 inline void LogReplyParamsToMessage(const ReplyParamType& reply_params, | 1117 inline void LogReplyParamsToMessage(const ReplyParamType& reply_params, |
1119 const Message* msg) { | 1118 const Message* msg) { |
1120 if (msg->received_time() != 0) { | 1119 if (msg->received_time() != 0) { |
1121 std::string output_params; | 1120 std::string output_params; |
1122 LogParam(reply_params, &output_params); | 1121 LogParam(reply_params, &output_params); |
1123 msg->set_output_params(output_params); | 1122 msg->set_output_params(output_params); |
1124 } | 1123 } |
1125 } | 1124 } |
1126 | 1125 |
1127 inline void ConnectMessageAndReply(const Message* msg, Message* reply) { | 1126 inline void ConnectMessageAndReply(const Message* msg, Message* reply) { |
1128 if (msg->sent_time()) { | 1127 if (msg->sent_time()) { |
1129 // Don't log the sync message after dispatch, as we don't have the | 1128 // Don't log the sync message after dispatch, as we don't have the |
1130 // output parameters at that point. Instead, save its data and log it | 1129 // output parameters at that point. Instead, save its data and log it |
1131 // with the outgoing reply message when it's sent. | 1130 // with the outgoing reply message when it's sent. |
1132 LogData* data = new LogData; | 1131 LogData* data = new LogData; |
1133 GenerateLogData("", *msg, data, true); | 1132 GenerateLogData(*msg, data, true); |
1134 msg->set_dont_log(); | 1133 msg->set_dont_log(); |
1135 reply->set_sync_log_data(data); | 1134 reply->set_sync_log_data(data); |
1136 } | 1135 } |
1137 } | 1136 } |
1138 #else | 1137 #else |
1139 inline void AddOutputParamsToLog(const Message* msg, std::string* l) {} | 1138 inline void AddOutputParamsToLog(const Message* msg, std::string* l) {} |
1140 | 1139 |
1141 template <class ReplyParamType> | 1140 template <class ReplyParamType> |
1142 inline void LogReplyParamsToMessage(const ReplyParamType& reply_params, | 1141 inline void LogReplyParamsToMessage(const ReplyParamType& reply_params, |
1143 const Message* msg) {} | 1142 const Message* msg) {} |
1144 | 1143 |
1145 inline void ConnectMessageAndReply(const Message* msg, Message* reply) {} | 1144 inline void ConnectMessageAndReply(const Message* msg, Message* reply) {} |
1146 #endif | 1145 #endif |
1147 | 1146 |
1148 } // namespace IPC | 1147 } // namespace IPC |
1149 | 1148 |
1150 #endif // IPC_IPC_MESSAGE_UTILS_H_ | 1149 #endif // IPC_IPC_MESSAGE_UTILS_H_ |
OLD | NEW |