summaryrefslogtreecommitdiffstats
path: root/extensions/common
diff options
context:
space:
mode:
authorrockot <rockot@chromium.org>2016-02-03 12:20:16 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-03 20:21:49 +0000
commit502c94ff1a9f99b5c4ecfe700415cc4ed14228dd (patch)
tree260521d2640e580c11a54d24781ef0ebc32baee3 /extensions/common
parent26c9117edc07280155c69c7fab04729af46a79eb (diff)
downloadchromium_src-502c94ff1a9f99b5c4ecfe700415cc4ed14228dd.zip
chromium_src-502c94ff1a9f99b5c4ecfe700415cc4ed14228dd.tar.gz
chromium_src-502c94ff1a9f99b5c4ecfe700415cc4ed14228dd.tar.bz2
IPC::Message -> base::Pickle
This changes consumers of IPC::Message to generally refer refer to base::Pickle instead when performing serialization and deserialization operations. The few specific instances where the IPC::Message interface (Read/WriteAttachent) is needed can safely be static_cast'd, as IPC::Message is the only public subclass of base::Pickle. The purpose of this change is to facilitate the transition to Mojo IPC, as we've trained the Mojo bindings layer to use existing ParamTraits<T> parameterized over base::Pickle. To support this base::Pickle has had some stub interfaces added for WriteAttachment and ReadAttachment, along with a Pickle::Attachment. A follow-up patch will add sizing traits to the standard IPC_STRUCT macros, enabling the majority of Chrome IPC structs to be carried over Mojo message pipes as-is. BUG=577685 R=jam@chromium.org Review URL: https://codereview.chromium.org/1659003003 Cr-Commit-Position: refs/heads/master@{#373323}
Diffstat (limited to 'extensions/common')
-rw-r--r--extensions/common/extension_messages.cc43
-rw-r--r--extensions/common/extension_messages.h48
-rw-r--r--extensions/common/permissions/api_permission.cc4
-rw-r--r--extensions/common/permissions/api_permission.h4
-rw-r--r--extensions/common/permissions/manifest_permission.cc4
-rw-r--r--extensions/common/permissions/manifest_permission.h4
-rw-r--r--extensions/common/permissions/set_disjunction_permission.h6
-rw-r--r--extensions/common/permissions/settings_override_permission.cc4
-rw-r--r--extensions/common/permissions/settings_override_permission.h4
9 files changed, 67 insertions, 54 deletions
diff --git a/extensions/common/extension_messages.cc b/extensions/common/extension_messages.cc
index 15bc121..5cccc11 100644
--- a/extensions/common/extension_messages.cc
+++ b/extensions/common/extension_messages.cc
@@ -92,11 +92,11 @@ namespace IPC {
template <>
struct ParamTraits<Manifest::Location> {
typedef Manifest::Location param_type;
- static void Write(Message* m, const param_type& p) {
+ static void Write(base::Pickle* m, const param_type& p) {
int val = static_cast<int>(p);
WriteParam(m, val);
}
- static bool Read(const Message* m,
+ static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
param_type* p) {
int val = 0;
@@ -112,12 +112,12 @@ struct ParamTraits<Manifest::Location> {
}
};
-void ParamTraits<URLPattern>::Write(Message* m, const param_type& p) {
+void ParamTraits<URLPattern>::Write(base::Pickle* m, const param_type& p) {
WriteParam(m, p.valid_schemes());
WriteParam(m, p.GetAsString());
}
-bool ParamTraits<URLPattern>::Read(const Message* m,
+bool ParamTraits<URLPattern>::Read(const base::Pickle* m,
base::PickleIterator* iter,
param_type* p) {
int valid_schemes;
@@ -141,11 +141,11 @@ void ParamTraits<URLPattern>::Log(const param_type& p, std::string* l) {
LogParam(p.GetAsString(), l);
}
-void ParamTraits<URLPatternSet>::Write(Message* m, const param_type& p) {
+void ParamTraits<URLPatternSet>::Write(base::Pickle* m, const param_type& p) {
WriteParam(m, p.patterns());
}
-bool ParamTraits<URLPatternSet>::Read(const Message* m,
+bool ParamTraits<URLPatternSet>::Read(const base::Pickle* m,
base::PickleIterator* iter,
param_type* p) {
std::set<URLPattern> patterns;
@@ -162,12 +162,12 @@ void ParamTraits<URLPatternSet>::Log(const param_type& p, std::string* l) {
LogParam(p.patterns(), l);
}
-void ParamTraits<APIPermission::ID>::Write(
- Message* m, const param_type& p) {
+void ParamTraits<APIPermission::ID>::Write(base::Pickle* m,
+ const param_type& p) {
WriteParam(m, static_cast<int>(p));
}
-bool ParamTraits<APIPermission::ID>::Read(const Message* m,
+bool ParamTraits<APIPermission::ID>::Read(const base::Pickle* m,
base::PickleIterator* iter,
param_type* p) {
int api_id = -2;
@@ -183,8 +183,8 @@ void ParamTraits<APIPermission::ID>::Log(
LogParam(static_cast<int>(p), l);
}
-void ParamTraits<APIPermissionSet>::Write(
- Message* m, const param_type& p) {
+void ParamTraits<APIPermissionSet>::Write(base::Pickle* m,
+ const param_type& p) {
APIPermissionSet::const_iterator it = p.begin();
const APIPermissionSet::const_iterator end = p.end();
WriteParam(m, p.size());
@@ -194,7 +194,7 @@ void ParamTraits<APIPermissionSet>::Write(
}
}
-bool ParamTraits<APIPermissionSet>::Read(const Message* m,
+bool ParamTraits<APIPermissionSet>::Read(const base::Pickle* m,
base::PickleIterator* iter,
param_type* r) {
size_t size;
@@ -221,8 +221,8 @@ void ParamTraits<APIPermissionSet>::Log(
LogParam(p.map(), l);
}
-void ParamTraits<ManifestPermissionSet>::Write(
- Message* m, const param_type& p) {
+void ParamTraits<ManifestPermissionSet>::Write(base::Pickle* m,
+ const param_type& p) {
ManifestPermissionSet::const_iterator it = p.begin();
const ManifestPermissionSet::const_iterator end = p.end();
WriteParam(m, p.size());
@@ -232,7 +232,7 @@ void ParamTraits<ManifestPermissionSet>::Write(
}
}
-bool ParamTraits<ManifestPermissionSet>::Read(const Message* m,
+bool ParamTraits<ManifestPermissionSet>::Read(const base::Pickle* m,
base::PickleIterator* iter,
param_type* r) {
size_t size;
@@ -257,13 +257,12 @@ void ParamTraits<ManifestPermissionSet>::Log(
LogParam(p.map(), l);
}
-void ParamTraits<HostID>::Write(
- Message* m, const param_type& p) {
+void ParamTraits<HostID>::Write(base::Pickle* m, const param_type& p) {
WriteParam(m, p.type());
WriteParam(m, p.id());
}
-bool ParamTraits<HostID>::Read(const Message* m,
+bool ParamTraits<HostID>::Read(const base::Pickle* m,
base::PickleIterator* iter,
param_type* r) {
HostID::HostType type;
@@ -282,7 +281,7 @@ void ParamTraits<HostID>::Log(
LogParam(p.id(), l);
}
-void ParamTraits<ExtensionMsg_PermissionSetStruct>::Write(Message* m,
+void ParamTraits<ExtensionMsg_PermissionSetStruct>::Write(base::Pickle* m,
const param_type& p) {
WriteParam(m, p.apis);
WriteParam(m, p.manifest_permissions);
@@ -291,7 +290,7 @@ void ParamTraits<ExtensionMsg_PermissionSetStruct>::Write(Message* m,
}
bool ParamTraits<ExtensionMsg_PermissionSetStruct>::Read(
- const Message* m,
+ const base::Pickle* m,
base::PickleIterator* iter,
param_type* p) {
return ReadParam(m, iter, &p->apis) &&
@@ -308,7 +307,7 @@ void ParamTraits<ExtensionMsg_PermissionSetStruct>::Log(const param_type& p,
LogParam(p.scriptable_hosts, l);
}
-void ParamTraits<ExtensionMsg_Loaded_Params>::Write(Message* m,
+void ParamTraits<ExtensionMsg_Loaded_Params>::Write(base::Pickle* m,
const param_type& p) {
WriteParam(m, p.location);
WriteParam(m, p.path);
@@ -318,7 +317,7 @@ void ParamTraits<ExtensionMsg_Loaded_Params>::Write(Message* m,
WriteParam(m, p.withheld_permissions);
}
-bool ParamTraits<ExtensionMsg_Loaded_Params>::Read(const Message* m,
+bool ParamTraits<ExtensionMsg_Loaded_Params>::Read(const base::Pickle* m,
base::PickleIterator* iter,
param_type* p) {
p->manifest.reset(new base::DictionaryValue());
diff --git a/extensions/common/extension_messages.h b/extensions/common/extension_messages.h
index 2e025ac..5125941 100644
--- a/extensions/common/extension_messages.h
+++ b/extensions/common/extension_messages.h
@@ -304,64 +304,80 @@ namespace IPC {
template <>
struct ParamTraits<URLPattern> {
typedef URLPattern param_type;
- static void Write(Message* m, const param_type& p);
- static bool Read(const Message* m, base::PickleIterator* iter, param_type* p);
+ static void Write(base::Pickle* m, const param_type& p);
+ static bool Read(const base::Pickle* m,
+ base::PickleIterator* iter,
+ param_type* p);
static void Log(const param_type& p, std::string* l);
};
template <>
struct ParamTraits<extensions::URLPatternSet> {
typedef extensions::URLPatternSet param_type;
- static void Write(Message* m, const param_type& p);
- static bool Read(const Message* m, base::PickleIterator* iter, param_type* p);
+ static void Write(base::Pickle* m, const param_type& p);
+ static bool Read(const base::Pickle* m,
+ base::PickleIterator* iter,
+ param_type* p);
static void Log(const param_type& p, std::string* l);
};
template <>
struct ParamTraits<extensions::APIPermission::ID> {
typedef extensions::APIPermission::ID param_type;
- static void Write(Message* m, const param_type& p);
- static bool Read(const Message* m, base::PickleIterator* iter, param_type* p);
+ static void Write(base::Pickle* m, const param_type& p);
+ static bool Read(const base::Pickle* m,
+ base::PickleIterator* iter,
+ param_type* p);
static void Log(const param_type& p, std::string* l);
};
template <>
struct ParamTraits<extensions::APIPermissionSet> {
typedef extensions::APIPermissionSet param_type;
- static void Write(Message* m, const param_type& p);
- static bool Read(const Message* m, base::PickleIterator* iter, param_type* r);
+ static void Write(base::Pickle* m, const param_type& p);
+ static bool Read(const base::Pickle* m,
+ base::PickleIterator* iter,
+ param_type* r);
static void Log(const param_type& p, std::string* l);
};
template <>
struct ParamTraits<extensions::ManifestPermissionSet> {
typedef extensions::ManifestPermissionSet param_type;
- static void Write(Message* m, const param_type& p);
- static bool Read(const Message* m, base::PickleIterator* iter, param_type* r);
+ static void Write(base::Pickle* m, const param_type& p);
+ static bool Read(const base::Pickle* m,
+ base::PickleIterator* iter,
+ param_type* r);
static void Log(const param_type& p, std::string* l);
};
template <>
struct ParamTraits<HostID> {
typedef HostID param_type;
- static void Write(Message* m, const param_type& p);
- static bool Read(const Message* m, base::PickleIterator* iter, param_type* r);
+ static void Write(base::Pickle* m, const param_type& p);
+ static bool Read(const base::Pickle* m,
+ base::PickleIterator* iter,
+ param_type* r);
static void Log(const param_type& p, std::string* l);
};
template <>
struct ParamTraits<ExtensionMsg_PermissionSetStruct> {
typedef ExtensionMsg_PermissionSetStruct param_type;
- static void Write(Message* m, const param_type& p);
- static bool Read(const Message* m, base::PickleIterator* iter, param_type* p);
+ static void Write(base::Pickle* m, const param_type& p);
+ static bool Read(const base::Pickle* m,
+ base::PickleIterator* iter,
+ param_type* p);
static void Log(const param_type& p, std::string* l);
};
template <>
struct ParamTraits<ExtensionMsg_Loaded_Params> {
typedef ExtensionMsg_Loaded_Params param_type;
- static void Write(Message* m, const param_type& p);
- static bool Read(const Message* m, base::PickleIterator* iter, param_type* p);
+ static void Write(base::Pickle* m, const param_type& p);
+ static bool Read(const base::Pickle* m,
+ base::PickleIterator* iter,
+ param_type* p);
static void Log(const param_type& p, std::string* l);
};
diff --git a/extensions/common/permissions/api_permission.cc b/extensions/common/permissions/api_permission.cc
index 89eaea5..77a1317 100644
--- a/extensions/common/permissions/api_permission.cc
+++ b/extensions/common/permissions/api_permission.cc
@@ -69,9 +69,9 @@ class SimpleAPIPermission : public APIPermission {
return new SimpleAPIPermission(info());
}
- void Write(IPC::Message* m) const override {}
+ void Write(base::Pickle* m) const override {}
- bool Read(const IPC::Message* m, base::PickleIterator* iter) override {
+ bool Read(const base::Pickle* m, base::PickleIterator* iter) override {
return true;
}
diff --git a/extensions/common/permissions/api_permission.h b/extensions/common/permissions/api_permission.h
index 5d46ce9..0b6f1a3 100644
--- a/extensions/common/permissions/api_permission.h
+++ b/extensions/common/permissions/api_permission.h
@@ -324,10 +324,10 @@ class APIPermission {
// IPC functions
// Writes this into the given IPC message |m|.
- virtual void Write(IPC::Message* m) const = 0;
+ virtual void Write(base::Pickle* m) const = 0;
// Reads from the given IPC message |m|.
- virtual bool Read(const IPC::Message* m, base::PickleIterator* iter) = 0;
+ virtual bool Read(const base::Pickle* m, base::PickleIterator* iter) = 0;
// Logs this permission.
virtual void Log(std::string* log) const = 0;
diff --git a/extensions/common/permissions/manifest_permission.cc b/extensions/common/permissions/manifest_permission.cc
index a3ba98e..9742138 100644
--- a/extensions/common/permissions/manifest_permission.cc
+++ b/extensions/common/permissions/manifest_permission.cc
@@ -27,14 +27,14 @@ bool ManifestPermission::Equal(const ManifestPermission* rhs) const {
return ToValue()->Equals(rhs->ToValue().get());
}
-void ManifestPermission::Write(IPC::Message* m) const {
+void ManifestPermission::Write(base::Pickle* m) const {
base::ListValue singleton;
base::Value* value = ToValue().release();
singleton.Append(value);
IPC::WriteParam(m, singleton);
}
-bool ManifestPermission::Read(const IPC::Message* m,
+bool ManifestPermission::Read(const base::Pickle* m,
base::PickleIterator* iter) {
base::ListValue singleton;
if (!IPC::ReadParam(m, iter, &singleton))
diff --git a/extensions/common/permissions/manifest_permission.h b/extensions/common/permissions/manifest_permission.h
index 67c41d5..db8f07c 100644
--- a/extensions/common/permissions/manifest_permission.h
+++ b/extensions/common/permissions/manifest_permission.h
@@ -69,10 +69,10 @@ class ManifestPermission {
// IPC functions
// Writes this into the given IPC message |m|.
- void Write(IPC::Message* m) const;
+ void Write(base::Pickle* m) const;
// Reads from the given IPC message |m|.
- bool Read(const IPC::Message* m, base::PickleIterator* iter);
+ bool Read(const base::Pickle* m, base::PickleIterator* iter);
// Logs this permission.
void Log(std::string* log) const;
diff --git a/extensions/common/permissions/set_disjunction_permission.h b/extensions/common/permissions/set_disjunction_permission.h
index 1e124ab..0e97e9d 100644
--- a/extensions/common/permissions/set_disjunction_permission.h
+++ b/extensions/common/permissions/set_disjunction_permission.h
@@ -147,11 +147,9 @@ class SetDisjunctionPermission : public APIPermission {
return scoped_ptr<base::Value>(list);
}
- void Write(IPC::Message* m) const override {
- IPC::WriteParam(m, data_set_);
- }
+ void Write(base::Pickle* m) const override { IPC::WriteParam(m, data_set_); }
- bool Read(const IPC::Message* m, base::PickleIterator* iter) override {
+ bool Read(const base::Pickle* m, base::PickleIterator* iter) override {
return IPC::ReadParam(m, iter, &data_set_);
}
diff --git a/extensions/common/permissions/settings_override_permission.cc b/extensions/common/permissions/settings_override_permission.cc
index 7756c5e..43765d2 100644
--- a/extensions/common/permissions/settings_override_permission.cc
+++ b/extensions/common/permissions/settings_override_permission.cc
@@ -84,9 +84,9 @@ APIPermission* SettingsOverrideAPIPermission::Intersect(
return new SettingsOverrideAPIPermission(info(), setting_value_);
}
-void SettingsOverrideAPIPermission::Write(IPC::Message* m) const {}
+void SettingsOverrideAPIPermission::Write(base::Pickle* m) const {}
-bool SettingsOverrideAPIPermission::Read(const IPC::Message* m,
+bool SettingsOverrideAPIPermission::Read(const base::Pickle* m,
base::PickleIterator* iter) {
return true;
}
diff --git a/extensions/common/permissions/settings_override_permission.h b/extensions/common/permissions/settings_override_permission.h
index 32dc8b3..81a2730 100644
--- a/extensions/common/permissions/settings_override_permission.h
+++ b/extensions/common/permissions/settings_override_permission.h
@@ -33,8 +33,8 @@ class SettingsOverrideAPIPermission : public APIPermission {
APIPermission* Diff(const APIPermission* rhs) const override;
APIPermission* Union(const APIPermission* rhs) const override;
APIPermission* Intersect(const APIPermission* rhs) const override;
- void Write(IPC::Message* m) const override;
- bool Read(const IPC::Message* m, base::PickleIterator* iter) override;
+ void Write(base::Pickle* m) const override;
+ bool Read(const base::Pickle* m, base::PickleIterator* iter) override;
void Log(std::string* log) const override;
private: