Chromium Code Reviews| OLD | NEW |
|---|---|
| (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/FontResource.h" | |
| 9 #include "core/fetch/ImageResourceClient.h" | |
| 10 #include "core/fetch/ResourceOwner.h" | |
| 11 #include "core/fetch/ScriptResource.h" | |
| 12 #include "core/fetch/StyleSheetResourceClient.h" | |
| 13 | |
| 14 namespace blink { | |
| 15 | |
| 16 class LinkLoader; | |
| 17 | |
| 18 class LinkPreloadResourceClient : public NoBaseWillBeGarbageCollectedFinalized<L inkPreloadResourceClient> { | |
| 19 public: | |
| 20 virtual ~LinkPreloadResourceClient() { } | |
| 21 | |
| 22 void triggerEvents(Resource*); | |
| 23 virtual void callSetResource(Resource*) = 0; | |
|
Nate Chapin
2016/01/13 23:52:24
Maybe take the Resource* as a parameter in the var
Yoav Weiss
2016/01/14 10:10:02
good call! :)
| |
| 24 | |
| 25 protected: | |
| 26 LinkPreloadResourceClient(LinkLoader*); | |
| 27 private: | |
| 28 WeakPtr<LinkLoader> m_loader; | |
|
Nate Chapin
2016/01/13 23:52:23
LinkLoader owns LinkPreloadResourceClient. Wouldn'
Yoav Weiss
2016/01/14 10:10:02
true. Previousely left the weakPtr around since th
| |
| 29 }; | |
| 30 | |
| 31 class LinkPreloadScriptResourceClient: public ResourceOwner<Resource, ScriptReso urceClient>, public LinkPreloadResourceClient { | |
|
Nate Chapin
2016/01/13 23:52:23
Here and below: If I understand oilpan correctly,
Yoav Weiss
2016/01/14 10:10:02
ok
| |
| 32 public: | |
| 33 static PassOwnPtr<LinkPreloadScriptResourceClient> create(LinkLoader* loader ) | |
| 34 { | |
| 35 return adoptPtr(new LinkPreloadScriptResourceClient(loader)); | |
| 36 } | |
| 37 | |
| 38 ~LinkPreloadScriptResourceClient() override { clearResource(); } | |
| 39 | |
| 40 virtual String debugName() const { return "LinkPreloadScript"; } | |
| 41 | |
| 42 void notifyFinished(Resource* resource) override | |
| 43 { | |
| 44 triggerEvents(resource); | |
| 45 clearResource(); | |
|
Nate Chapin
2016/01/13 23:52:24
Why does notifyFinished() call clearResource() in
Yoav Weiss
2016/01/14 10:10:02
leftover. Apologies.
| |
| 46 } | |
| 47 | |
| 48 void callSetResource(Resource* resource) | |
| 49 { | |
| 50 setResource(resource); | |
| 51 } | |
| 52 | |
| 53 private: | |
| 54 LinkPreloadScriptResourceClient(LinkLoader* loader) | |
| 55 : LinkPreloadResourceClient(loader) | |
| 56 { | |
| 57 } | |
| 58 }; | |
| 59 | |
| 60 class LinkPreloadStyleResourceClient: public ResourceOwner<Resource, StyleSheetR esourceClient>, public LinkPreloadResourceClient { | |
| 61 public: | |
| 62 static PassOwnPtr<LinkPreloadStyleResourceClient> create(LinkLoader* loader) | |
| 63 { | |
| 64 return adoptPtr(new LinkPreloadStyleResourceClient(loader)); | |
| 65 } | |
| 66 | |
| 67 virtual String debugName() const { return "LinkPreloadStyle"; } | |
| 68 | |
| 69 void notifyFinished(Resource* resource) override | |
| 70 { | |
| 71 triggerEvents(resource); | |
| 72 } | |
| 73 | |
| 74 void callSetResource(Resource* resource) | |
| 75 { | |
| 76 setResource(resource); | |
| 77 } | |
| 78 | |
| 79 private: | |
| 80 LinkPreloadStyleResourceClient(LinkLoader* loader) | |
| 81 : LinkPreloadResourceClient(loader) | |
| 82 { | |
| 83 } | |
| 84 }; | |
| 85 | |
| 86 class LinkPreloadImageResourceClient: public ResourceOwner<Resource, ImageResour ceClient>, public LinkPreloadResourceClient { | |
| 87 public: | |
| 88 static PassOwnPtr<LinkPreloadImageResourceClient> create(LinkLoader* loader) | |
| 89 { | |
| 90 return adoptPtr(new LinkPreloadImageResourceClient(loader)); | |
| 91 } | |
| 92 | |
| 93 virtual String debugName() const { return "LinkPreloadImage"; } | |
| 94 | |
| 95 void notifyFinished(Resource* resource) override | |
| 96 { | |
| 97 triggerEvents(resource); | |
| 98 } | |
| 99 | |
| 100 void callSetResource(Resource* resource) | |
| 101 { | |
| 102 setResource(resource); | |
| 103 } | |
| 104 | |
| 105 private: | |
| 106 LinkPreloadImageResourceClient(LinkLoader* loader) | |
| 107 : LinkPreloadResourceClient(loader) | |
| 108 { | |
| 109 } | |
| 110 }; | |
| 111 | |
| 112 } | |
| 113 | |
| 114 #endif // LinkPreloadResourceClients_h | |
| OLD | NEW |