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