OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 typedef unsigned long long param_type; | 234 typedef unsigned long long param_type; |
235 static void Write(Message* m, const param_type& p) { | 235 static void Write(Message* m, const param_type& p) { |
236 m->WriteInt64(p); | 236 m->WriteInt64(p); |
237 } | 237 } |
238 static bool Read(const Message* m, void** iter, param_type* r) { | 238 static bool Read(const Message* m, void** iter, param_type* r) { |
239 return m->ReadInt64(iter, reinterpret_cast<int64*>(r)); | 239 return m->ReadInt64(iter, reinterpret_cast<int64*>(r)); |
240 } | 240 } |
241 static void Log(const param_type& p, std::string* l); | 241 static void Log(const param_type& p, std::string* l); |
242 }; | 242 }; |
243 | 243 |
| 244 template <> |
| 245 struct ParamTraits<unsigned short> { |
| 246 typedef unsigned short param_type; |
| 247 static void Write(Message* m, const param_type& p); |
| 248 static bool Read(const Message* m, void** iter, param_type* r); |
| 249 static void Log(const param_type& p, std::string* l); |
| 250 }; |
| 251 |
244 // Note that the IPC layer doesn't sanitize NaNs and +/- INF values. Clients | 252 // Note that the IPC layer doesn't sanitize NaNs and +/- INF values. Clients |
245 // should be sure to check the sanity of these values after receiving them over | 253 // should be sure to check the sanity of these values after receiving them over |
246 // IPC. | 254 // IPC. |
247 template <> | 255 template <> |
248 struct ParamTraits<float> { | 256 struct ParamTraits<float> { |
249 typedef float param_type; | 257 typedef float param_type; |
250 static void Write(Message* m, const param_type& p) { | 258 static void Write(Message* m, const param_type& p) { |
251 m->WriteData(reinterpret_cast<const char*>(&p), sizeof(param_type)); | 259 m->WriteData(reinterpret_cast<const char*>(&p), sizeof(param_type)); |
252 } | 260 } |
253 static bool Read(const Message* m, void** iter, param_type* r) { | 261 static bool Read(const Message* m, void** iter, param_type* r) { |
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 ReplyParam p(a, b, c, d, e); | 1199 ReplyParam p(a, b, c, d, e); |
1192 WriteParam(reply, p); | 1200 WriteParam(reply, p); |
1193 } | 1201 } |
1194 }; | 1202 }; |
1195 | 1203 |
1196 //----------------------------------------------------------------------------- | 1204 //----------------------------------------------------------------------------- |
1197 | 1205 |
1198 } // namespace IPC | 1206 } // namespace IPC |
1199 | 1207 |
1200 #endif // IPC_IPC_MESSAGE_UTILS_H_ | 1208 #endif // IPC_IPC_MESSAGE_UTILS_H_ |
OLD | NEW |