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" |
(...skipping 17 matching lines...) Expand all Loading... |
28 m->WriteString(std::string()); | 28 m->WriteString(std::string()); |
29 return; | 29 return; |
30 } | 30 } |
31 | 31 |
32 m->WriteString(p.possibly_invalid_spec()); | 32 m->WriteString(p.possibly_invalid_spec()); |
33 // TODO(brettw) bug 684583: Add encoding for query params. | 33 // TODO(brettw) bug 684583: Add encoding for query params. |
34 } | 34 } |
35 | 35 |
36 bool ParamTraits<GURL>::Read(const Message* m, PickleIterator* iter, GURL* p) { | 36 bool ParamTraits<GURL>::Read(const Message* m, PickleIterator* iter, GURL* p) { |
37 std::string s; | 37 std::string s; |
38 if (!iter->ReadString(&s) || s.length() > content::GetMaxURLChars()) { | 38 if (!m->ReadString(iter, &s) || s.length() > content::GetMaxURLChars()) { |
39 *p = GURL(); | 39 *p = GURL(); |
40 return false; | 40 return false; |
41 } | 41 } |
42 *p = GURL(s); | 42 *p = GURL(s); |
43 if (!s.empty() && !p->is_valid()) { | 43 if (!s.empty() && !p->is_valid()) { |
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, |
55 const url::Origin& p) { | 55 const url::Origin& p) { |
56 m->WriteString(p.string()); | 56 m->WriteString(p.string()); |
57 } | 57 } |
58 | 58 |
59 bool ParamTraits<url::Origin>::Read(const Message* m, | 59 bool ParamTraits<url::Origin>::Read(const Message* m, |
60 PickleIterator* iter, | 60 PickleIterator* iter, |
61 url::Origin* p) { | 61 url::Origin* p) { |
62 std::string s; | 62 std::string s; |
63 if (!iter->ReadString(&s)) { | 63 if (!m->ReadString(iter, &s)) { |
64 *p = url::Origin(); | 64 *p = url::Origin(); |
65 return false; | 65 return false; |
66 } | 66 } |
67 *p = url::Origin(s); | 67 *p = url::Origin(s); |
68 return true; | 68 return true; |
69 } | 69 } |
70 | 70 |
71 void ParamTraits<url::Origin>::Log(const url::Origin& p, std::string* l) { | 71 void ParamTraits<url::Origin>::Log(const url::Origin& p, std::string* l) { |
72 l->append(p.string()); | 72 l->append(p.string()); |
73 } | 73 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ | 154 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ |
155 #include "content/public/common/common_param_traits_macros.h" | 155 #include "content/public/common/common_param_traits_macros.h" |
156 } // namespace IPC | 156 } // namespace IPC |
157 | 157 |
158 // Generate param traits log methods. | 158 // Generate param traits log methods. |
159 #include "ipc/param_traits_log_macros.h" | 159 #include "ipc/param_traits_log_macros.h" |
160 namespace IPC { | 160 namespace IPC { |
161 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ | 161 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ |
162 #include "content/public/common/common_param_traits_macros.h" | 162 #include "content/public/common/common_param_traits_macros.h" |
163 } // namespace IPC | 163 } // namespace IPC |
OLD | NEW |