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/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*); |
| 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); |
| 43 USING_FAST_MALLOC_WILL_BE_REMOVED(LinkPreloadScriptResourceClient); |
| 44 public: |
| 45 static PassOwnPtrWillBeRawPtr<LinkPreloadScriptResourceClient> create(LinkLo
ader* loader, ScriptResource* resource) |
| 46 { |
| 47 return adoptPtrWillBeNoop(new LinkPreloadScriptResourceClient(loader, re
source)); |
| 48 } |
| 49 |
| 50 virtual String debugName() const { return "LinkPreloadScript"; } |
| 51 |
| 52 void notifyFinished(Resource* resource) override |
| 53 { |
| 54 ASSERT(this->resource() == resource); |
| 55 triggerEvents(resource); |
| 56 } |
| 57 |
| 58 DEFINE_INLINE_VIRTUAL_TRACE() |
| 59 { |
| 60 LinkPreloadResourceClient::trace(visitor); |
| 61 ResourceOwner<ScriptResource, ScriptResourceClient>::trace(visitor); |
| 62 } |
| 63 |
| 64 private: |
| 65 LinkPreloadScriptResourceClient(LinkLoader* loader, ScriptResource* resource
) |
| 66 : LinkPreloadResourceClient(loader) |
| 67 { |
| 68 setResource(resource); |
| 69 } |
| 70 }; |
| 71 |
| 72 class LinkPreloadStyleResourceClient: public LinkPreloadResourceClient, public R
esourceOwner<CSSStyleSheetResource, StyleSheetResourceClient> { |
| 73 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(LinkPreloadStyleResourceClient); |
| 74 USING_FAST_MALLOC_WILL_BE_REMOVED(LinkPreloadStyleResourceClient); |
| 75 public: |
| 76 static PassOwnPtrWillBeRawPtr<LinkPreloadStyleResourceClient> create(LinkLoa
der* loader, CSSStyleSheetResource* resource) |
| 77 { |
| 78 return adoptPtrWillBeNoop(new LinkPreloadStyleResourceClient(loader, res
ource)); |
| 79 } |
| 80 |
| 81 virtual String debugName() const { return "LinkPreloadStyle"; } |
| 82 |
| 83 void setCSSStyleSheet(const String&, const KURL&, const String&, const CSSSt
yleSheetResource* resource) override |
| 84 { |
| 85 ASSERT(this->resource() == resource); |
| 86 triggerEvents(static_cast<const Resource*>(resource)); |
| 87 } |
| 88 |
| 89 DEFINE_INLINE_VIRTUAL_TRACE() |
| 90 { |
| 91 LinkPreloadResourceClient::trace(visitor); |
| 92 ResourceOwner<CSSStyleSheetResource, StyleSheetResourceClient>::trace(vi
sitor); |
| 93 } |
| 94 |
| 95 private: |
| 96 LinkPreloadStyleResourceClient(LinkLoader* loader, CSSStyleSheetResource* re
source) |
| 97 : LinkPreloadResourceClient(loader) |
| 98 { |
| 99 setResource(resource); |
| 100 } |
| 101 }; |
| 102 |
| 103 } |
| 104 |
| 105 #endif // LinkPreloadResourceClients_h |
OLD | NEW |