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

Unified Diff: url/mojo/origin_struct_traits.h

Issue 1966933002: Mojo C++ bindings: switch the existing usage of StructTraits to use the new data view interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@26_reader
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: url/mojo/origin_struct_traits.h
diff --git a/url/mojo/origin_struct_traits.h b/url/mojo/origin_struct_traits.h
index 1d28c877db9075b6a68813781c2206326ebe4e6d..cbcd9953944ca09bdc5e8245bc8852c4cb56cd4f 100644
--- a/url/mojo/origin_struct_traits.h
+++ b/url/mojo/origin_struct_traits.h
@@ -25,15 +25,27 @@ struct StructTraits<url::mojom::Origin, url::Origin> {
static bool unique(const url::Origin& r) {
return r.unique();
}
- static bool Read(url::mojom::Origin::Reader r, url::Origin* out) {
- *out = r.unique() ? url::Origin()
- : url::Origin::UnsafelyCreateOriginWithoutNormalization(
- r.scheme(), r.host(), r.port());
+ static bool Read(url::mojom::OriginDataView data, url::Origin* out) {
+ if (data.is_null()) {
dcheng 2016/05/11 18:04:22 Why/when would data be null? Why do we consider th
yzshen1 2016/05/11 18:18:25 Imagine we have a mojo interface like this: inter
+ *out = url::Origin();
+ return true;
+ }
+
+ if (data.unique()) {
+ *out = url::Origin();
+ } else {
+ base::StringPiece scheme, host;
+ if (!data.ReadScheme(&scheme) || !data.ReadHost(&host))
+ return false;
+
+ *out = url::Origin::UnsafelyCreateOriginWithoutNormalization(scheme, host,
+ data.port());
+ }
// If a unique origin was created, but the unique flag wasn't set, then
// the values provided to 'UnsafelyCreateOriginWithoutNormalization' were
// invalid.
- if (!r.unique() && out->unique())
+ if (!data.unique() && out->unique())
return false;
return true;
« no previous file with comments | « mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl ('k') | url/mojo/url_gurl_struct_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698