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

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

Issue 2716583003: Rename Origin.unique() to opaque().
Patch Set: Update new uses post-rebase Created 3 years, 4 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/origin.mojom ('k') | url/mojo/url_gurl_struct_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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 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 #ifndef URL_MOJO_ORIGIN_STRUCT_TRAITS_H_ 5 #ifndef URL_MOJO_ORIGIN_STRUCT_TRAITS_H_
6 #define URL_MOJO_ORIGIN_STRUCT_TRAITS_H_ 6 #define URL_MOJO_ORIGIN_STRUCT_TRAITS_H_
7 7
8 #include "base/strings/string_piece.h" 8 #include "base/strings/string_piece.h"
9 #include "url/mojo/origin.mojom.h" 9 #include "url/mojo/origin.mojom.h"
10 #include "url/origin.h" 10 #include "url/origin.h"
11 11
12 namespace mojo { 12 namespace mojo {
13 13
14 template <> 14 template <>
15 struct StructTraits<url::mojom::OriginDataView, url::Origin> { 15 struct StructTraits<url::mojom::OriginDataView, url::Origin> {
16 static const std::string& scheme(const url::Origin& r) { return r.scheme(); } 16 static const std::string& scheme(const url::Origin& r) { return r.scheme(); }
17 static const std::string& host(const url::Origin& r) { return r.host(); } 17 static const std::string& host(const url::Origin& r) { return r.host(); }
18 static uint16_t port(const url::Origin& r) { 18 static uint16_t port(const url::Origin& r) {
19 return r.port(); 19 return r.port();
20 } 20 }
21 static const std::string& suborigin(const url::Origin& r) { 21 static const std::string& suborigin(const url::Origin& r) {
22 return r.suborigin(); 22 return r.suborigin();
23 } 23 }
24 static bool unique(const url::Origin& r) { 24 static bool opaque(const url::Origin& r) { return r.opaque(); }
25 return r.unique();
26 }
27 static bool Read(url::mojom::OriginDataView data, url::Origin* out) { 25 static bool Read(url::mojom::OriginDataView data, url::Origin* out) {
28 if (data.unique()) { 26 if (data.opaque()) {
29 *out = url::Origin(); 27 *out = url::Origin();
30 } else { 28 } else {
31 base::StringPiece scheme, host, suborigin; 29 base::StringPiece scheme, host, suborigin;
32 if (!data.ReadScheme(&scheme) || !data.ReadHost(&host) || 30 if (!data.ReadScheme(&scheme) || !data.ReadHost(&host) ||
33 !data.ReadSuborigin(&suborigin)) 31 !data.ReadSuborigin(&suborigin))
34 return false; 32 return false;
35 33
36 *out = url::Origin::UnsafelyCreateOriginWithoutNormalization( 34 *out = url::Origin::UnsafelyCreateOriginWithoutNormalization(
37 scheme, host, data.port(), suborigin); 35 scheme, host, data.port(), suborigin);
38 } 36 }
39 37
40 // If a unique origin was created, but the unique flag wasn't set, then 38 // If an opaque origin was created, but the opaque flag wasn't set, then
41 // the values provided to 'UnsafelyCreateOriginWithoutNormalization' were 39 // the values provided to 'UnsafelyCreateOriginWithoutNormalization' were
42 // invalid. 40 // invalid.
43 if (!data.unique() && out->unique()) 41 if (!data.opaque() && out->opaque())
44 return false; 42 return false;
45 43
46 return true; 44 return true;
47 } 45 }
48 }; 46 };
49 47
50 } 48 }
51 49
52 #endif // URL_MOJO_ORIGIN_STRUCT_TRAITS_H_ 50 #endif // URL_MOJO_ORIGIN_STRUCT_TRAITS_H_
OLDNEW
« no previous file with comments | « url/mojo/origin.mojom ('k') | url/mojo/url_gurl_struct_traits_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698