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

Unified Diff: third_party/WebKit/Source/platform/mojo/ReferrerStructTraits.h

Issue 2762303002: Enable transmitting Fetch Requests over Mojo (Closed)
Patch Set: Enable transmitting Fetch Requests over Mojo Created 3 years, 9 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: third_party/WebKit/Source/platform/mojo/ReferrerStructTraits.h
diff --git a/third_party/WebKit/Source/platform/mojo/ReferrerStructTraits.h b/third_party/WebKit/Source/platform/mojo/ReferrerStructTraits.h
new file mode 100644
index 0000000000000000000000000000000000000000..9d251c06f641fc8ccd54c045bfda083020499f84
--- /dev/null
+++ b/third_party/WebKit/Source/platform/mojo/ReferrerStructTraits.h
@@ -0,0 +1,46 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ReferrerStructTraits_h
+#define ReferrerStructTraits_h
+
+#include "platform/weborigin/Referrer.h"
+#include "platform/weborigin/ReferrerPolicy.h"
+#include "public/platform/ReferrerPolicyEnumTraits.h"
+#include "public/platform/WebReferrerPolicy.h"
+#include "wtf/Assertions.h"
+
+namespace mojo {
+
+template <>
+struct StructTraits<blink::mojom::ReferrerDataView, blink::Referrer> {
+ static blink::KURL url(const blink::Referrer& referrer) {
+ if (referrer.referrer == blink::Referrer::noReferrer())
+ return blink::KURL();
+
+ return blink::KURL(blink::KURL(), referrer.referrer);
+ }
+
+ // Equality of values is asserted in //Source/web/AssertMatchingEnums.cpp.
+ static blink::WebReferrerPolicy policy(const blink::Referrer& referrer) {
+ return static_cast<blink::WebReferrerPolicy>(referrer.referrerPolicy);
+ }
+
+ static bool Read(blink::mojom::ReferrerDataView data, blink::Referrer* out) {
+ blink::KURL referrer;
+ blink::WebReferrerPolicy webReferrerPolicy;
+ if (!data.ReadUrl(&referrer) || !data.ReadPolicy(&webReferrerPolicy))
+ return false;
+
+ out->referrerPolicy = static_cast<blink::ReferrerPolicy>(webReferrerPolicy);
+ out->referrer = AtomicString(referrer.getString());
+
+ // Mimics the ASSERT() done in the blink::Referrer constructor.
+ return referrer.isValid() || out->referrer == blink::Referrer::noReferrer();
+ }
+};
+
+} // namespace mojo
+
+#endif // ReferrerStructTraits_h
« no previous file with comments | « third_party/WebKit/Source/platform/mojo/Referrer.typemap ('k') | third_party/WebKit/Source/platform/mojo/blink_typemaps.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698