OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 CHROME_COMMON_IPC_MESSAGE_UTILS_H_ | 5 #ifndef CHROME_COMMON_IPC_MESSAGE_UTILS_H_ |
6 #define CHROME_COMMON_IPC_MESSAGE_UTILS_H_ | 6 #define CHROME_COMMON_IPC_MESSAGE_UTILS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 #include <map> | 10 #include <map> |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 m->WriteInt64(static_cast<int64>(p)); | 201 m->WriteInt64(static_cast<int64>(p)); |
202 } | 202 } |
203 static bool Read(const Message* m, void** iter, param_type* r) { | 203 static bool Read(const Message* m, void** iter, param_type* r) { |
204 return m->ReadInt64(iter, reinterpret_cast<int64*>(r)); | 204 return m->ReadInt64(iter, reinterpret_cast<int64*>(r)); |
205 } | 205 } |
206 static void Log(const param_type& p, std::wstring* l) { | 206 static void Log(const param_type& p, std::wstring* l) { |
207 l->append(StringPrintf(L"%I64u", p)); | 207 l->append(StringPrintf(L"%I64u", p)); |
208 } | 208 } |
209 }; | 209 }; |
210 | 210 |
| 211 #if !defined(OS_WIN) |
| 212 // TODO(port): why do we need this? |
| 213 template <> |
| 214 struct ParamTraits<void*> { |
| 215 typedef void* param_type; |
| 216 static void Write(Message* m, const param_type& p) { |
| 217 COMPILE_ASSERT(sizeof(long) == sizeof(void*), |
| 218 assumes_pointers_and_longs_same_size); |
| 219 m->WriteLong(bit_cast<long>(p)); |
| 220 } |
| 221 static bool Read(const Message* m, void** iter, param_type* r) { |
| 222 return m->ReadLong(iter, reinterpret_cast<long*>(r)); |
| 223 } |
| 224 static void Log(const param_type& p, std::wstring* l) { |
| 225 l->append(StringPrintf(L"%x", p)); |
| 226 } |
| 227 }; |
| 228 #endif |
| 229 |
211 template <> | 230 template <> |
212 struct ParamTraits<double> { | 231 struct ParamTraits<double> { |
213 typedef double param_type; | 232 typedef double param_type; |
214 static void Write(Message* m, const param_type& p) { | 233 static void Write(Message* m, const param_type& p) { |
215 m->WriteData(reinterpret_cast<const char*>(&p), sizeof(param_type)); | 234 m->WriteData(reinterpret_cast<const char*>(&p), sizeof(param_type)); |
216 } | 235 } |
217 static bool Read(const Message* m, void** iter, param_type* r) { | 236 static bool Read(const Message* m, void** iter, param_type* r) { |
218 const char *data; | 237 const char *data; |
219 int data_size = 0; | 238 int data_size = 0; |
220 bool result = m->ReadData(iter, &data, &data_size); | 239 bool result = m->ReadData(iter, &data, &data_size); |
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 l->append(L"<FindInPageRequest>"); | 1294 l->append(L"<FindInPageRequest>"); |
1276 } | 1295 } |
1277 }; | 1296 }; |
1278 | 1297 |
1279 //----------------------------------------------------------------------------- | 1298 //----------------------------------------------------------------------------- |
1280 | 1299 |
1281 } // namespace IPC | 1300 } // namespace IPC |
1282 | 1301 |
1283 #endif // CHROME_COMMON_IPC_MESSAGE_UTILS_H_ | 1302 #endif // CHROME_COMMON_IPC_MESSAGE_UTILS_H_ |
1284 | 1303 |
OLD | NEW |