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

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

Issue 1577073005: Add <link rel=preload> onload support for scripts and styles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed adoptPtr 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 2016 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 protected:
26 LinkPreloadResourceClient(LinkLoader* loader)
27 : m_loader(loader)
28 {
29 ASSERT(loader);
30 }
31
32 private:
33 LinkLoader* m_loader;
34 };
35
36 class LinkPreloadScriptResourceClient: public LinkPreloadResourceClient, public ResourceOwner<ScriptResource, ScriptResourceClient> {
37 public:
38 static PassOwnPtr<LinkPreloadScriptResourceClient> create(LinkLoader* 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 private:
52 LinkPreloadScriptResourceClient(LinkLoader* loader, ScriptResource* resource )
53 : LinkPreloadResourceClient(loader)
54 {
55 setResource(resource);
56 }
57 };
58
59 class LinkPreloadStyleResourceClient: public LinkPreloadResourceClient, public R esourceOwner<CSSStyleSheetResource, StyleSheetResourceClient> {
60 public:
61 static PassOwnPtr<LinkPreloadStyleResourceClient> create(LinkLoader* loader, CSSStyleSheetResource* resource)
62 {
63 return adoptPtrWillBeNoop(new LinkPreloadStyleResourceClient(loader, res ource));
64 }
65
66 virtual String debugName() const { return "LinkPreloadStyle"; }
67
68 void setCSSStyleSheet(const String&, const KURL&, const String&, const CSSSt yleSheetResource* resource) override
69 {
70 ASSERT(this->resource() == resource);
71 triggerEvents(static_cast<const Resource*>(resource));
72 }
73
74 private:
75 LinkPreloadStyleResourceClient(LinkLoader* loader, CSSStyleSheetResource* re source)
76 : LinkPreloadResourceClient(loader)
77 {
78 setResource(resource);
79 }
80 };
81
82 }
83
84 #endif // LinkPreloadResourceClients_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698