OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/common/common_param_traits.h" | 5 #include "chrome/common/common_param_traits.h" |
6 | 6 |
7 #include "base/time.h" | 7 #include "base/time.h" |
8 #include "chrome/common/chrome_constants.h" | 8 #include "chrome/common/chrome_constants.h" |
9 #include "chrome/common/content_settings.h" | 9 #include "chrome/common/content_settings.h" |
10 #include "chrome/common/geoposition.h" | 10 #include "chrome/common/geoposition.h" |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 struct ParamTraits<net::UploadData::Element> { | 371 struct ParamTraits<net::UploadData::Element> { |
372 typedef net::UploadData::Element param_type; | 372 typedef net::UploadData::Element param_type; |
373 static void Write(Message* m, const param_type& p) { | 373 static void Write(Message* m, const param_type& p) { |
374 WriteParam(m, static_cast<int>(p.type())); | 374 WriteParam(m, static_cast<int>(p.type())); |
375 switch (p.type()) { | 375 switch (p.type()) { |
376 case net::UploadData::TYPE_BYTES: { | 376 case net::UploadData::TYPE_BYTES: { |
377 m->WriteData(&p.bytes()[0], static_cast<int>(p.bytes().size())); | 377 m->WriteData(&p.bytes()[0], static_cast<int>(p.bytes().size())); |
378 break; | 378 break; |
379 } | 379 } |
380 case net::UploadData::TYPE_CHUNK: { | 380 case net::UploadData::TYPE_CHUNK: { |
381 m->WriteData(&p.bytes()[0], static_cast<int>(p.bytes().size())); | 381 std::string chunk_length = StringPrintf("%X\r\n", p.bytes().size()); |
| 382 std::vector<char> bytes; |
| 383 bytes.insert(bytes.end(), chunk_length.data(), |
| 384 chunk_length.data() + chunk_length.length()); |
| 385 const char* data = &p.bytes()[0]; |
| 386 bytes.insert(bytes.end(), data, data + p.bytes().size()); |
| 387 const char* crlf = "\r\n"; |
| 388 bytes.insert(bytes.end(), crlf, crlf + 2); |
| 389 if (p.is_last_chunk()) { |
| 390 const char* end_of_data = "0\r\n\r\n"; |
| 391 bytes.insert(bytes.end(), end_of_data, end_of_data + 5); |
| 392 } |
| 393 m->WriteData(&bytes[0], static_cast<int>(bytes.size())); |
382 // If this element is part of a chunk upload then send over information | 394 // If this element is part of a chunk upload then send over information |
383 // indicating if this is the last chunk. | 395 // indicating if this is the last chunk. |
384 WriteParam(m, p.is_last_chunk()); | 396 WriteParam(m, p.is_last_chunk()); |
385 break; | 397 break; |
386 } | 398 } |
387 case net::UploadData::TYPE_FILE: { | 399 case net::UploadData::TYPE_FILE: { |
388 WriteParam(m, p.file_path()); | 400 WriteParam(m, p.file_path()); |
389 WriteParam(m, p.file_range_offset()); | 401 WriteParam(m, p.file_range_offset()); |
390 WriteParam(m, p.file_range_length()); | 402 WriteParam(m, p.file_range_length()); |
391 WriteParam(m, p.expected_file_modification_time()); | 403 WriteParam(m, p.expected_file_modification_time()); |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 l->append(","); | 748 l->append(","); |
737 LogParam(p.caps_mime_type, l); | 749 LogParam(p.caps_mime_type, l); |
738 l->append(","); | 750 l->append(","); |
739 LogParam(p.printer_defaults, l); | 751 LogParam(p.printer_defaults, l); |
740 l->append(","); | 752 l->append(","); |
741 LogParam(p.defaults_mime_type, l); | 753 LogParam(p.defaults_mime_type, l); |
742 l->append(")"); | 754 l->append(")"); |
743 } | 755 } |
744 | 756 |
745 } // namespace IPC | 757 } // namespace IPC |
OLD | NEW |