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

Side by Side Diff: third_party/WebKit/Source/core/loader/LinkPreloadResourceClients.h

Issue 1615703002: Removal of rel=preload link elements should stop the download. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added back clear() Created 4 years, 11 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
« no previous file with comments | « third_party/WebKit/Source/core/loader/LinkLoader.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef LinkPreloadResourceClients_h 5 #ifndef LinkPreloadResourceClients_h
6 #define LinkPreloadResourceClients_h 6 #define LinkPreloadResourceClients_h
7 7
8 #include "core/fetch/CSSStyleSheetResource.h" 8 #include "core/fetch/CSSStyleSheetResource.h"
9 #include "core/fetch/FontResource.h" 9 #include "core/fetch/FontResource.h"
10 #include "core/fetch/ImageResourceClient.h" 10 #include "core/fetch/ImageResourceClient.h"
11 #include "core/fetch/ResourceLoader.h"
11 #include "core/fetch/ResourceOwner.h" 12 #include "core/fetch/ResourceOwner.h"
12 #include "core/fetch/ScriptResource.h" 13 #include "core/fetch/ScriptResource.h"
13 #include "core/fetch/StyleSheetResourceClient.h" 14 #include "core/fetch/StyleSheetResourceClient.h"
14 15
15 namespace blink { 16 namespace blink {
16 17
17 class LinkLoader; 18 class LinkLoader;
18 19
19 class LinkPreloadResourceClient : public NoBaseWillBeGarbageCollectedFinalized<L inkPreloadResourceClient> { 20 class LinkPreloadResourceClient : public NoBaseWillBeGarbageCollectedFinalized<L inkPreloadResourceClient> {
20 public: 21 public:
21 virtual ~LinkPreloadResourceClient() { } 22 virtual ~LinkPreloadResourceClient() { }
22 23
23 void triggerEvents(const Resource*); 24 void triggerEvents(const Resource*);
25 virtual void clear() = 0;
24 26
25 DEFINE_INLINE_VIRTUAL_TRACE() 27 DEFINE_INLINE_VIRTUAL_TRACE()
26 { 28 {
27 visitor->trace(m_loader); 29 visitor->trace(m_loader);
28 } 30 }
29 31
30 protected: 32 protected:
31 LinkPreloadResourceClient(LinkLoader* loader) 33 LinkPreloadResourceClient(LinkLoader* loader)
32 : m_loader(loader) 34 : m_loader(loader)
33 { 35 {
34 ASSERT(loader); 36 ASSERT(loader);
35 } 37 }
36 38
37 private: 39 private:
38 RawPtrWillBeMember<LinkLoader> m_loader; 40 RawPtrWillBeMember<LinkLoader> m_loader;
39 }; 41 };
40 42
41 class LinkPreloadScriptResourceClient: public LinkPreloadResourceClient, public ResourceOwner<ScriptResource, ScriptResourceClient> { 43 class LinkPreloadScriptResourceClient: public LinkPreloadResourceClient, public ResourceOwner<ScriptResource, ScriptResourceClient> {
42 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(LinkPreloadScriptResourceClient); 44 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(LinkPreloadScriptResourceClient);
43 USING_FAST_MALLOC_WILL_BE_REMOVED(LinkPreloadScriptResourceClient); 45 USING_FAST_MALLOC_WILL_BE_REMOVED(LinkPreloadScriptResourceClient);
44 public: 46 public:
45 static PassOwnPtrWillBeRawPtr<LinkPreloadScriptResourceClient> create(LinkLo ader* loader, ScriptResource* resource) 47 static PassOwnPtrWillBeRawPtr<LinkPreloadScriptResourceClient> create(LinkLo ader* loader, ScriptResource* resource)
46 { 48 {
47 return adoptPtrWillBeNoop(new LinkPreloadScriptResourceClient(loader, re source)); 49 return adoptPtrWillBeNoop(new LinkPreloadScriptResourceClient(loader, re source));
48 } 50 }
49 51
50 virtual String debugName() const { return "LinkPreloadScript"; } 52 virtual String debugName() const { return "LinkPreloadScript"; }
53 virtual ~LinkPreloadScriptResourceClient() { }
54
55 void clear() override { clearResource(); }
51 56
52 void notifyFinished(Resource* resource) override 57 void notifyFinished(Resource* resource) override
53 { 58 {
54 ASSERT(this->resource() == resource); 59 ASSERT(this->resource() == resource);
55 triggerEvents(resource); 60 triggerEvents(resource);
56 } 61 }
57 62
58 DEFINE_INLINE_VIRTUAL_TRACE() 63 DEFINE_INLINE_VIRTUAL_TRACE()
59 { 64 {
60 LinkPreloadResourceClient::trace(visitor); 65 LinkPreloadResourceClient::trace(visitor);
(...skipping 11 matching lines...) Expand all
72 class LinkPreloadStyleResourceClient: public LinkPreloadResourceClient, public R esourceOwner<CSSStyleSheetResource, StyleSheetResourceClient> { 77 class LinkPreloadStyleResourceClient: public LinkPreloadResourceClient, public R esourceOwner<CSSStyleSheetResource, StyleSheetResourceClient> {
73 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(LinkPreloadStyleResourceClient); 78 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(LinkPreloadStyleResourceClient);
74 USING_FAST_MALLOC_WILL_BE_REMOVED(LinkPreloadStyleResourceClient); 79 USING_FAST_MALLOC_WILL_BE_REMOVED(LinkPreloadStyleResourceClient);
75 public: 80 public:
76 static PassOwnPtrWillBeRawPtr<LinkPreloadStyleResourceClient> create(LinkLoa der* loader, CSSStyleSheetResource* resource) 81 static PassOwnPtrWillBeRawPtr<LinkPreloadStyleResourceClient> create(LinkLoa der* loader, CSSStyleSheetResource* resource)
77 { 82 {
78 return adoptPtrWillBeNoop(new LinkPreloadStyleResourceClient(loader, res ource)); 83 return adoptPtrWillBeNoop(new LinkPreloadStyleResourceClient(loader, res ource));
79 } 84 }
80 85
81 virtual String debugName() const { return "LinkPreloadStyle"; } 86 virtual String debugName() const { return "LinkPreloadStyle"; }
87 virtual ~LinkPreloadStyleResourceClient() { }
88
89 void clear() override { clearResource(); }
82 90
83 void setCSSStyleSheet(const String&, const KURL&, const String&, const CSSSt yleSheetResource* resource) override 91 void setCSSStyleSheet(const String&, const KURL&, const String&, const CSSSt yleSheetResource* resource) override
84 { 92 {
85 ASSERT(this->resource() == resource); 93 ASSERT(this->resource() == resource);
86 triggerEvents(static_cast<const Resource*>(resource)); 94 triggerEvents(static_cast<const Resource*>(resource));
87 } 95 }
88 96
89 DEFINE_INLINE_VIRTUAL_TRACE() 97 DEFINE_INLINE_VIRTUAL_TRACE()
90 { 98 {
91 LinkPreloadResourceClient::trace(visitor); 99 LinkPreloadResourceClient::trace(visitor);
92 ResourceOwner<CSSStyleSheetResource, StyleSheetResourceClient>::trace(vi sitor); 100 ResourceOwner<CSSStyleSheetResource, StyleSheetResourceClient>::trace(vi sitor);
93 } 101 }
94 102
95 private: 103 private:
96 LinkPreloadStyleResourceClient(LinkLoader* loader, CSSStyleSheetResource* re source) 104 LinkPreloadStyleResourceClient(LinkLoader* loader, CSSStyleSheetResource* re source)
97 : LinkPreloadResourceClient(loader) 105 : LinkPreloadResourceClient(loader)
98 { 106 {
99 setResource(resource); 107 setResource(resource);
100 } 108 }
101 }; 109 };
102 110
103 } 111 }
104 112
105 #endif // LinkPreloadResourceClients_h 113 #endif // LinkPreloadResourceClients_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/LinkLoader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698