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

Side by Side Diff: url/ipc/url_param_traits.cc

Issue 1722773002: Mustash: Move GURL ParamTraits to url/ipc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Get rid of defines used for testing deps Created 4 years, 9 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
« no previous file with comments | « url/ipc/url_param_traits.h ('k') | url/ipc/url_param_traits_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "url/ipc/url_param_traits.h"
6
7 #include "url/gurl.h"
8
9 namespace IPC {
10
11 void ParamTraits<GURL>::Write(base::Pickle* m, const GURL& p) {
12 if (p.possibly_invalid_spec().length() > url::kMaxURLChars) {
13 m->WriteString(std::string());
14 return;
15 }
16
17 // Beware of print-parse inconsistency which would change an invalid
18 // 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
20 // avoids changing the on-the-wire representation of such a fundamental
21 // type as GURL. See https://crbug.com/166486 for additional work in
22 // this area.
23 if (!p.is_valid()) {
24 m->WriteString(std::string());
25 return;
26 }
27
28 m->WriteString(p.possibly_invalid_spec());
29 // TODO(brettw) bug 684583: Add encoding for query params.
30 }
31
32 bool ParamTraits<GURL>::Read(const base::Pickle* m,
33 base::PickleIterator* iter,
34 GURL* p) {
35 std::string s;
36 if (!iter->ReadString(&s) || s.length() > url::kMaxURLChars) {
37 *p = GURL();
38 return false;
39 }
40 *p = GURL(s);
41 if (!s.empty() && !p->is_valid()) {
42 *p = GURL();
43 return false;
44 }
45 return true;
46 }
47
48 void ParamTraits<GURL>::Log(const GURL& p, std::string* l) {
49 l->append(p.spec());
50 }
51
52 } // namespace IPC
OLDNEW
« no previous file with comments | « url/ipc/url_param_traits.h ('k') | url/ipc/url_param_traits_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698