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

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

Issue 2834733003: Separate preaload matching from MemoryCache (Closed)
Patch Set: rebase Created 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef PreloadKey_h
6 #define PreloadKey_h
7
8 #include "platform/loader/fetch/Resource.h"
9 #include "platform/weborigin/KURL.h"
10 #include "platform/weborigin/KURLHash.h"
11 #include "platform/wtf/HashTraits.h"
12
13 namespace blink {
14
15 // PreloadKey is a key type of the prealods map in a fetch group (a.k.a.
16 // blink::ResourceFetcher).
17 struct PreloadKey final {
18 public:
19 struct Hash {
20 STATIC_ONLY(Hash);
21
22 public:
23 static unsigned GetHash(const PreloadKey& key) {
24 return KURLHash::GetHash(key.url);
25 }
26 static bool Equal(const PreloadKey& x, const PreloadKey& y) {
27 return x == y;
28 }
29 static constexpr bool safe_to_compare_to_empty_or_deleted = false;
30 };
31
32 PreloadKey() = default;
33 PreloadKey(WTF::HashTableDeletedValueType)
34 : url(WTF::kHashTableDeletedValue) {}
35 PreloadKey(const KURL& url, Resource::Type type)
36 : url(FragmentRemovedUrl(url)), type(type) {}
37
38 bool IsHashTableDeletedValue() const { return url.IsHashTableDeletedValue(); }
39
40 bool operator==(const PreloadKey& x) const {
41 return url == x.url && type == x.type;
42 }
43
44 static KURL FragmentRemovedUrl(const KURL& src) {
Nate Chapin 2017/05/02 00:02:16 RemoveFragmentFromUrl() would be a little clearer.
yhirano 2017/05/02 10:22:17 Done.
45 if (!src.HasFragmentIdentifier())
46 return src;
47 KURL url = src;
48 url.RemoveFragmentIdentifier();
49 return url;
50 }
51
52 KURL url;
53 Resource::Type type = Resource::kMainResource;
54 };
55
56 } // namespace blink
57
58 namespace WTF {
59
60 template <>
61 struct DefaultHash<blink::PreloadKey> {
62 using Hash = blink::PreloadKey::Hash;
63 };
64
65 template <>
66 struct HashTraits<blink::PreloadKey>
67 : public SimpleClassHashTraits<blink::PreloadKey> {};
68
69 } // namespace WTF
70
71 #endif // PreloadKey_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698