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 LinkPreloadResourceClients_h | |
6 #define LinkPreloadResourceClients_h | |
7 | |
8 #include "core/fetch/CSSStyleSheetResource.h" | |
9 #include "core/fetch/FontResource.h" | |
10 #include "core/fetch/ImageResourceClient.h" | |
11 #include "core/fetch/ResourceOwner.h" | |
12 #include "core/fetch/ScriptResource.h" | |
13 #include "core/fetch/StyleSheetResourceClient.h" | |
14 | |
15 namespace blink { | |
16 | |
17 class LinkLoader; | |
18 | |
19 class LinkPreloadResourceClient : public NoBaseWillBeGarbageCollectedFinalized<L inkPreloadResourceClient> { | |
20 public: | |
21 virtual ~LinkPreloadResourceClient() { } | |
22 | |
23 void triggerEvents(const Resource*) const; | |
24 | |
25 DEFINE_INLINE_VIRTUAL_TRACE() | |
26 { | |
27 visitor->trace(m_loader); | |
28 } | |
29 | |
30 protected: | |
31 LinkPreloadResourceClient(LinkLoader* loader) | |
32 : m_loader(loader) | |
33 { | |
34 ASSERT(loader); | |
35 } | |
36 | |
37 private: | |
38 RawPtrWillBeMember<LinkLoader> m_loader; | |
39 }; | |
40 | |
41 class LinkPreloadScriptResourceClient: public LinkPreloadResourceClient, public ResourceOwner<ScriptResource, ScriptResourceClient> { | |
42 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(LinkPreloadScriptResourceClient); | |
sof
2016/01/20 13:22:41
Add USING_FAST_MALLOC_WILL_BE_REMOVED(..) on this
Yoav Weiss
2016/01/20 13:28:05
Added
| |
43 public: | |
44 static PassOwnPtrWillBeRawPtr<LinkPreloadScriptResourceClient> create(LinkLo ader* loader, ScriptResource* resource) | |
45 { | |
46 return adoptPtrWillBeNoop(new LinkPreloadScriptResourceClient(loader, re source)); | |
47 } | |
48 | |
49 virtual String debugName() const { return "LinkPreloadScript"; } | |
50 | |
51 void notifyFinished(Resource* resource) override | |
52 { | |
53 ASSERT(this->resource() == resource); | |
54 triggerEvents(resource); | |
55 } | |
56 | |
57 DEFINE_INLINE_VIRTUAL_TRACE() | |
58 { | |
59 LinkPreloadResourceClient::trace(visitor); | |
60 ResourceOwner<ScriptResource, ScriptResourceClient>::trace(visitor); | |
61 } | |
62 | |
63 private: | |
64 LinkPreloadScriptResourceClient(LinkLoader* loader, ScriptResource* resource ) | |
65 : LinkPreloadResourceClient(loader) | |
66 { | |
67 setResource(resource); | |
68 } | |
69 }; | |
70 | |
71 class LinkPreloadStyleResourceClient: public LinkPreloadResourceClient, public R esourceOwner<CSSStyleSheetResource, StyleSheetResourceClient> { | |
72 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(LinkPreloadStyleResourceClient); | |
73 public: | |
74 static PassOwnPtrWillBeRawPtr<LinkPreloadStyleResourceClient> create(LinkLoa der* loader, CSSStyleSheetResource* resource) | |
75 { | |
76 return adoptPtrWillBeNoop(new LinkPreloadStyleResourceClient(loader, res ource)); | |
77 } | |
78 | |
79 virtual String debugName() const { return "LinkPreloadStyle"; } | |
80 | |
81 void setCSSStyleSheet(const String&, const KURL&, const String&, const CSSSt yleSheetResource* resource) override | |
82 { | |
83 ASSERT(this->resource() == resource); | |
84 triggerEvents(static_cast<const Resource*>(resource)); | |
85 } | |
86 | |
87 DEFINE_INLINE_VIRTUAL_TRACE() | |
88 { | |
89 LinkPreloadResourceClient::trace(visitor); | |
90 ResourceOwner<CSSStyleSheetResource, StyleSheetResourceClient>::trace(vi sitor); | |
91 } | |
92 | |
93 private: | |
94 LinkPreloadStyleResourceClient(LinkLoader* loader, CSSStyleSheetResource* re source) | |
95 : LinkPreloadResourceClient(loader) | |
96 { | |
97 setResource(resource); | |
98 } | |
99 }; | |
100 | |
101 } | |
102 | |
103 #endif // LinkPreloadResourceClients_h | |
OLD | NEW |