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 <algorithm> | 8 #include <algorithm> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 m->WriteString(p); | 244 m->WriteString(p); |
245 } | 245 } |
246 static bool Read(const Message* m, PickleIterator* iter, | 246 static bool Read(const Message* m, PickleIterator* iter, |
247 param_type* r) { | 247 param_type* r) { |
248 return iter->ReadString(r); | 248 return iter->ReadString(r); |
249 } | 249 } |
250 IPC_EXPORT static void Log(const param_type& p, std::string* l); | 250 IPC_EXPORT static void Log(const param_type& p, std::string* l); |
251 }; | 251 }; |
252 | 252 |
253 template <> | 253 template <> |
254 struct ParamTraits<std::wstring> { | |
255 typedef std::wstring param_type; | |
256 static void Write(Message* m, const param_type& p) { | |
257 m->WriteWString(p); | |
258 } | |
259 static bool Read(const Message* m, PickleIterator* iter, | |
260 param_type* r) { | |
261 return iter->ReadWString(r); | |
262 } | |
263 IPC_EXPORT static void Log(const param_type& p, std::string* l); | |
264 }; | |
265 | |
266 // If WCHAR_T_IS_UTF16 is defined, then string16 is a std::wstring so we don't | |
267 // need this trait. | |
268 #if !defined(WCHAR_T_IS_UTF16) | |
269 template <> | |
270 struct ParamTraits<base::string16> { | 254 struct ParamTraits<base::string16> { |
271 typedef base::string16 param_type; | 255 typedef base::string16 param_type; |
272 static void Write(Message* m, const param_type& p) { | 256 static void Write(Message* m, const param_type& p) { |
273 m->WriteString16(p); | 257 m->WriteString16(p); |
274 } | 258 } |
275 static bool Read(const Message* m, PickleIterator* iter, | 259 static bool Read(const Message* m, PickleIterator* iter, |
276 param_type* r) { | 260 param_type* r) { |
277 return iter->ReadString16(r); | 261 return iter->ReadString16(r); |
278 } | 262 } |
279 IPC_EXPORT static void Log(const param_type& p, std::string* l); | 263 IPC_EXPORT static void Log(const param_type& p, std::string* l); |
280 }; | 264 }; |
281 #endif | |
282 | 265 |
283 template <> | 266 template <> |
284 struct IPC_EXPORT ParamTraits<std::vector<char> > { | 267 struct IPC_EXPORT ParamTraits<std::vector<char> > { |
285 typedef std::vector<char> param_type; | 268 typedef std::vector<char> param_type; |
286 static void Write(Message* m, const param_type& p); | 269 static void Write(Message* m, const param_type& p); |
287 static bool Read(const Message*, PickleIterator* iter, param_type* r); | 270 static bool Read(const Message*, PickleIterator* iter, param_type* r); |
288 static void Log(const param_type& p, std::string* l); | 271 static void Log(const param_type& p, std::string* l); |
289 }; | 272 }; |
290 | 273 |
291 template <> | 274 template <> |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
950 template<typename TA, typename TB, typename TC, typename TD, typename TE> | 933 template<typename TA, typename TB, typename TC, typename TD, typename TE> |
951 static void WriteReplyParams(Message* reply, TA a, TB b, TC c, TD d, TE e) { | 934 static void WriteReplyParams(Message* reply, TA a, TB b, TC c, TD d, TE e) { |
952 ReplyParam p(a, b, c, d, e); | 935 ReplyParam p(a, b, c, d, e); |
953 WriteParam(reply, p); | 936 WriteParam(reply, p); |
954 } | 937 } |
955 }; | 938 }; |
956 | 939 |
957 } // namespace IPC | 940 } // namespace IPC |
958 | 941 |
959 #endif // IPC_IPC_MESSAGE_UTILS_H_ | 942 #endif // IPC_IPC_MESSAGE_UTILS_H_ |
OLD | NEW |