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

Unified Diff: content/common/common_param_traits.cc

Issue 6840044: Size reduction: halve npchrome_frame.dll via code motion. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: content/common/common_param_traits.cc
===================================================================
--- content/common/common_param_traits.cc (revision 81474)
+++ content/common/common_param_traits.cc (working copy)
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// NOTE: New trait definitions that will be used by Chrome Frame must be placed
+// in common_param_traits2.cc.
+
#include "content/common/common_param_traits.h"
#include "content/common/content_constants.h"
-#include "net/base/host_port_pair.h"
-#include "net/base/upload_data.h"
#include "net/http/http_response_headers.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/gfx/rect.h"
#include "webkit/glue/password_form.h"
#include "webkit/glue/resource_loader_bridge.h"
@@ -69,26 +69,6 @@
namespace IPC {
-void ParamTraits<GURL>::Write(Message* m, const GURL& p) {
- m->WriteString(p.possibly_invalid_spec());
- // TODO(brettw) bug 684583: Add encoding for query params.
-}
-
-bool ParamTraits<GURL>::Read(const Message* m, void** iter, GURL* p) {
- std::string s;
- if (!m->ReadString(iter, &s) || s.length() > content::kMaxURLChars) {
- *p = GURL();
- return false;
- }
- *p = GURL(s);
- return true;
-}
-
-void ParamTraits<GURL>::Log(const GURL& p, std::string* l) {
- l->append(p.spec());
-}
-
-
void ParamTraits<ResourceType::Type>::Write(Message* m, const param_type& p) {
m->WriteInt(p);
}
@@ -153,225 +133,6 @@
LogParam(type, l);
}
-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<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<scoped_refptr<net::HttpResponseHeaders> >::Write(
Message* m, const param_type& p) {
WriteParam(m, p.get() != NULL);
@@ -570,26 +331,6 @@
l->append(")");
}
-void ParamTraits<gfx::Point>::Write(Message* m, const gfx::Point& p) {
- m->WriteInt(p.x());
- m->WriteInt(p.y());
-}
-
-bool ParamTraits<gfx::Point>::Read(const Message* m, void** iter,
- gfx::Point* r) {
- int x, y;
- if (!m->ReadInt(iter, &x) ||
- !m->ReadInt(iter, &y))
- return false;
- r->set_x(x);
- r->set_y(y);
- return true;
-}
-
-void ParamTraits<gfx::Point>::Log(const gfx::Point& p, std::string* l) {
- l->append(base::StringPrintf("(%d, %d)", p.x(), p.y()));
-}
-
void ParamTraits<gfx::Size>::Write(Message* m, const gfx::Size& p) {
m->WriteInt(p.width());
m->WriteInt(p.height());
@@ -609,32 +350,6 @@
l->append(base::StringPrintf("(%d, %d)", p.width(), p.height()));
}
-void ParamTraits<gfx::Rect>::Write(Message* m, const gfx::Rect& p) {
- m->WriteInt(p.x());
- m->WriteInt(p.y());
- m->WriteInt(p.width());
- m->WriteInt(p.height());
-}
-
-bool ParamTraits<gfx::Rect>::Read(const Message* m, void** iter, gfx::Rect* r) {
- int x, y, w, h;
- if (!m->ReadInt(iter, &x) ||
- !m->ReadInt(iter, &y) ||
- !m->ReadInt(iter, &w) ||
- !m->ReadInt(iter, &h))
- return false;
- r->set_x(x);
- r->set_y(y);
- r->set_width(w);
- r->set_height(h);
- return true;
-}
-
-void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::string* l) {
- l->append(base::StringPrintf("(%d, %d, %d, %d)", p.x(), p.y(),
- p.width(), p.height()));
-}
-
// Only the webkit_blob::BlobData ParamTraits<> definition needs this
// definition, so keep this in the implementation file so we can forward declare
// BlobData in the header.

Powered by Google App Engine
This is Rietveld 408576698