| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All Rights Reserved. | 2 * Copyright (C) 2013 Google Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef HTMLResourcePreloader_h | 26 #ifndef HTMLResourcePreloader_h |
| 27 #define HTMLResourcePreloader_h | 27 #define HTMLResourcePreloader_h |
| 28 | 28 |
| 29 #include "core/fetch/FetchRequest.h" | 29 #include "core/fetch/FetchRequest.h" |
| 30 #include "core/fetch/Resource.h" | 30 #include "core/fetch/Resource.h" |
| 31 #include "core/html/parser/PreloadRequest.h" |
| 32 #include "core/html/parser/ResourcePreloader.h" |
| 31 #include "wtf/CurrentTime.h" | 33 #include "wtf/CurrentTime.h" |
| 32 #include "wtf/text/TextPosition.h" | 34 #include "wtf/text/TextPosition.h" |
| 33 | 35 |
| 34 namespace blink { | 36 namespace blink { |
| 35 | 37 |
| 36 class Document; | 38 class HTMLResourcePreloader final : public NoBaseWillBeGarbageCollected<HTMLReso
urcePreloader>, public ResourcePreloader { |
| 37 | |
| 38 class PreloadRequest { | |
| 39 public: | |
| 40 static PassOwnPtr<PreloadRequest> create(const String& initiatorName, const
TextPosition& initiatorPosition, const String& resourceURL, const KURL& baseURL,
Resource::Type resourceType, const FetchRequest::ResourceWidth& resourceWidth =
FetchRequest::ResourceWidth()) | |
| 41 { | |
| 42 return adoptPtr(new PreloadRequest(initiatorName, initiatorPosition, res
ourceURL, baseURL, resourceType, resourceWidth)); | |
| 43 } | |
| 44 | |
| 45 bool isSafeToSendToAnotherThread() const; | |
| 46 | |
| 47 FetchRequest resourceRequest(Document*); | |
| 48 | |
| 49 const String& charset() const { return m_charset; } | |
| 50 double discoveryTime() const { return m_discoveryTime; } | |
| 51 void setDefer(FetchRequest::DeferOption defer) { m_defer = defer; } | |
| 52 void setCharset(const String& charset) { m_charset = charset.isolatedCopy();
} | |
| 53 void setCrossOriginEnabled(StoredCredentials allowCredentials) | |
| 54 { | |
| 55 m_isCORSEnabled = true; | |
| 56 m_allowCredentials = allowCredentials; | |
| 57 } | |
| 58 | |
| 59 Resource::Type resourceType() const { return m_resourceType; } | |
| 60 | |
| 61 private: | |
| 62 PreloadRequest(const String& initiatorName, const TextPosition& initiatorPos
ition, const String& resourceURL, const KURL& baseURL, Resource::Type resourceTy
pe, const FetchRequest::ResourceWidth& resourceWidth) | |
| 63 : m_initiatorName(initiatorName) | |
| 64 , m_initiatorPosition(initiatorPosition) | |
| 65 , m_resourceURL(resourceURL.isolatedCopy()) | |
| 66 , m_baseURL(baseURL.copy()) | |
| 67 , m_resourceType(resourceType) | |
| 68 , m_isCORSEnabled(false) | |
| 69 , m_allowCredentials(DoNotAllowStoredCredentials) | |
| 70 , m_discoveryTime(monotonicallyIncreasingTime()) | |
| 71 , m_defer(FetchRequest::NoDefer) | |
| 72 , m_resourceWidth(resourceWidth) | |
| 73 { | |
| 74 } | |
| 75 | |
| 76 KURL completeURL(Document*); | |
| 77 | |
| 78 String m_initiatorName; | |
| 79 TextPosition m_initiatorPosition; | |
| 80 String m_resourceURL; | |
| 81 KURL m_baseURL; | |
| 82 String m_charset; | |
| 83 Resource::Type m_resourceType; | |
| 84 bool m_isCORSEnabled; | |
| 85 StoredCredentials m_allowCredentials; | |
| 86 double m_discoveryTime; | |
| 87 FetchRequest::DeferOption m_defer; | |
| 88 FetchRequest::ResourceWidth m_resourceWidth; | |
| 89 }; | |
| 90 | |
| 91 typedef Vector<OwnPtr<PreloadRequest>> PreloadRequestStream; | |
| 92 | |
| 93 class HTMLResourcePreloader final : public NoBaseWillBeGarbageCollected<HTMLReso
urcePreloader> { | |
| 94 WTF_MAKE_NONCOPYABLE(HTMLResourcePreloader); WTF_MAKE_FAST_ALLOCATED_WILL_BE
_REMOVED(HTMLResourcePreloader); | 39 WTF_MAKE_NONCOPYABLE(HTMLResourcePreloader); WTF_MAKE_FAST_ALLOCATED_WILL_BE
_REMOVED(HTMLResourcePreloader); |
| 95 public: | 40 public: |
| 96 static PassOwnPtrWillBeRawPtr<HTMLResourcePreloader> create(Document&); | 41 static PassOwnPtrWillBeRawPtr<HTMLResourcePreloader> create(Document&); |
| 97 DECLARE_TRACE(); | 42 DECLARE_TRACE(); |
| 98 | 43 |
| 99 void takeAndPreload(PreloadRequestStream&); | 44 protected: |
| 45 virtual void preload(PassOwnPtr<PreloadRequest>) override; |
| 100 | 46 |
| 101 private: | 47 private: |
| 102 explicit HTMLResourcePreloader(Document&); | 48 explicit HTMLResourcePreloader(Document&); |
| 103 | 49 |
| 104 void preload(PassOwnPtr<PreloadRequest>); | |
| 105 | |
| 106 RawPtrWillBeMember<Document> m_document; | 50 RawPtrWillBeMember<Document> m_document; |
| 107 }; | 51 }; |
| 108 | 52 |
| 109 } | 53 } |
| 110 | 54 |
| 111 #endif | 55 #endif |
| OLD | NEW |