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 "content/public/common/content_constants.h" | 7 #include "content/public/common/content_constants.h" |
8 #include "content/public/common/referrer.h" | 8 #include "content/public/common/referrer.h" |
9 #include "net/base/host_port_pair.h" | 9 #include "net/base/host_port_pair.h" |
10 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 return true; | 43 return true; |
44 } | 44 } |
45 }; | 45 }; |
46 | 46 |
47 } // namespace | 47 } // namespace |
48 | 48 |
49 namespace IPC { | 49 namespace IPC { |
50 | 50 |
51 void ParamTraits<GURL>::Write(Message* m, const GURL& p) { | 51 void ParamTraits<GURL>::Write(Message* m, const GURL& p) { |
52 DCHECK(p.possibly_invalid_spec().length() <= content::kMaxURLChars); | 52 DCHECK(p.possibly_invalid_spec().length() <= content::kMaxURLChars); |
53 | |
54 // Beware of print-parse inconsistency which would change an invalid | |
55 // URL into a valid one. Ideally, the message would contain this flag | |
56 // so that the read side could make the check, but performing it here | |
57 // avoids changing the on-the-wire representation of such a fundamental | |
58 // type as GURL. | |
brettw
2012/12/17 20:25:00
Can you file a bug for doing said improvements and
Tom Sepez
2012/12/17 20:53:38
Done.
| |
59 if (!p.is_valid()) { | |
60 GURL reconstructed_url(p.possibly_invalid_spec()); | |
61 if (reconstructed_url.is_valid()) { | |
62 DLOG(WARNING) << "GURL string " << p.possibly_invalid_spec() | |
63 << " (marked invalid) but parsed as valid."; | |
64 m->WriteString(""); | |
brettw
2012/12/17 20:25:00
Can you do WriteString(std::string()) instead?
Tom Sepez
2012/12/17 20:53:38
Done.
| |
65 return; | |
66 } | |
67 } | |
68 | |
53 m->WriteString(p.possibly_invalid_spec()); | 69 m->WriteString(p.possibly_invalid_spec()); |
54 // TODO(brettw) bug 684583: Add encoding for query params. | 70 // TODO(brettw) bug 684583: Add encoding for query params. |
55 } | 71 } |
56 | 72 |
57 bool ParamTraits<GURL>::Read(const Message* m, PickleIterator* iter, GURL* p) { | 73 bool ParamTraits<GURL>::Read(const Message* m, PickleIterator* iter, GURL* p) { |
58 std::string s; | 74 std::string s; |
59 if (!m->ReadString(iter, &s) || s.length() > content::kMaxURLChars) { | 75 if (!m->ReadString(iter, &s) || s.length() > content::kMaxURLChars) { |
60 *p = GURL(); | 76 *p = GURL(); |
61 return false; | 77 return false; |
62 } | 78 } |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
305 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ | 321 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ |
306 #include "content/public/common/common_param_traits_macros.h" | 322 #include "content/public/common/common_param_traits_macros.h" |
307 } // namespace IPC | 323 } // namespace IPC |
308 | 324 |
309 // Generate param traits log methods. | 325 // Generate param traits log methods. |
310 #include "ipc/param_traits_log_macros.h" | 326 #include "ipc/param_traits_log_macros.h" |
311 namespace IPC { | 327 namespace IPC { |
312 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ | 328 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ |
313 #include "content/public/common/common_param_traits_macros.h" | 329 #include "content/public/common/common_param_traits_macros.h" |
314 } // namespace IPC | 330 } // namespace IPC |
OLD | NEW |