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 #include "ipc/ipc_message_utils.h" | 5 #include "ipc/ipc_message_utils.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/nullable_string16.h" | 10 #include "base/strings/nullable_string16.h" |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
304 } | 304 } |
305 | 305 |
306 void ParamTraits<long long>::Log(const param_type& p, std::string* l) { | 306 void ParamTraits<long long>::Log(const param_type& p, std::string* l) { |
307 l->append(base::Int64ToString(static_cast<int64>(p))); | 307 l->append(base::Int64ToString(static_cast<int64>(p))); |
308 } | 308 } |
309 | 309 |
310 void ParamTraits<unsigned long long>::Log(const param_type& p, std::string* l) { | 310 void ParamTraits<unsigned long long>::Log(const param_type& p, std::string* l) { |
311 l->append(base::Uint64ToString(p)); | 311 l->append(base::Uint64ToString(p)); |
312 } | 312 } |
313 | 313 |
314 void ParamTraits<float>::Write(Message* m, const param_type& p) { | |
315 m->WriteData(reinterpret_cast<const char*>(&p), sizeof(param_type)); | |
316 } | |
317 | |
318 bool ParamTraits<float>::Read(const Message* m, PickleIterator* iter, | 314 bool ParamTraits<float>::Read(const Message* m, PickleIterator* iter, |
319 param_type* r) { | 315 param_type* r) { |
320 const char *data; | 316 if (!m->ReadFloat(iter, r)) { |
321 int data_size; | |
322 if (!m->ReadData(iter, &data, &data_size) || | |
323 data_size != sizeof(param_type)) { | |
324 NOTREACHED(); | 317 NOTREACHED(); |
325 return false; | 318 return false; |
326 } | 319 } |
327 memcpy(r, data, sizeof(param_type)); | |
328 return true; | 320 return true; |
329 } | 321 } |
330 | 322 |
331 void ParamTraits<float>::Log(const param_type& p, std::string* l) { | 323 void ParamTraits<float>::Log(const param_type& p, std::string* l) { |
332 l->append(base::StringPrintf("%e", p)); | 324 l->append(base::StringPrintf("%e", p)); |
333 } | 325 } |
334 | 326 |
335 void ParamTraits<double>::Write(Message* m, const param_type& p) { | 327 void ParamTraits<double>::Write(Message* m, const param_type& p) { |
336 m->WriteData(reinterpret_cast<const char*>(&p), sizeof(param_type)); | 328 m->WriteData(reinterpret_cast<const char*>(&p), sizeof(param_type)); |
danakj
2013/10/22 17:22:05
This is funny too, should be WriteBytes
piman
2013/10/24 06:17:14
Done, though I extracted this part to a separate C
| |
337 } | 329 } |
338 | 330 |
339 bool ParamTraits<double>::Read(const Message* m, PickleIterator* iter, | 331 bool ParamTraits<double>::Read(const Message* m, PickleIterator* iter, |
340 param_type* r) { | 332 param_type* r) { |
341 const char *data; | 333 const char *data; |
342 int data_size; | 334 int data_size; |
343 if (!m->ReadData(iter, &data, &data_size) || | 335 if (!m->ReadData(iter, &data, &data_size) || |
344 data_size != sizeof(param_type)) { | 336 data_size != sizeof(param_type)) { |
345 NOTREACHED(); | 337 NOTREACHED(); |
346 return false; | 338 return false; |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
842 return result; | 834 return result; |
843 } | 835 } |
844 | 836 |
845 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) { | 837 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) { |
846 l->append("<MSG>"); | 838 l->append("<MSG>"); |
847 } | 839 } |
848 | 840 |
849 #endif // OS_WIN | 841 #endif // OS_WIN |
850 | 842 |
851 } // namespace IPC | 843 } // namespace IPC |
OLD | NEW |