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 <stdint.h> |
| 9 |
8 #include <algorithm> | 10 #include <algorithm> |
9 #include <map> | 11 #include <map> |
10 #include <set> | 12 #include <set> |
11 #include <string> | 13 #include <string> |
12 #include <vector> | 14 #include <vector> |
13 | 15 |
14 #include "base/containers/small_map.h" | 16 #include "base/containers/small_map.h" |
15 #include "base/containers/stack_container.h" | 17 #include "base/containers/stack_container.h" |
16 #include "base/files/file.h" | 18 #include "base/files/file.h" |
17 #include "base/format_macros.h" | 19 #include "base/format_macros.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 71 |
70 struct ChannelHandle; | 72 struct ChannelHandle; |
71 | 73 |
72 // ----------------------------------------------------------------------------- | 74 // ----------------------------------------------------------------------------- |
73 // How we send IPC message logs across channels. | 75 // How we send IPC message logs across channels. |
74 struct IPC_EXPORT LogData { | 76 struct IPC_EXPORT LogData { |
75 LogData(); | 77 LogData(); |
76 ~LogData(); | 78 ~LogData(); |
77 | 79 |
78 std::string channel; | 80 std::string channel; |
79 int32 routing_id; | 81 int32_t routing_id; |
80 uint32 type; // "User-defined" message type, from ipc_message.h. | 82 uint32_t type; // "User-defined" message type, from ipc_message.h. |
81 std::string flags; | 83 std::string flags; |
82 int64 sent; // Time that the message was sent (i.e. at Send()). | 84 int64_t sent; // Time that the message was sent (i.e. at Send()). |
83 int64 receive; // Time before it was dispatched (i.e. before calling | 85 int64_t receive; // Time before it was dispatched (i.e. before calling |
84 // OnMessageReceived). | 86 // OnMessageReceived). |
85 int64 dispatch; // Time after it was dispatched (i.e. after calling | 87 int64_t dispatch; // Time after it was dispatched (i.e. after calling |
86 // OnMessageReceived). | 88 // OnMessageReceived). |
87 std::string message_name; | 89 std::string message_name; |
88 std::string params; | 90 std::string params; |
89 }; | 91 }; |
90 | 92 |
91 //----------------------------------------------------------------------------- | 93 //----------------------------------------------------------------------------- |
92 | 94 |
93 // A dummy struct to place first just to allow leading commas for all | 95 // A dummy struct to place first just to allow leading commas for all |
94 // members in the macro-generated constructor initializer lists. | 96 // members in the macro-generated constructor initializer lists. |
95 struct NoParams { | 97 struct NoParams { |
96 }; | 98 }; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 param_type* r) { | 203 param_type* r) { |
202 return iter->ReadLong(reinterpret_cast<long*>(r)); | 204 return iter->ReadLong(reinterpret_cast<long*>(r)); |
203 } | 205 } |
204 IPC_EXPORT static void Log(const param_type& p, std::string* l); | 206 IPC_EXPORT static void Log(const param_type& p, std::string* l); |
205 }; | 207 }; |
206 | 208 |
207 template <> | 209 template <> |
208 struct ParamTraits<long long> { | 210 struct ParamTraits<long long> { |
209 typedef long long param_type; | 211 typedef long long param_type; |
210 static void Write(Message* m, const param_type& p) { | 212 static void Write(Message* m, const param_type& p) { |
211 m->WriteInt64(static_cast<int64>(p)); | 213 m->WriteInt64(static_cast<int64_t>(p)); |
212 } | 214 } |
213 static bool Read(const Message* m, | 215 static bool Read(const Message* m, |
214 base::PickleIterator* iter, | 216 base::PickleIterator* iter, |
215 param_type* r) { | 217 param_type* r) { |
216 return iter->ReadInt64(reinterpret_cast<int64*>(r)); | 218 return iter->ReadInt64(reinterpret_cast<int64_t*>(r)); |
217 } | 219 } |
218 IPC_EXPORT static void Log(const param_type& p, std::string* l); | 220 IPC_EXPORT static void Log(const param_type& p, std::string* l); |
219 }; | 221 }; |
220 | 222 |
221 template <> | 223 template <> |
222 struct ParamTraits<unsigned long long> { | 224 struct ParamTraits<unsigned long long> { |
223 typedef unsigned long long param_type; | 225 typedef unsigned long long param_type; |
224 static void Write(Message* m, const param_type& p) { | 226 static void Write(Message* m, const param_type& p) { |
225 m->WriteInt64(p); | 227 m->WriteInt64(p); |
226 } | 228 } |
227 static bool Read(const Message* m, | 229 static bool Read(const Message* m, |
228 base::PickleIterator* iter, | 230 base::PickleIterator* iter, |
229 param_type* r) { | 231 param_type* r) { |
230 return iter->ReadInt64(reinterpret_cast<int64*>(r)); | 232 return iter->ReadInt64(reinterpret_cast<int64_t*>(r)); |
231 } | 233 } |
232 IPC_EXPORT static void Log(const param_type& p, std::string* l); | 234 IPC_EXPORT static void Log(const param_type& p, std::string* l); |
233 }; | 235 }; |
234 | 236 |
235 // Note that the IPC layer doesn't sanitize NaNs and +/- INF values. Clients | 237 // Note that the IPC layer doesn't sanitize NaNs and +/- INF values. Clients |
236 // should be sure to check the sanity of these values after receiving them over | 238 // should be sure to check the sanity of these values after receiving them over |
237 // IPC. | 239 // IPC. |
238 template <> | 240 template <> |
239 struct IPC_EXPORT ParamTraits<float> { | 241 struct IPC_EXPORT ParamTraits<float> { |
240 typedef float param_type; | 242 typedef float param_type; |
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 template <typename... Ts> | 1058 template <typename... Ts> |
1057 static void WriteReplyParams(Message* reply, Ts... args) { | 1059 static void WriteReplyParams(Message* reply, Ts... args) { |
1058 ReplyParam p(args...); | 1060 ReplyParam p(args...); |
1059 WriteParam(reply, p); | 1061 WriteParam(reply, p); |
1060 } | 1062 } |
1061 }; | 1063 }; |
1062 | 1064 |
1063 } // namespace IPC | 1065 } // namespace IPC |
1064 | 1066 |
1065 #endif // IPC_IPC_MESSAGE_UTILS_H_ | 1067 #endif // IPC_IPC_MESSAGE_UTILS_H_ |
OLD | NEW |