Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: chrome/common/common_param_traits.cc

Issue 6357017: Add support for chunked encoding in ChromeFrame for POST requests. This fixes... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 } 343 }
344 344
345 // Only the net::UploadData ParamTraits<> definition needs this definition, so 345 // Only the net::UploadData ParamTraits<> definition needs this definition, so
346 // keep this in the implementation file so we can forward declare UploadData in 346 // keep this in the implementation file so we can forward declare UploadData in
347 // the header. 347 // the header.
348 template <> 348 template <>
349 struct ParamTraits<net::UploadData::Element> { 349 struct ParamTraits<net::UploadData::Element> {
350 typedef net::UploadData::Element param_type; 350 typedef net::UploadData::Element param_type;
351 static void Write(Message* m, const param_type& p) { 351 static void Write(Message* m, const param_type& p) {
352 WriteParam(m, static_cast<int>(p.type())); 352 WriteParam(m, static_cast<int>(p.type()));
353 if (p.type() == net::UploadData::TYPE_BYTES) { 353 if (p.type() == net::UploadData::TYPE_BYTES ||
amit 2011/01/26 21:42:24 nit: It will be more readable to handle TYPE_CHUNK
ananta 2011/01/26 22:19:58 Done.
354 p.type() == net::UploadData::TYPE_CHUNK) {
354 m->WriteData(&p.bytes()[0], static_cast<int>(p.bytes().size())); 355 m->WriteData(&p.bytes()[0], static_cast<int>(p.bytes().size()));
356 if (p.type() == net::UploadData::TYPE_CHUNK) {
357 // If this element is part of a chunk upload then send over information
358 // indicating if this is the last chunk.
359 WriteParam(m, p.is_last_chunk());
360 }
355 } else if (p.type() == net::UploadData::TYPE_FILE) { 361 } else if (p.type() == net::UploadData::TYPE_FILE) {
356 WriteParam(m, p.file_path()); 362 WriteParam(m, p.file_path());
357 WriteParam(m, p.file_range_offset()); 363 WriteParam(m, p.file_range_offset());
358 WriteParam(m, p.file_range_length()); 364 WriteParam(m, p.file_range_length());
359 WriteParam(m, p.expected_file_modification_time()); 365 WriteParam(m, p.expected_file_modification_time());
360 } else { 366 } else {
361 WriteParam(m, p.blob_url()); 367 WriteParam(m, p.blob_url());
362 } 368 }
363 } 369 }
364 static bool Read(const Message* m, void** iter, param_type* r) { 370 static bool Read(const Message* m, void** iter, param_type* r) {
365 int type; 371 int type;
366 if (!ReadParam(m, iter, &type)) 372 if (!ReadParam(m, iter, &type))
367 return false; 373 return false;
368 if (type == net::UploadData::TYPE_BYTES) { 374 if (type == net::UploadData::TYPE_BYTES ||
375 type == net::UploadData::TYPE_CHUNK) {
369 const char* data; 376 const char* data;
370 int len; 377 int len;
371 if (!m->ReadData(iter, &data, &len)) 378 if (!m->ReadData(iter, &data, &len))
372 return false; 379 return false;
373 r->SetToBytes(data, len); 380 r->SetToBytes(data, len);
381 if (type == net::UploadData::TYPE_CHUNK) {
382 // If this element is part of a chunk upload then we need to explicitly
383 // set the type of the element and whether it is the last chunk.
384 bool is_last_chunk = false;
385 if (!ReadParam(m, iter, &is_last_chunk))
386 return false;
387 r->set_type(net::UploadData::TYPE_CHUNK);
388 r->set_is_last_chunk(is_last_chunk);
389 }
374 } else if (type == net::UploadData::TYPE_FILE) { 390 } else if (type == net::UploadData::TYPE_FILE) {
375 FilePath file_path; 391 FilePath file_path;
376 uint64 offset, length; 392 uint64 offset, length;
377 base::Time expected_modification_time; 393 base::Time expected_modification_time;
378 if (!ReadParam(m, iter, &file_path)) 394 if (!ReadParam(m, iter, &file_path))
379 return false; 395 return false;
380 if (!ReadParam(m, iter, &offset)) 396 if (!ReadParam(m, iter, &offset))
381 return false; 397 return false;
382 if (!ReadParam(m, iter, &length)) 398 if (!ReadParam(m, iter, &length))
383 return false; 399 return false;
(...skipping 14 matching lines...) Expand all
398 l->append("<net::UploadData::Element>"); 414 l->append("<net::UploadData::Element>");
399 } 415 }
400 }; 416 };
401 417
402 void ParamTraits<scoped_refptr<net::UploadData> >::Write(Message* m, 418 void ParamTraits<scoped_refptr<net::UploadData> >::Write(Message* m,
403 const param_type& p) { 419 const param_type& p) {
404 WriteParam(m, p.get() != NULL); 420 WriteParam(m, p.get() != NULL);
405 if (p) { 421 if (p) {
406 WriteParam(m, *p->elements()); 422 WriteParam(m, *p->elements());
407 WriteParam(m, p->identifier()); 423 WriteParam(m, p->identifier());
424 WriteParam(m, p->is_chunked());
408 } 425 }
409 } 426 }
410 427
411 bool ParamTraits<scoped_refptr<net::UploadData> >::Read(const Message* m, 428 bool ParamTraits<scoped_refptr<net::UploadData> >::Read(const Message* m,
412 void** iter, 429 void** iter,
413 param_type* r) { 430 param_type* r) {
414 bool has_object; 431 bool has_object;
415 if (!ReadParam(m, iter, &has_object)) 432 if (!ReadParam(m, iter, &has_object))
416 return false; 433 return false;
417 if (!has_object) 434 if (!has_object)
418 return true; 435 return true;
419 std::vector<net::UploadData::Element> elements; 436 std::vector<net::UploadData::Element> elements;
420 if (!ReadParam(m, iter, &elements)) 437 if (!ReadParam(m, iter, &elements))
421 return false; 438 return false;
422 int64 identifier; 439 int64 identifier;
423 if (!ReadParam(m, iter, &identifier)) 440 if (!ReadParam(m, iter, &identifier))
424 return false; 441 return false;
442 bool is_chunked = false;
443 if (!ReadParam(m, iter, &is_chunked))
444 return false;
425 *r = new net::UploadData; 445 *r = new net::UploadData;
426 (*r)->swap_elements(&elements); 446 (*r)->swap_elements(&elements);
427 (*r)->set_identifier(identifier); 447 (*r)->set_identifier(identifier);
448 (*r)->set_is_chunked(is_chunked);
428 return true; 449 return true;
429 } 450 }
430 451
431 void ParamTraits<scoped_refptr<net::UploadData> >::Log(const param_type& p, 452 void ParamTraits<scoped_refptr<net::UploadData> >::Log(const param_type& p,
432 std::string* l) { 453 std::string* l) {
433 l->append("<net::UploadData>"); 454 l->append("<net::UploadData>");
434 } 455 }
435 456
436 void ParamTraits<ThumbnailScore>::Write(Message* m, const param_type& p) { 457 void ParamTraits<ThumbnailScore>::Write(Message* m, const param_type& p) {
437 IPC::ParamTraits<double>::Write(m, p.boring_score); 458 IPC::ParamTraits<double>::Write(m, p.boring_score);
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 l->append(","); 694 l->append(",");
674 LogParam(p.caps_mime_type, l); 695 LogParam(p.caps_mime_type, l);
675 l->append(","); 696 l->append(",");
676 LogParam(p.printer_defaults, l); 697 LogParam(p.printer_defaults, l);
677 l->append(","); 698 l->append(",");
678 LogParam(p.defaults_mime_type, l); 699 LogParam(p.defaults_mime_type, l);
679 l->append(")"); 700 l->append(")");
680 } 701 }
681 702
682 } // namespace IPC 703 } // namespace IPC
OLDNEW
« no previous file with comments | « no previous file | chrome_frame/plugin_url_request.h » ('j') | chrome_frame/urlmon_upload_data_stream.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698