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( |
| 382 "%X\r\n", static_cast<unsigned int>(p.bytes().size())); |
| 383 std::vector<char> bytes; |
| 384 bytes.insert(bytes.end(), chunk_length.data(), |
| 385 chunk_length.data() + chunk_length.length()); |
| 386 const char* data = &p.bytes()[0]; |
| 387 bytes.insert(bytes.end(), data, data + p.bytes().size()); |
| 388 const char* crlf = "\r\n"; |
| 389 bytes.insert(bytes.end(), crlf, crlf + strlen(crlf)); |
| 390 if (p.is_last_chunk()) { |
| 391 const char* end_of_data = "0\r\n\r\n"; |
| 392 bytes.insert(bytes.end(), end_of_data, |
| 393 end_of_data + strlen(end_of_data)); |
| 394 } |
| 395 m->WriteData(&bytes[0], static_cast<int>(bytes.size())); |
382 // If this element is part of a chunk upload then send over information | 396 // If this element is part of a chunk upload then send over information |
383 // indicating if this is the last chunk. | 397 // indicating if this is the last chunk. |
384 WriteParam(m, p.is_last_chunk()); | 398 WriteParam(m, p.is_last_chunk()); |
385 break; | 399 break; |
386 } | 400 } |
387 case net::UploadData::TYPE_FILE: { | 401 case net::UploadData::TYPE_FILE: { |
388 WriteParam(m, p.file_path()); | 402 WriteParam(m, p.file_path()); |
389 WriteParam(m, p.file_range_offset()); | 403 WriteParam(m, p.file_range_offset()); |
390 WriteParam(m, p.file_range_length()); | 404 WriteParam(m, p.file_range_length()); |
391 WriteParam(m, p.expected_file_modification_time()); | 405 WriteParam(m, p.expected_file_modification_time()); |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 l->append(","); | 750 l->append(","); |
737 LogParam(p.caps_mime_type, l); | 751 LogParam(p.caps_mime_type, l); |
738 l->append(","); | 752 l->append(","); |
739 LogParam(p.printer_defaults, l); | 753 LogParam(p.printer_defaults, l); |
740 l->append(","); | 754 l->append(","); |
741 LogParam(p.defaults_mime_type, l); | 755 LogParam(p.defaults_mime_type, l); |
742 l->append(")"); | 756 l->append(")"); |
743 } | 757 } |
744 | 758 |
745 } // namespace IPC | 759 } // namespace IPC |
OLD | NEW |