Index: chrome/common/common_param_traits.cc |
=================================================================== |
--- chrome/common/common_param_traits.cc (revision 72508) |
+++ chrome/common/common_param_traits.cc (working copy) |
@@ -350,8 +350,14 @@ |
typedef net::UploadData::Element param_type; |
static void Write(Message* m, const param_type& p) { |
WriteParam(m, static_cast<int>(p.type())); |
- if (p.type() == net::UploadData::TYPE_BYTES) { |
+ if (p.type() == net::UploadData::TYPE_BYTES || |
+ p.type() == net::UploadData::TYPE_CHUNK) { |
m->WriteData(&p.bytes()[0], static_cast<int>(p.bytes().size())); |
+ if (p.type() == net::UploadData::TYPE_CHUNK) { |
+ // If this element is part of a chunk upload then send over information |
+ // indicating if this is the last chunk. |
+ WriteParam(m, p.is_last_chunk()); |
+ } |
} else if (p.type() == net::UploadData::TYPE_FILE) { |
WriteParam(m, p.file_path()); |
WriteParam(m, p.file_range_offset()); |
@@ -365,12 +371,22 @@ |
int type; |
if (!ReadParam(m, iter, &type)) |
return false; |
- if (type == net::UploadData::TYPE_BYTES) { |
+ if (type == net::UploadData::TYPE_BYTES || |
+ type == net::UploadData::TYPE_CHUNK) { |
const char* data; |
int len; |
if (!m->ReadData(iter, &data, &len)) |
return false; |
r->SetToBytes(data, len); |
+ if (type == net::UploadData::TYPE_CHUNK) { |
+ // If this element is part of a chunk upload then we need to explicitly |
+ // set the type of the element and whether it is the last chunk. |
+ bool is_last_chunk = false; |
+ if (!ReadParam(m, iter, &is_last_chunk)) |
+ return false; |
+ r->set_type(net::UploadData::TYPE_CHUNK); |
+ r->set_is_last_chunk(is_last_chunk); |
+ } |
} else if (type == net::UploadData::TYPE_FILE) { |
FilePath file_path; |
uint64 offset, length; |
@@ -405,6 +421,7 @@ |
if (p) { |
WriteParam(m, *p->elements()); |
WriteParam(m, p->identifier()); |
+ WriteParam(m, p->is_chunked()); |
} |
} |
@@ -422,9 +439,13 @@ |
int64 identifier; |
if (!ReadParam(m, iter, &identifier)) |
return false; |
+ bool is_chunked = false; |
+ if (!ReadParam(m, iter, &is_chunked)) |
+ return false; |
*r = new net::UploadData; |
(*r)->swap_elements(&elements); |
(*r)->set_identifier(identifier); |
+ (*r)->set_is_chunked(is_chunked); |
return true; |
} |