OLD | NEW |
---|---|
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 "url/ipc/url_param_traits.h" | 5 #include "url/ipc/url_param_traits.h" |
6 | 6 |
7 #include "url/gurl.h" | 7 #include "url/gurl.h" |
8 | 8 |
9 namespace IPC { | 9 namespace IPC { |
10 | 10 |
11 void ParamTraits<GURL>::GetSize(base::PickleSizer* s, const GURL& p) { | |
12 if (p.possibly_invalid_spec().length() > url::kMaxURLChars || !p.is_valid()) { | |
13 s->AddString(std::string()); | |
14 return; | |
15 } | |
16 | |
17 s->AddString(p.possibly_invalid_spec()); | |
dcheng
2016/05/11 17:39:12
Ditto: maybe this should just be GetParamSize(s, p
jam
2016/05/11 17:57:02
Done.
| |
18 } | |
19 | |
11 void ParamTraits<GURL>::Write(base::Pickle* m, const GURL& p) { | 20 void ParamTraits<GURL>::Write(base::Pickle* m, const GURL& p) { |
12 if (p.possibly_invalid_spec().length() > url::kMaxURLChars) { | 21 if (p.possibly_invalid_spec().length() > url::kMaxURLChars) { |
13 m->WriteString(std::string()); | 22 m->WriteString(std::string()); |
14 return; | 23 return; |
15 } | 24 } |
16 | 25 |
17 // Beware of print-parse inconsistency which would change an invalid | 26 // Beware of print-parse inconsistency which would change an invalid |
18 // URL into a valid one. Ideally, the message would contain this flag | 27 // URL into a valid one. Ideally, the message would contain this flag |
19 // so that the read side could make the check, but performing it here | 28 // so that the read side could make the check, but performing it here |
20 // avoids changing the on-the-wire representation of such a fundamental | 29 // avoids changing the on-the-wire representation of such a fundamental |
(...skipping 22 matching lines...) Expand all Loading... | |
43 return false; | 52 return false; |
44 } | 53 } |
45 return true; | 54 return true; |
46 } | 55 } |
47 | 56 |
48 void ParamTraits<GURL>::Log(const GURL& p, std::string* l) { | 57 void ParamTraits<GURL>::Log(const GURL& p, std::string* l) { |
49 l->append(p.spec()); | 58 l->append(p.spec()); |
50 } | 59 } |
51 | 60 |
52 } // namespace IPC | 61 } // namespace IPC |
OLD | NEW |