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

Side by Side Diff: third_party/WebKit/Source/platform/mojo/SecurityOriginStructTraits.h

Issue 2253293002: Mojo C++ bindings: change the first template parameter of StructTraits and UnionTraits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@91_extra
Patch Set: rebase Created 4 years, 3 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 | « third_party/WebKit/Source/platform/mojo/KURLStructTraits.h ('k') | ui/display/display.h » ('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 SecurityOriginStructTraits_h 5 #ifndef SecurityOriginStructTraits_h
6 #define SecurityOriginStructTraits_h 6 #define SecurityOriginStructTraits_h
7 7
8 #include "platform/weborigin/SecurityOrigin.h" 8 #include "platform/weborigin/SecurityOrigin.h"
9 #include "url/mojo/origin.mojom-blink.h" 9 #include "url/mojo/origin.mojom-blink.h"
10 #include "wtf/text/WTFString.h" 10 #include "wtf/text/WTFString.h"
11 11
12 namespace mojo { 12 namespace mojo {
13 13
14 template <> 14 template <>
15 struct StructTraits<url::mojom::blink::Origin, RefPtr<::blink::SecurityOrigin>> { 15 struct StructTraits<url::mojom::blink::Origin::DataView, RefPtr<::blink::Securit yOrigin>> {
16 static WTF::String scheme(const RefPtr<::blink::SecurityOrigin>& origin) 16 static WTF::String scheme(const RefPtr<::blink::SecurityOrigin>& origin)
17 { 17 {
18 return origin->protocol(); 18 return origin->protocol();
19 } 19 }
20 static WTF::String host(const RefPtr<::blink::SecurityOrigin>& origin) 20 static WTF::String host(const RefPtr<::blink::SecurityOrigin>& origin)
21 { 21 {
22 return origin->host(); 22 return origin->host();
23 } 23 }
24 static uint16_t port(const RefPtr<::blink::SecurityOrigin>& origin) 24 static uint16_t port(const RefPtr<::blink::SecurityOrigin>& origin)
25 { 25 {
26 return origin->effectivePort(); 26 return origin->effectivePort();
27 } 27 }
28 static bool unique(const RefPtr<::blink::SecurityOrigin>& origin) 28 static bool unique(const RefPtr<::blink::SecurityOrigin>& origin)
29 { 29 {
30 return origin->isUnique(); 30 return origin->isUnique();
31 } 31 }
32 static bool Read(url::mojom::blink::OriginDataView data, RefPtr<::blink::Sec urityOrigin>* out) 32 static bool Read(url::mojom::blink::Origin::DataView data, RefPtr<::blink::S ecurityOrigin>* out)
33 { 33 {
34 if (data.unique()) { 34 if (data.unique()) {
35 *out = ::blink::SecurityOrigin::createUnique(); 35 *out = ::blink::SecurityOrigin::createUnique();
36 } else { 36 } else {
37 WTF::String scheme; 37 WTF::String scheme;
38 WTF::String host; 38 WTF::String host;
39 if (!data.ReadScheme(&scheme) || !data.ReadHost(&host)) 39 if (!data.ReadScheme(&scheme) || !data.ReadHost(&host))
40 return false; 40 return false;
41 41
42 *out = ::blink::SecurityOrigin::create(scheme, host, data.port()); 42 *out = ::blink::SecurityOrigin::create(scheme, host, data.port());
43 } 43 }
44 44
45 // If a unique origin was created, but the unique flag wasn't set, then 45 // If a unique origin was created, but the unique flag wasn't set, then
46 // the values provided to 'create' were invalid. 46 // the values provided to 'create' were invalid.
47 if (!data.unique() && (*out)->isUnique()) 47 if (!data.unique() && (*out)->isUnique())
48 return false; 48 return false;
49 49
50 return true; 50 return true;
51 } 51 }
52 }; 52 };
53 } 53 }
54 54
55 #endif // SecurityOriginStructTraits_h 55 #endif // SecurityOriginStructTraits_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/mojo/KURLStructTraits.h ('k') | ui/display/display.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698