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

Unified Diff: third_party/WebKit/Source/platform/loader/fetch/PreloadKey.h

Issue 2834733003: Separate preaload matching from MemoryCache (Closed)
Patch Set: fix Created 3 years, 8 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/loader/fetch/PreloadKey.h
diff --git a/third_party/WebKit/Source/platform/loader/fetch/PreloadKey.h b/third_party/WebKit/Source/platform/loader/fetch/PreloadKey.h
new file mode 100644
index 0000000000000000000000000000000000000000..189f72adab9986be6d2736a8570fbc4579a034f2
--- /dev/null
+++ b/third_party/WebKit/Source/platform/loader/fetch/PreloadKey.h
@@ -0,0 +1,71 @@
+// 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 PreloadKey_h
+#define PreloadKey_h
+
+#include "platform/loader/fetch/Resource.h"
+#include "platform/weborigin/KURL.h"
+#include "platform/weborigin/KURLHash.h"
+#include "platform/wtf/HashTraits.h"
+
+namespace blink {
+
+// PreloadKey is a key type of the prealods map in a fetch group (a.k.a.
+// blink::ResourceFetcher).
+struct PreloadKey final {
+ public:
+ struct Hash {
+ STATIC_ONLY(Hash);
+
+ public:
+ static unsigned GetHash(const PreloadKey& key) {
+ return KURLHash::GetHash(key.url);
+ }
+ static bool Equal(const PreloadKey& x, const PreloadKey& y) {
+ return x == y;
+ }
+ static constexpr bool safe_to_compare_to_empty_or_deleted = false;
+ };
+
+ PreloadKey() = default;
+ PreloadKey(WTF::HashTableDeletedValueType)
+ : url(WTF::kHashTableDeletedValue) {}
+ PreloadKey(const KURL& url, Resource::Type type)
+ : url(RemoveFragmentFromUrl(url)), type(type) {}
+
+ bool IsHashTableDeletedValue() const { return url.IsHashTableDeletedValue(); }
+
+ bool operator==(const PreloadKey& x) const {
+ return url == x.url && type == x.type;
+ }
+
+ static KURL RemoveFragmentFromUrl(const KURL& src) {
+ if (!src.HasFragmentIdentifier())
+ return src;
+ KURL url = src;
+ url.RemoveFragmentIdentifier();
+ return url;
+ }
+
+ KURL url;
+ Resource::Type type = Resource::kMainResource;
+};
+
+} // namespace blink
+
+namespace WTF {
+
+template <>
+struct DefaultHash<blink::PreloadKey> {
+ using Hash = blink::PreloadKey::Hash;
+};
+
+template <>
+struct HashTraits<blink::PreloadKey>
+ : public SimpleClassHashTraits<blink::PreloadKey> {};
+
+} // namespace WTF
+
+#endif // PreloadKey_h
« no previous file with comments | « third_party/WebKit/Source/platform/loader/BUILD.gn ('k') | third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698