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 { | |
sof
2016/01/20 12:22:53
Since this contains a heap reference, you need to
Yoav Weiss
2016/01/20 13:14:01
Had to define it as NoBaseWillBeGarbageCollectedFi
| |
20 public: | |
21 virtual ~LinkPreloadResourceClient() { } | |
22 | |
23 void triggerEvents(const Resource*) const; | |
24 | |
25 protected: | |
26 LinkPreloadResourceClient(LinkLoader* loader) | |
27 : m_loader(loader) | |
28 { | |
29 ASSERT(loader); | |
30 } | |
31 | |
32 private: | |
33 LinkLoader* m_loader; | |
sof
2016/01/20 12:22:53
RawPtrWillBeMember<LinkLoader>
Yoav Weiss
2016/01/20 13:14:01
done
| |
34 }; | |
35 | |
36 class LinkPreloadScriptResourceClient: public ResourceOwner<ScriptResource, Scri ptResourceClient>, public LinkPreloadResourceClient { | |
37 public: | |
38 static PassOwnPtrWillBeRawPtr<LinkPreloadScriptResourceClient> create(LinkLo ader* loader, ScriptResource* resource) | |
39 { | |
40 return adoptPtrWillBeNoop(new LinkPreloadScriptResourceClient(loader, re source)); | |
41 } | |
42 | |
43 virtual String debugName() const { return "LinkPreloadScript"; } | |
44 | |
45 void notifyFinished(Resource* resource) override | |
46 { | |
47 ASSERT(this->resource() == resource); | |
48 triggerEvents(resource); | |
49 } | |
50 | |
51 DEFINE_INLINE_VIRTUAL_TRACE() | |
52 { | |
53 ResourceOwner<ScriptResource, ScriptResourceClient>::trace(visitor); | |
54 } | |
55 | |
56 private: | |
57 LinkPreloadScriptResourceClient(LinkLoader* loader, ScriptResource* resource ) | |
58 : LinkPreloadResourceClient(loader) | |
59 { | |
60 setResource(resource); | |
61 } | |
62 }; | |
63 | |
64 class LinkPreloadStyleResourceClient: public ResourceOwner<CSSStyleSheetResource , StyleSheetResourceClient>, public LinkPreloadResourceClient { | |
65 public: | |
66 static PassOwnPtrWillBeRawPtr<LinkPreloadStyleResourceClient> create(LinkLoa der* loader, CSSStyleSheetResource* resource) | |
67 { | |
68 return adoptPtrWillBeNoop(new LinkPreloadStyleResourceClient(loader, res ource)); | |
69 } | |
70 | |
71 virtual String debugName() const { return "LinkPreloadStyle"; } | |
72 | |
73 void setCSSStyleSheet(const String&, const KURL&, const String&, const CSSSt yleSheetResource* resource) override | |
74 { | |
75 ASSERT(this->resource() == resource); | |
76 triggerEvents(static_cast<const Resource*>(resource)); | |
77 } | |
78 | |
79 DEFINE_INLINE_VIRTUAL_TRACE() | |
80 { | |
81 ResourceOwner<CSSStyleSheetResource, StyleSheetResourceClient>::trace(vi sitor); | |
82 } | |
83 | |
84 private: | |
85 LinkPreloadStyleResourceClient(LinkLoader* loader, CSSStyleSheetResource* re source) | |
86 : LinkPreloadResourceClient(loader) | |
87 { | |
88 setResource(resource); | |
89 } | |
90 }; | |
91 | |
92 } | |
93 | |
94 #endif // LinkPreloadResourceClients_h | |
OLD | NEW |