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

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

Issue 2000253006: Implement URL and Origin typemaps/struct traits for blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 6 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SecurityOriginStructTraits_h
6 #define SecurityOriginStructTraits_h
7
8 #include "platform/weborigin/SecurityOrigin.h"
9 #include "url/mojo/origin.mojom-blink.h"
10
11 namespace mojo {
12
13 template <>
14 struct StructTraits<url::mojom::blink::Origin, RefPtr<::blink::SecurityOrigin>> {
15 static WTF::String scheme(const RefPtr<::blink::SecurityOrigin>& r)
esprehn 2016/05/25 17:06:27 ditto, don't use single letter vars
Marijn Kruisselbrink 2016/05/25 17:35:08 Fixed
16 {
17 return r->protocol();
18 }
19 static WTF::String host(const RefPtr<::blink::SecurityOrigin>& r)
20 {
21 return r->host();
22 }
23 static uint16_t port(const RefPtr<::blink::SecurityOrigin>& r)
24 {
25 return r->port();
26 }
27 static bool unique(const RefPtr<::blink::SecurityOrigin>& r)
28 {
29 return r->isUnique();
30 }
31 static bool Read(url::mojom::blink::OriginDataView data, RefPtr<::blink::Sec urityOrigin>* out)
32 {
33 if (data.unique()) {
34 *out = ::blink::SecurityOrigin::createUnique();
35 } else {
36 WTF::String scheme, host;
esprehn 2016/05/25 17:06:27 one line per var
Marijn Kruisselbrink 2016/05/25 17:35:08 Fixed
37 if (!data.ReadScheme(&scheme) || !data.ReadHost(&host))
38 return false;
39
40 *out = ::blink::SecurityOrigin::create(scheme, host, data.port());
41 }
42
43 // If a unique origin was created, but the unique flag wasn't set, then
44 // the values provided to 'create' were invalid.
45 if (!data.unique() && (*out)->isUnique())
esprehn 2016/05/25 17:06:27 does the contract for these say it's okay to still
Marijn Kruisselbrink 2016/05/25 17:35:08 Documented at https://www.chromium.org/developers/
46 return false;
47
48 return true;
49 }
50 };
51 }
52
53 #endif // SecurityOriginStructTraits_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698