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

Unified Diff: content/common/resource_messages.cc

Issue 2405483002: Make the request initiator Optional (Closed)
Patch Set: Introduce NullableOrigin to use for request initiator Created 4 years, 2 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/resource_messages.cc
diff --git a/content/common/resource_messages.cc b/content/common/resource_messages.cc
index 31330a7e2080c3b3be15f73fb19970becba02885..a62985f376fff7557d6d30a539f7d33b35ea07b2 100644
--- a/content/common/resource_messages.cc
+++ b/content/common/resource_messages.cc
@@ -480,4 +480,69 @@ void ParamTraits<scoped_refptr<net::ct::SignedCertificateTimestamp>>::Log(
l->append("<SignedCertificateTimestamp>");
}
+void ParamTraits<scoped_refptr<url::NullableOrigin>>::GetSize(
+ base::PickleSizer* s,
+ const param_type& p) {
+ GetParamSize(s, p.get() != NULL);
+ if (p.get()) {
+ GetParamSize(s, p->unique());
+ GetParamSize(s, p->scheme());
+ GetParamSize(s, p->host());
+ GetParamSize(s, p->port());
+ }
+}
+
+void ParamTraits<scoped_refptr<url::NullableOrigin>>::Write(
+ base::Pickle* m,
+ const param_type& p) {
+ WriteParam(m, p.get() != NULL);
+ if (p.get()) {
+ WriteParam(m, p->unique());
+ WriteParam(m, p->scheme());
+ WriteParam(m, p->host());
+ WriteParam(m, p->port());
+ }
+}
+
+bool ParamTraits<scoped_refptr<url::NullableOrigin>>::Read(
+ const base::Pickle* m,
+ base::PickleIterator* iter,
+ param_type* r) {
+ bool has_object;
+ if (!ReadParam(m, iter, &has_object))
+ return false;
+
+ if (!has_object)
+ return true;
+
+ bool unique;
+ std::string scheme;
+ std::string host;
+ uint16_t port;
+ if (!ReadParam(m, iter, &unique) || !ReadParam(m, iter, &scheme) ||
+ !ReadParam(m, iter, &host) || !ReadParam(m, iter, &port)) {
+ return false;
+ }
+
+ *r = unique ? new url::NullableOrigin(url::Origin())
+ : new url::NullableOrigin(
+ url::Origin::UnsafelyCreateOriginWithoutNormalization(
+ scheme, host, port));
+
+ // If a unique origin was created, but the unique flag wasn't set, then
+ // the values provided to 'UnsafelyCreateOriginWithoutNormalization' were
+ // invalid; kill the renderer.
+ if (!unique && (*r)->unique())
+ return false;
+
+ return true;
+}
+
+void ParamTraits<scoped_refptr<url::NullableOrigin>>::Log(const param_type& p,
+ std::string* l) {
+ l->append("<NullableOrigin>");
+ if (p.get())
+ l->append(p->Serialize());
+}
+
} // namespace IPC

Powered by Google App Engine
This is Rietveld 408576698