Index: chrome/common/common_param_traits.cc |
=================================================================== |
--- chrome/common/common_param_traits.cc (revision 77019) |
+++ chrome/common/common_param_traits.cc (working copy) |
@@ -12,8 +12,6 @@ |
#include "chrome/common/web_apps.h" |
#include "content/common/common_param_traits.h" |
#include "googleurl/src/gurl.h" |
-#include "net/base/host_port_pair.h" |
-#include "net/base/upload_data.h" |
#include "printing/backend/print_backend.h" |
#include "printing/native_metafile.h" |
#include "printing/page_range.h" |
@@ -273,225 +271,6 @@ |
l->append("<WebApplicationInfo>"); |
} |
-void ParamTraits<net::HostPortPair>::Write(Message* m, const param_type& p) { |
- WriteParam(m, p.host()); |
- WriteParam(m, p.port()); |
-} |
- |
-bool ParamTraits<net::HostPortPair>::Read(const Message* m, void** iter, |
- param_type* r) { |
- std::string host; |
- uint16 port; |
- if (!ReadParam(m, iter, &host) || !ReadParam(m, iter, &port)) |
- return false; |
- |
- r->set_host(host); |
- r->set_port(port); |
- return true; |
-} |
- |
-void ParamTraits<net::HostPortPair>::Log(const param_type& p, std::string* l) { |
- l->append(p.ToString()); |
-} |
- |
-void ParamTraits<net::URLRequestStatus>::Write(Message* m, |
- const param_type& p) { |
- WriteParam(m, static_cast<int>(p.status())); |
- WriteParam(m, p.os_error()); |
-} |
- |
-bool ParamTraits<net::URLRequestStatus>::Read(const Message* m, void** iter, |
- param_type* r) { |
- int status, os_error; |
- if (!ReadParam(m, iter, &status) || |
- !ReadParam(m, iter, &os_error)) |
- return false; |
- r->set_status(static_cast<net::URLRequestStatus::Status>(status)); |
- r->set_os_error(os_error); |
- return true; |
-} |
- |
-void ParamTraits<net::URLRequestStatus>::Log(const param_type& p, |
- std::string* l) { |
- std::string status; |
- switch (p.status()) { |
- case net::URLRequestStatus::SUCCESS: |
- status = "SUCCESS"; |
- break; |
- case net::URLRequestStatus::IO_PENDING: |
- status = "IO_PENDING "; |
- break; |
- case net::URLRequestStatus::HANDLED_EXTERNALLY: |
- status = "HANDLED_EXTERNALLY"; |
- break; |
- case net::URLRequestStatus::CANCELED: |
- status = "CANCELED"; |
- break; |
- case net::URLRequestStatus::FAILED: |
- status = "FAILED"; |
- break; |
- default: |
- status = "UNKNOWN"; |
- break; |
- } |
- if (p.status() == net::URLRequestStatus::FAILED) |
- l->append("("); |
- |
- LogParam(status, l); |
- |
- if (p.status() == net::URLRequestStatus::FAILED) { |
- l->append(", "); |
- LogParam(p.os_error(), l); |
- l->append(")"); |
- } |
-} |
- |
-// Only the net::UploadData ParamTraits<> definition needs this definition, so |
-// keep this in the implementation file so we can forward declare UploadData in |
-// the header. |
-template <> |
-struct ParamTraits<net::UploadData::Element> { |
- typedef net::UploadData::Element param_type; |
- static void Write(Message* m, const param_type& p) { |
- WriteParam(m, static_cast<int>(p.type())); |
- switch (p.type()) { |
- case net::UploadData::TYPE_BYTES: { |
- m->WriteData(&p.bytes()[0], static_cast<int>(p.bytes().size())); |
- break; |
- } |
- case net::UploadData::TYPE_CHUNK: { |
- std::string chunk_length = StringPrintf( |
- "%X\r\n", static_cast<unsigned int>(p.bytes().size())); |
- std::vector<char> bytes; |
- bytes.insert(bytes.end(), chunk_length.data(), |
- chunk_length.data() + chunk_length.length()); |
- const char* data = &p.bytes()[0]; |
- bytes.insert(bytes.end(), data, data + p.bytes().size()); |
- const char* crlf = "\r\n"; |
- bytes.insert(bytes.end(), crlf, crlf + strlen(crlf)); |
- if (p.is_last_chunk()) { |
- const char* end_of_data = "0\r\n\r\n"; |
- bytes.insert(bytes.end(), end_of_data, |
- end_of_data + strlen(end_of_data)); |
- } |
- m->WriteData(&bytes[0], static_cast<int>(bytes.size())); |
- // 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()); |
- break; |
- } |
- case net::UploadData::TYPE_FILE: { |
- WriteParam(m, p.file_path()); |
- WriteParam(m, p.file_range_offset()); |
- WriteParam(m, p.file_range_length()); |
- WriteParam(m, p.expected_file_modification_time()); |
- break; |
- } |
- default: { |
- WriteParam(m, p.blob_url()); |
- break; |
- } |
- } |
- } |
- static bool Read(const Message* m, void** iter, param_type* r) { |
- int type; |
- if (!ReadParam(m, iter, &type)) |
- return false; |
- switch (type) { |
- case net::UploadData::TYPE_BYTES: { |
- const char* data; |
- int len; |
- if (!m->ReadData(iter, &data, &len)) |
- return false; |
- r->SetToBytes(data, len); |
- break; |
- } |
- case net::UploadData::TYPE_CHUNK: { |
- const char* data; |
- int len; |
- if (!m->ReadData(iter, &data, &len)) |
- return false; |
- r->SetToBytes(data, len); |
- // 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); |
- break; |
- } |
- case net::UploadData::TYPE_FILE: { |
- FilePath file_path; |
- uint64 offset, length; |
- base::Time expected_modification_time; |
- if (!ReadParam(m, iter, &file_path)) |
- return false; |
- if (!ReadParam(m, iter, &offset)) |
- return false; |
- if (!ReadParam(m, iter, &length)) |
- return false; |
- if (!ReadParam(m, iter, &expected_modification_time)) |
- return false; |
- r->SetToFilePathRange(file_path, offset, length, |
- expected_modification_time); |
- break; |
- } |
- default: { |
- DCHECK(type == net::UploadData::TYPE_BLOB); |
- GURL blob_url; |
- if (!ReadParam(m, iter, &blob_url)) |
- return false; |
- r->SetToBlobUrl(blob_url); |
- break; |
- } |
- } |
- return true; |
- } |
- static void Log(const param_type& p, std::string* l) { |
- l->append("<net::UploadData::Element>"); |
- } |
-}; |
- |
-void ParamTraits<scoped_refptr<net::UploadData> >::Write(Message* m, |
- const param_type& p) { |
- WriteParam(m, p.get() != NULL); |
- if (p) { |
- WriteParam(m, *p->elements()); |
- WriteParam(m, p->identifier()); |
- WriteParam(m, p->is_chunked()); |
- } |
-} |
- |
-bool ParamTraits<scoped_refptr<net::UploadData> >::Read(const Message* m, |
- void** iter, |
- param_type* r) { |
- bool has_object; |
- if (!ReadParam(m, iter, &has_object)) |
- return false; |
- if (!has_object) |
- return true; |
- std::vector<net::UploadData::Element> elements; |
- if (!ReadParam(m, iter, &elements)) |
- return false; |
- 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; |
-} |
- |
-void ParamTraits<scoped_refptr<net::UploadData> >::Log(const param_type& p, |
- std::string* l) { |
- l->append("<net::UploadData>"); |
-} |
- |
void ParamTraits<ThumbnailScore>::Write(Message* m, const param_type& p) { |
IPC::ParamTraits<double>::Write(m, p.boring_score); |
IPC::ParamTraits<bool>::Write(m, p.good_clipping); |