| 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 #include <map> | 12 #include <map> |
| 13 #include <set> | 13 #include <set> |
| 14 | 14 |
| 15 #include "base/file_path.h" | 15 #include "base/file_path.h" |
| 16 #include "base/format_macros.h" | 16 #include "base/format_macros.h" |
| 17 #include "base/nullable_string16.h" | 17 #include "base/nullable_string16.h" |
| 18 #include "base/string16.h" | 18 #include "base/string16.h" |
| 19 #include "base/string_number_conversions.h" |
| 19 #include "base/string_util.h" | 20 #include "base/string_util.h" |
| 20 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
| 21 #include "base/time.h" | 22 #include "base/time.h" |
| 22 #include "base/tuple.h" | 23 #include "base/tuple.h" |
| 23 #include "base/values.h" | 24 #include "base/values.h" |
| 24 #if defined(OS_POSIX) | 25 #if defined(OS_POSIX) |
| 25 #include "ipc/file_descriptor_set_posix.h" | 26 #include "ipc/file_descriptor_set_posix.h" |
| 26 #endif | 27 #endif |
| 27 #include "ipc/ipc_channel_handle.h" | 28 #include "ipc/ipc_channel_handle.h" |
| 28 #include "ipc/ipc_sync_message.h" | 29 #include "ipc/ipc_sync_message.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 template <> | 203 template <> |
| 203 struct ParamTraits<long long> { | 204 struct ParamTraits<long long> { |
| 204 typedef long long param_type; | 205 typedef long long param_type; |
| 205 static void Write(Message* m, const param_type& p) { | 206 static void Write(Message* m, const param_type& p) { |
| 206 m->WriteInt64(static_cast<int64>(p)); | 207 m->WriteInt64(static_cast<int64>(p)); |
| 207 } | 208 } |
| 208 static bool Read(const Message* m, void** iter, param_type* r) { | 209 static bool Read(const Message* m, void** iter, param_type* r) { |
| 209 return m->ReadInt64(iter, reinterpret_cast<int64*>(r)); | 210 return m->ReadInt64(iter, reinterpret_cast<int64*>(r)); |
| 210 } | 211 } |
| 211 static void Log(const param_type& p, std::wstring* l) { | 212 static void Log(const param_type& p, std::wstring* l) { |
| 212 l->append(Int64ToWString(static_cast<int64>(p))); | 213 l->append(UTF8ToWide(base::Int64ToString(static_cast<int64>(p)))); |
| 213 } | 214 } |
| 214 }; | 215 }; |
| 215 | 216 |
| 216 template <> | 217 template <> |
| 217 struct ParamTraits<unsigned long long> { | 218 struct ParamTraits<unsigned long long> { |
| 218 typedef unsigned long long param_type; | 219 typedef unsigned long long param_type; |
| 219 static void Write(Message* m, const param_type& p) { | 220 static void Write(Message* m, const param_type& p) { |
| 220 m->WriteInt64(p); | 221 m->WriteInt64(p); |
| 221 } | 222 } |
| 222 static bool Read(const Message* m, void** iter, param_type* r) { | 223 static bool Read(const Message* m, void** iter, param_type* r) { |
| 223 return m->ReadInt64(iter, reinterpret_cast<int64*>(r)); | 224 return m->ReadInt64(iter, reinterpret_cast<int64*>(r)); |
| 224 } | 225 } |
| 225 static void Log(const param_type& p, std::wstring* l) { | 226 static void Log(const param_type& p, std::wstring* l) { |
| 226 l->append(Uint64ToWString(p)); | 227 l->append(UTF8ToWide(base::Uint64ToString(p))); |
| 227 } | 228 } |
| 228 }; | 229 }; |
| 229 | 230 |
| 230 // Note that the IPC layer doesn't sanitize NaNs and +/- INF values. Clients | 231 // Note that the IPC layer doesn't sanitize NaNs and +/- INF values. Clients |
| 231 // should be sure to check the sanity of these values after receiving them over | 232 // should be sure to check the sanity of these values after receiving them over |
| 232 // IPC. | 233 // IPC. |
| 233 template <> | 234 template <> |
| 234 struct ParamTraits<float> { | 235 struct ParamTraits<float> { |
| 235 typedef float param_type; | 236 typedef float param_type; |
| 236 static void Write(Message* m, const param_type& p) { | 237 static void Write(Message* m, const param_type& p) { |
| (...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1306 ReplyParam p(a, b, c, d, e); | 1307 ReplyParam p(a, b, c, d, e); |
| 1307 WriteParam(reply, p); | 1308 WriteParam(reply, p); |
| 1308 } | 1309 } |
| 1309 }; | 1310 }; |
| 1310 | 1311 |
| 1311 //----------------------------------------------------------------------------- | 1312 //----------------------------------------------------------------------------- |
| 1312 | 1313 |
| 1313 } // namespace IPC | 1314 } // namespace IPC |
| 1314 | 1315 |
| 1315 #endif // IPC_IPC_MESSAGE_UTILS_H_ | 1316 #endif // IPC_IPC_MESSAGE_UTILS_H_ |
| OLD | NEW |