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

Side by Side Diff: content/public/common/common_param_traits.cc

Issue 1153763002: Hardening the 'url::Origin' implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/public/common/common_param_traits.h" 5 #include "content/public/common/common_param_traits.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "content/public/common/content_constants.h" 9 #include "content/public/common/content_constants.h"
10 #include "content/public/common/page_state.h" 10 #include "content/public/common/page_state.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 *p = GURL(); 44 *p = GURL();
45 return false; 45 return false;
46 } 46 }
47 return true; 47 return true;
48 } 48 }
49 49
50 void ParamTraits<GURL>::Log(const GURL& p, std::string* l) { 50 void ParamTraits<GURL>::Log(const GURL& p, std::string* l) {
51 l->append(p.spec()); 51 l->append(p.spec());
52 } 52 }
53 53
54 void ParamTraits<url::Origin>::Write(Message* m, 54 void ParamTraits<url::Origin>::Write(Message* m, const url::Origin& p) {
55 const url::Origin& p) { 55 WriteParam(m, p.scheme());
56 m->WriteString(p.string()); 56 WriteParam(m, p.host());
57 WriteParam(m, p.port());
Ryan Sleevi 2015/05/22 20:43:35 DANGER: If p.port()'s signature were to hypothetic
Mike West 2015/05/28 07:24:29 My impression is that this is safe; if we update t
Ryan Sleevi 2015/05/28 07:33:21 You didn't add tsepez, fyi
57 } 58 }
58 59
59 bool ParamTraits<url::Origin>::Read(const Message* m, 60 bool ParamTraits<url::Origin>::Read(const Message* m,
60 PickleIterator* iter, 61 PickleIterator* iter,
61 url::Origin* p) { 62 url::Origin* p) {
62 std::string s; 63 std::string scheme;
63 if (!iter->ReadString(&s)) { 64 std::string host;
65 unsigned short port;
Ryan Sleevi 2015/05/22 20:43:35 DANGER: This isn't explicitly sized, but it would
Mike West 2015/05/28 07:24:29 Following HostPortPair's lead, and converting this
66 if (!ReadParam(m, iter, &scheme) || !ReadParam(m, iter, &host) ||
67 !ReadParam(m, iter, &port)) {
64 *p = url::Origin(); 68 *p = url::Origin();
65 return false; 69 return false;
66 } 70 }
67 *p = url::Origin(s); 71 *p = url::Origin(scheme, host, port);
68 return true; 72 return true;
69 } 73 }
70 74
71 void ParamTraits<url::Origin>::Log(const url::Origin& p, std::string* l) { 75 void ParamTraits<url::Origin>::Log(const url::Origin& p, std::string* l) {
72 l->append(p.string()); 76 l->append(p.serialize());
73 } 77 }
74 78
75 void ParamTraits<net::HostPortPair>::Write(Message* m, const param_type& p) { 79 void ParamTraits<net::HostPortPair>::Write(Message* m, const param_type& p) {
76 WriteParam(m, p.host()); 80 WriteParam(m, p.host());
77 WriteParam(m, p.port()); 81 WriteParam(m, p.port());
78 } 82 }
79 83
80 bool ParamTraits<net::HostPortPair>::Read(const Message* m, 84 bool ParamTraits<net::HostPortPair>::Read(const Message* m,
81 PickleIterator* iter, 85 PickleIterator* iter,
82 param_type* r) { 86 param_type* r) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ 158 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_
155 #include "content/public/common/common_param_traits_macros.h" 159 #include "content/public/common/common_param_traits_macros.h"
156 } // namespace IPC 160 } // namespace IPC
157 161
158 // Generate param traits log methods. 162 // Generate param traits log methods.
159 #include "ipc/param_traits_log_macros.h" 163 #include "ipc/param_traits_log_macros.h"
160 namespace IPC { 164 namespace IPC {
161 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ 165 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_
162 #include "content/public/common/common_param_traits_macros.h" 166 #include "content/public/common/common_param_traits_macros.h"
163 } // namespace IPC 167 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698