OLD | NEW |
---|---|
(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. | |
kinuko
2017/05/15 02:09:04
prealods -> preloads
Here, in the issue title and
yhirano
2017/05/16 11:19:24
Done.
| |
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(RemoveFragmentFromUrl(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 RemoveFragmentFromUrl(const KURL& src) { | |
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 | |
OLD | NEW |