| 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 // This file is used to define IPC::ParamTraits<> specializations for a number | 5 // This file is used to define IPC::ParamTraits<> specializations for a number |
| 6 // of types so that they can be serialized over IPC. IPC::ParamTraits<> | 6 // of types so that they can be serialized over IPC. IPC::ParamTraits<> |
| 7 // specializations for basic types (like int and std::string) and types in the | 7 // specializations for basic types (like int and std::string) and types in the |
| 8 // 'base' project can be found in ipc/ipc_message_utils.h. This file contains | 8 // 'base' project can be found in ipc/ipc_message_utils.h. This file contains |
| 9 // specializations for types that are shared by more than one child process. | 9 // specializations for types that are shared by more than one child process. |
| 10 | 10 |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 struct ParamTraits<net::UploadData::Element> { | 311 struct ParamTraits<net::UploadData::Element> { |
| 312 typedef net::UploadData::Element param_type; | 312 typedef net::UploadData::Element param_type; |
| 313 static void Write(Message* m, const param_type& p) { | 313 static void Write(Message* m, const param_type& p) { |
| 314 WriteParam(m, static_cast<int>(p.type())); | 314 WriteParam(m, static_cast<int>(p.type())); |
| 315 if (p.type() == net::UploadData::TYPE_BYTES) { | 315 if (p.type() == net::UploadData::TYPE_BYTES) { |
| 316 m->WriteData(&p.bytes()[0], static_cast<int>(p.bytes().size())); | 316 m->WriteData(&p.bytes()[0], static_cast<int>(p.bytes().size())); |
| 317 } else { | 317 } else { |
| 318 WriteParam(m, p.file_path()); | 318 WriteParam(m, p.file_path()); |
| 319 WriteParam(m, p.file_range_offset()); | 319 WriteParam(m, p.file_range_offset()); |
| 320 WriteParam(m, p.file_range_length()); | 320 WriteParam(m, p.file_range_length()); |
| 321 WriteParam(m, p.expected_file_modification_time()); |
| 321 } | 322 } |
| 322 } | 323 } |
| 323 static bool Read(const Message* m, void** iter, param_type* r) { | 324 static bool Read(const Message* m, void** iter, param_type* r) { |
| 324 int type; | 325 int type; |
| 325 if (!ReadParam(m, iter, &type)) | 326 if (!ReadParam(m, iter, &type)) |
| 326 return false; | 327 return false; |
| 327 if (type == net::UploadData::TYPE_BYTES) { | 328 if (type == net::UploadData::TYPE_BYTES) { |
| 328 const char* data; | 329 const char* data; |
| 329 int len; | 330 int len; |
| 330 if (!m->ReadData(iter, &data, &len)) | 331 if (!m->ReadData(iter, &data, &len)) |
| 331 return false; | 332 return false; |
| 332 r->SetToBytes(data, len); | 333 r->SetToBytes(data, len); |
| 333 } else { | 334 } else { |
| 334 DCHECK(type == net::UploadData::TYPE_FILE); | 335 DCHECK(type == net::UploadData::TYPE_FILE); |
| 335 FilePath file_path; | 336 FilePath file_path; |
| 336 uint64 offset, length; | 337 uint64 offset, length; |
| 338 base::Time expected_modification_time; |
| 337 if (!ReadParam(m, iter, &file_path)) | 339 if (!ReadParam(m, iter, &file_path)) |
| 338 return false; | 340 return false; |
| 339 if (!ReadParam(m, iter, &offset)) | 341 if (!ReadParam(m, iter, &offset)) |
| 340 return false; | 342 return false; |
| 341 if (!ReadParam(m, iter, &length)) | 343 if (!ReadParam(m, iter, &length)) |
| 342 return false; | 344 return false; |
| 343 r->SetToFilePathRange(file_path, offset, length); | 345 if (!ReadParam(m, iter, &expected_modification_time)) |
| 346 return false; |
| 347 r->SetToFilePathRange(file_path, offset, length, |
| 348 expected_modification_time); |
| 344 } | 349 } |
| 345 return true; | 350 return true; |
| 346 } | 351 } |
| 347 static void Log(const param_type& p, std::wstring* l) { | 352 static void Log(const param_type& p, std::wstring* l) { |
| 348 l->append(L"<net::UploadData::Element>"); | 353 l->append(L"<net::UploadData::Element>"); |
| 349 } | 354 } |
| 350 }; | 355 }; |
| 351 | 356 |
| 352 // Traits for net::UploadData. | 357 // Traits for net::UploadData. |
| 353 template <> | 358 template <> |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 struct ParamTraits<Geoposition::ErrorCode> { | 430 struct ParamTraits<Geoposition::ErrorCode> { |
| 426 typedef Geoposition::ErrorCode param_type; | 431 typedef Geoposition::ErrorCode param_type; |
| 427 static void Write(Message* m, const param_type& p); | 432 static void Write(Message* m, const param_type& p); |
| 428 static bool Read(const Message* m, void** iter, param_type* p); | 433 static bool Read(const Message* m, void** iter, param_type* p); |
| 429 static void Log(const param_type& p, std::wstring* l); | 434 static void Log(const param_type& p, std::wstring* l); |
| 430 }; | 435 }; |
| 431 | 436 |
| 432 } // namespace IPC | 437 } // namespace IPC |
| 433 | 438 |
| 434 #endif // CHROME_COMMON_COMMON_PARAM_TRAITS_H_ | 439 #endif // CHROME_COMMON_COMMON_PARAM_TRAITS_H_ |
| OLD | NEW |