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; |