[go: nahoru, domu]

Change origin.mojom to use url::Origin::Nonce for serializing opaque origins.

This CL is part of adding precursor origin support to url::Origin which
nick@ started in https://crrev.com/c/1028985. It changes the Mojo
representation of url::Origin to use the nonce as an indicator for
whether the origin is opaque or not instead of keeping a boolean.

Bug: 882053
Cq-Include-Trybots: luci.chromium.try:linux_mojo
Change-Id: If260a09a66cf62b870f15d52f5aabc27a3f73823
Reviewed-on: https://chromium-review.googlesource.com/1227393
Commit-Queue: Nasko Oskov <nasko@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Balazs Engedy <engedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594911}
diff --git a/url/origin.h b/url/origin.h
index 5306803..4e1d349 100644
--- a/url/origin.h
+++ b/url/origin.h
@@ -15,6 +15,7 @@
 #include "base/strings/string_piece.h"
 #include "base/strings/string_util.h"
 #include "base/unguessable_token.h"
+#include "ipc/ipc_param_traits.h"
 #include "url/scheme_host_port.h"
 #include "url/third_party/mozilla/url_parse.h"
 #include "url/url_canon.h"
@@ -28,8 +29,17 @@
 struct FuzzTraits;
 }  // namespace ipc_fuzzer
 
+namespace mojo {
+template <typename DataViewType, typename T>
+struct StructTraits;
+}  // namespace mojo
+
 namespace url {
 
+namespace mojom {
+class OriginDataView;
+}  // namespace mojom
+
 // Per https://html.spec.whatwg.org/multipage/origin.html#origin, an origin is
 // either:
 // - a tuple origin of (scheme, host, port) as described in RFC 6454.
@@ -245,7 +255,9 @@
 
  private:
   friend class OriginTest;
+  friend IPC::ParamTraits<url::Origin>;
   friend struct ipc_fuzzer::FuzzTraits<Origin>;
+  friend struct mojo::StructTraits<url::mojom::OriginDataView, url::Origin>;
   friend URL_EXPORT std::ostream& operator<<(std::ostream& out,
                                              const Origin& origin);