Commit f1c31f74 authored by gavinp@chromium.org's avatar gavinp@chromium.org

Move Referrer into CommonParamTraits

While working on http://codereview.chromium.org/9875026/ , I ended up needing to put a content::Referrer into the prerender_messages.  The problem was that it's already used in view_messages, and the compile would fail due to duplicate definitions.  The CommonParamTraits approach here avoids this problem by explicitly including a serializer and deserializer.

BUG=None

Review URL: http://codereview.chromium.org/10134024

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133915 0039d316-1c4b-4281-b951-d872f2087c98
parent bb40d8b1
......@@ -63,7 +63,6 @@ IPC_ENUM_TRAITS(WebKit::WebContextMenuData::MediaType)
IPC_ENUM_TRAITS(WebKit::WebMediaPlayerAction::Type)
IPC_ENUM_TRAITS(WebKit::WebPluginAction::Type)
IPC_ENUM_TRAITS(WebKit::WebPopupType)
IPC_ENUM_TRAITS(WebKit::WebReferrerPolicy)
IPC_ENUM_TRAITS(WebKit::WebTextDirection)
IPC_ENUM_TRAITS(WebMenuItem::Type)
IPC_ENUM_TRAITS(WindowContainerType)
......@@ -285,11 +284,6 @@ IPC_STRUCT_TRAITS_BEGIN(content::FrameNavigateParams)
IPC_STRUCT_TRAITS_MEMBER(socket_address)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(content::Referrer)
IPC_STRUCT_TRAITS_MEMBER(url)
IPC_STRUCT_TRAITS_MEMBER(policy)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(content::RendererPreferences)
IPC_STRUCT_TRAITS_MEMBER(can_accept_load_drops)
IPC_STRUCT_TRAITS_MEMBER(should_antialias_text)
......
......@@ -5,6 +5,7 @@
#include "content/public/common/common_param_traits.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/referrer.h"
#include "net/base/host_port_pair.h"
#include "net/base/upload_data.h"
#include "net/http/http_response_headers.h"
......@@ -445,6 +446,26 @@ void ParamTraits<base::PlatformFileInfo>::Log(
l->append(")");
}
void ParamTraits<content::Referrer>::Write(
Message* m, const param_type& p) {
WriteParam(m, p.url);
WriteParam(m, p.policy);
}
bool ParamTraits<content::Referrer>::Read(
const Message* m, PickleIterator* iter, param_type* r) {
return ReadParam(m, iter, &r->url) && ReadParam(m, iter, &r->policy);
}
void ParamTraits<content::Referrer>::Log(
const param_type& p, std::string* l) {
l->append("(");
LogParam(p.url, l);
l->append(",");
LogParam(p.policy, l);
l->append(")");
}
void ParamTraits<gfx::Point>::Write(Message* m, const gfx::Point& p) {
m->WriteInt(p.x());
m->WriteInt(p.y());
......
......@@ -8,7 +8,8 @@
// 'base' project can be found in ipc/ipc_message_utils.h. This file contains
// specializations for types that are used by the content code, and which need
// manual serialization code. This is usually because they're not structs with
// public members..
// public members, or because the same type is being used in multiple
// *_messages.h headers.
#ifndef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_H_
#define CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_H_
......@@ -23,12 +24,17 @@
#include "ipc/ipc_message_utils.h"
#include "net/base/ip_endpoint.h"
#include "net/url_request/url_request_status.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebReferrerPolicy.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/surface/transport_dib.h"
#include "webkit/glue/resource_type.h"
class SkBitmap;
namespace content {
struct Referrer;
}
namespace gfx {
class Point;
class Rect;
......@@ -111,6 +117,14 @@ struct ParamTraits<base::PlatformFileInfo> {
static void Log(const param_type& p, std::string* l);
};
template <>
struct CONTENT_EXPORT ParamTraits<content::Referrer> {
typedef content::Referrer param_type;
static void Write(Message* m, const param_type& p);
static bool Read(const Message* m, PickleIterator* iter, param_type* p);
static void Log(const param_type& p, std::string* l);
};
template <>
struct CONTENT_EXPORT ParamTraits<gfx::Point> {
typedef gfx::Point param_type;
......@@ -232,6 +246,11 @@ struct SimilarTypeTraits<base::PlatformFileError> {
typedef int Type;
};
template <>
struct SimilarTypeTraits<WebKit::WebReferrerPolicy> {
typedef int Type;
};
template <>
struct SimilarTypeTraits<content::PageTransition> {
typedef int Type;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment