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

Side by Side Diff: url/mojo/url_gurl.h

Issue 1760643004: Add mojo struct traits for GURL so that it can be sent over mojoms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move to mojom namespace and add security owners 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/mojo/url.mojom ('k') | url/mojo/url_test.mojom » ('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 2016 The Chromium Authors. All rights reserved.
dcheng 2016/03/03 16:23:53 Can we have some sort of naming convention for fil
jam 2016/03/03 21:25:12 sure that seems reasonable, renamed
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 "base/strings/string_piece.h"
6 #include "url/gurl.h"
7 #include "url/mojo/url.mojom.h"
8
9 namespace mojo {
10
11 // copied from content/public/common/content_constants.cc: make that file use
12 // this definition.
13 const size_t kMaxURLChars = 2 * 1024 * 1024;
dcheng 2016/03/03 16:23:53 Nit: Strictly speaking, this should be kMaxUrlChar
jam 2016/03/03 21:25:12 Done.
14
15 template <>
16 struct StructTraits<url::mojom::Url, GURL> {
17 static base::StringPiece url(const GURL& r) {
dcheng 2016/03/03 16:23:53 Is there documentation on how StructTraits work? H
jam 2016/03/03 21:25:12 Looks like Ken already replied.
18 if (r.possibly_invalid_spec().length() > kMaxURLChars || !r.is_valid()) {
19 return base::StringPiece();
20 }
21
22 return base::StringPiece(r.possibly_invalid_spec().c_str(),
23 r.possibly_invalid_spec().length());
24 }
25 static bool Read(url::mojom::Url::Reader r, GURL* out) {
26 if (r.url().length() > kMaxURLChars) {
27 *out = GURL();
28 return false;
29 }
30 *out = GURL(r.url());
31 if (!r.url().empty() && !out->is_valid()) {
32 *out = GURL();
33 return false;
34 }
35 return true;
36 }
37 };
38
39 }
OLDNEW
« no previous file with comments | « url/mojo/url.mojom ('k') | url/mojo/url_test.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698