Index: content/public/common/common_param_traits.cc |
diff --git a/content/public/common/common_param_traits.cc b/content/public/common/common_param_traits.cc |
index f402cca31b34f0365b6b5abf0906c59778432324..6a937c62c53218c774a7488ae665f88742127df7 100644 |
--- a/content/public/common/common_param_traits.cc |
+++ b/content/public/common/common_param_traits.cc |
@@ -14,6 +14,47 @@ |
#include "net/base/ip_endpoint.h" |
namespace IPC { |
+ |
+void ParamTraits<GURL>::Write(base::Pickle* m, const GURL& p) { |
+ if (p.possibly_invalid_spec().length() > content::kMaxURLChars) { |
+ m->WriteString(std::string()); |
+ return; |
+ } |
+ |
+ // Beware of print-parse inconsistency which would change an invalid |
+ // URL into a valid one. Ideally, the message would contain this flag |
+ // so that the read side could make the check, but performing it here |
+ // avoids changing the on-the-wire representation of such a fundamental |
+ // type as GURL. See https://crbug.com/166486 for additional work in |
+ // this area. |
+ if (!p.is_valid()) { |
+ m->WriteString(std::string()); |
+ return; |
+ } |
+ |
+ m->WriteString(p.possibly_invalid_spec()); |
+ // TODO(brettw) bug 684583: Add encoding for query params. |
+} |
+ |
+bool ParamTraits<GURL>::Read(const base::Pickle* m, |
+ base::PickleIterator* iter, |
+ GURL* p) { |
+ std::string s; |
+ if (!iter->ReadString(&s) || s.length() > content::kMaxURLChars) { |
+ *p = GURL(); |
+ return false; |
+ } |
+ *p = GURL(s); |
+ if (!s.empty() && !p->is_valid()) { |
+ *p = GURL(); |
+ return false; |
+ } |
+ return true; |
+} |
+ |
+void ParamTraits<GURL>::Log(const GURL& p, std::string* l) { |
+ l->append(p.spec()); |
+} |
void ParamTraits<url::Origin>::Write(base::Pickle* m, const url::Origin& p) { |
WriteParam(m, p.unique()); |