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

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

Issue 1586563014: Add <link rel=preload> onload support for scripts and styles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: oilpan build fixes and review comments 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
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
sof 2016/01/20 13:22:41 off by one :)
Yoav Weiss 2016/01/20 13:28:05 thinking ahead :)
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;
sof 2016/01/20 13:16:15 (odd-looking const method)
Yoav Weiss 2016/01/20 13:28:05 removed the const part as it's not necessary.
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 ResourceOwner<ScriptResource, Scri ptResourceClient>, public LinkPreloadResourceClient {
sof 2016/01/20 13:16:15 LinkPreloadResourceClient needs to be the leftmost
Yoav Weiss 2016/01/20 13:28:05 switched order
42 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(LinkPreloadScriptResourceClient);
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 ResourceOwner<CSSStyleSheetResource , StyleSheetResourceClient>, public LinkPreloadResourceClient {
sof 2016/01/20 13:16:15 ditto
Yoav Weiss 2016/01/20 13:28:05 switched order
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698