OLD | NEW |
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" |
11 #include "content/public/common/referrer.h" | 11 #include "content/public/common/referrer.h" |
12 #include "net/base/host_port_pair.h" | 12 #include "net/base/host_port_pair.h" |
13 #include "net/base/ip_address.h" | 13 #include "net/base/ip_address.h" |
14 #include "net/base/ip_endpoint.h" | 14 #include "net/base/ip_endpoint.h" |
15 | 15 |
16 namespace IPC { | 16 namespace IPC { |
17 | 17 |
18 void ParamTraits<url::Origin>::GetSize(base::PickleSizer* s, | 18 void ParamTraits<url::Origin>::GetSize(base::PickleSizer* s, |
19 const param_type& p) { | 19 const param_type& p) { |
20 GetParamSize(s, p.unique()); | 20 GetParamSize(s, p.opaque()); |
21 GetParamSize(s, p.scheme()); | 21 GetParamSize(s, p.scheme()); |
22 GetParamSize(s, p.host()); | 22 GetParamSize(s, p.host()); |
23 GetParamSize(s, p.port()); | 23 GetParamSize(s, p.port()); |
24 } | 24 } |
25 | 25 |
26 void ParamTraits<url::Origin>::Write(base::Pickle* m, const url::Origin& p) { | 26 void ParamTraits<url::Origin>::Write(base::Pickle* m, const url::Origin& p) { |
27 WriteParam(m, p.unique()); | 27 WriteParam(m, p.opaque()); |
28 WriteParam(m, p.scheme()); | 28 WriteParam(m, p.scheme()); |
29 WriteParam(m, p.host()); | 29 WriteParam(m, p.host()); |
30 WriteParam(m, p.port()); | 30 WriteParam(m, p.port()); |
31 } | 31 } |
32 | 32 |
33 bool ParamTraits<url::Origin>::Read(const base::Pickle* m, | 33 bool ParamTraits<url::Origin>::Read(const base::Pickle* m, |
34 base::PickleIterator* iter, | 34 base::PickleIterator* iter, |
35 url::Origin* p) { | 35 url::Origin* p) { |
36 bool unique; | 36 bool opaque; |
37 std::string scheme; | 37 std::string scheme; |
38 std::string host; | 38 std::string host; |
39 uint16_t port; | 39 uint16_t port; |
40 if (!ReadParam(m, iter, &unique) || !ReadParam(m, iter, &scheme) || | 40 if (!ReadParam(m, iter, &opaque) || !ReadParam(m, iter, &scheme) || |
41 !ReadParam(m, iter, &host) || !ReadParam(m, iter, &port)) { | 41 !ReadParam(m, iter, &host) || !ReadParam(m, iter, &port)) { |
42 *p = url::Origin(); | 42 *p = url::Origin(); |
43 return false; | 43 return false; |
44 } | 44 } |
45 | 45 |
46 *p = unique ? url::Origin() | 46 *p = opaque ? url::Origin() |
47 : url::Origin::UnsafelyCreateOriginWithoutNormalization( | 47 : url::Origin::UnsafelyCreateOriginWithoutNormalization( |
48 scheme, host, port); | 48 scheme, host, port); |
49 | 49 |
50 // If a unique origin was created, but the unique flag wasn't set, then | 50 // If an opaque origin was created, but the opaque flag wasn't set, then |
51 // the values provided to 'UnsafelyCreateOriginWithoutNormalization' were | 51 // the values provided to 'UnsafelyCreateOriginWithoutNormalization' were |
52 // invalid; kill the renderer. | 52 // invalid; kill the renderer. |
53 if (!unique && p->unique()) | 53 if (!opaque && p->opaque()) |
54 return false; | 54 return false; |
55 | 55 |
56 return true; | 56 return true; |
57 } | 57 } |
58 | 58 |
59 void ParamTraits<url::Origin>::Log(const url::Origin& p, std::string* l) { | 59 void ParamTraits<url::Origin>::Log(const url::Origin& p, std::string* l) { |
60 l->append(p.Serialize()); | 60 l->append(p.Serialize()); |
61 } | 61 } |
62 | 62 |
63 void ParamTraits<net::HostPortPair>::GetSize(base::PickleSizer* s, | 63 void ParamTraits<net::HostPortPair>::GetSize(base::PickleSizer* s, |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ | 195 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ |
196 #include "content/public/common/common_param_traits_macros.h" | 196 #include "content/public/common/common_param_traits_macros.h" |
197 } // namespace IPC | 197 } // namespace IPC |
198 | 198 |
199 // Generate param traits log methods. | 199 // Generate param traits log methods. |
200 #include "ipc/param_traits_log_macros.h" | 200 #include "ipc/param_traits_log_macros.h" |
201 namespace IPC { | 201 namespace IPC { |
202 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ | 202 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ |
203 #include "content/public/common/common_param_traits_macros.h" | 203 #include "content/public/common/common_param_traits_macros.h" |
204 } // namespace IPC | 204 } // namespace IPC |
OLD | NEW |