| OLD | NEW |
| 1 /* | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 * Copyright (C) 2013 Google Inc. All Rights Reserved. | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 * | 3 // found in the LICENSE file. |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * 1. Redistributions of source code must retain the above copyright | |
| 8 * notice, this list of conditions and the following disclaimer. | |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer in the | |
| 11 * documentation and/or other materials provided with the distribution. | |
| 12 * | |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 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. | |
| 24 */ | |
| 25 | 4 |
| 26 #ifndef HTMLResourcePreloader_h | 5 #ifndef PreloadRequest_h |
| 27 #define HTMLResourcePreloader_h | 6 #define PreloadRequest_h |
| 28 | 7 |
| 29 #include "core/fetch/FetchRequest.h" | 8 #include "core/fetch/FetchRequest.h" |
| 30 #include "core/fetch/Resource.h" | 9 #include "core/fetch/Resource.h" |
| 31 #include "wtf/CurrentTime.h" | |
| 32 #include "wtf/text/TextPosition.h" | 10 #include "wtf/text/TextPosition.h" |
| 33 | 11 |
| 34 namespace blink { | 12 namespace blink { |
| 35 | 13 |
| 36 class Document; | 14 class Document; |
| 37 | 15 |
| 38 class PreloadRequest { | 16 class PreloadRequest { |
| 39 public: | 17 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()) | 18 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 { | 19 { |
| 42 return adoptPtr(new PreloadRequest(initiatorName, initiatorPosition, res
ourceURL, baseURL, resourceType, resourceWidth)); | 20 return adoptPtr(new PreloadRequest(initiatorName, initiatorPosition, res
ourceURL, baseURL, resourceType, resourceWidth)); |
| 43 } | 21 } |
| 44 | 22 |
| 45 bool isSafeToSendToAnotherThread() const; | 23 bool isSafeToSendToAnotherThread() const; |
| 46 | 24 |
| 47 FetchRequest resourceRequest(Document*); | 25 FetchRequest resourceRequest(Document*); |
| 48 | 26 |
| 49 const String& charset() const { return m_charset; } | 27 const String& charset() const { return m_charset; } |
| 50 double discoveryTime() const { return m_discoveryTime; } | 28 double discoveryTime() const { return m_discoveryTime; } |
| 51 void setDefer(FetchRequest::DeferOption defer) { m_defer = defer; } | 29 void setDefer(FetchRequest::DeferOption defer) { m_defer = defer; } |
| 52 void setCharset(const String& charset) { m_charset = charset.isolatedCopy();
} | 30 void setCharset(const String& charset) { m_charset = charset.isolatedCopy();
} |
| 53 void setCrossOriginEnabled(StoredCredentials allowCredentials) | 31 void setCrossOriginEnabled(StoredCredentials allowCredentials) |
| 54 { | 32 { |
| 55 m_isCORSEnabled = true; | 33 m_isCORSEnabled = true; |
| 56 m_allowCredentials = allowCredentials; | 34 m_allowCredentials = allowCredentials; |
| 57 } | 35 } |
| 58 | 36 |
| 59 Resource::Type resourceType() const { return m_resourceType; } | 37 Resource::Type resourceType() const { return m_resourceType; } |
| 60 | 38 |
| 39 const String& resourceURL() const { return m_resourceURL; } |
| 40 float resourceWidth() const { return m_resourceWidth.isSet ? m_resourceWidth
.width : 0; } |
| 41 const String& baseURL() const { return m_baseURL.string(); } |
| 42 |
| 61 private: | 43 private: |
| 62 PreloadRequest(const String& initiatorName, const TextPosition& initiatorPos
ition, const String& resourceURL, const KURL& baseURL, Resource::Type resourceTy
pe, const FetchRequest::ResourceWidth& resourceWidth) | 44 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) | 45 : m_initiatorName(initiatorName) |
| 64 , m_initiatorPosition(initiatorPosition) | 46 , m_initiatorPosition(initiatorPosition) |
| 65 , m_resourceURL(resourceURL.isolatedCopy()) | 47 , m_resourceURL(resourceURL.isolatedCopy()) |
| 66 , m_baseURL(baseURL.copy()) | 48 , m_baseURL(baseURL.copy()) |
| 67 , m_resourceType(resourceType) | 49 , m_resourceType(resourceType) |
| 68 , m_isCORSEnabled(false) | 50 , m_isCORSEnabled(false) |
| 69 , m_allowCredentials(DoNotAllowStoredCredentials) | 51 , m_allowCredentials(DoNotAllowStoredCredentials) |
| 70 , m_discoveryTime(monotonicallyIncreasingTime()) | 52 , m_discoveryTime(monotonicallyIncreasingTime()) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 83 Resource::Type m_resourceType; | 65 Resource::Type m_resourceType; |
| 84 bool m_isCORSEnabled; | 66 bool m_isCORSEnabled; |
| 85 StoredCredentials m_allowCredentials; | 67 StoredCredentials m_allowCredentials; |
| 86 double m_discoveryTime; | 68 double m_discoveryTime; |
| 87 FetchRequest::DeferOption m_defer; | 69 FetchRequest::DeferOption m_defer; |
| 88 FetchRequest::ResourceWidth m_resourceWidth; | 70 FetchRequest::ResourceWidth m_resourceWidth; |
| 89 }; | 71 }; |
| 90 | 72 |
| 91 typedef Vector<OwnPtr<PreloadRequest>> PreloadRequestStream; | 73 typedef Vector<OwnPtr<PreloadRequest>> PreloadRequestStream; |
| 92 | 74 |
| 93 class HTMLResourcePreloader final : public NoBaseWillBeGarbageCollected<HTMLReso
urcePreloader> { | |
| 94 WTF_MAKE_NONCOPYABLE(HTMLResourcePreloader); WTF_MAKE_FAST_ALLOCATED_WILL_BE
_REMOVED(HTMLResourcePreloader); | |
| 95 public: | |
| 96 static PassOwnPtrWillBeRawPtr<HTMLResourcePreloader> create(Document&); | |
| 97 DECLARE_TRACE(); | |
| 98 | |
| 99 void takeAndPreload(PreloadRequestStream&); | |
| 100 | |
| 101 private: | |
| 102 explicit HTMLResourcePreloader(Document&); | |
| 103 | |
| 104 void preload(PassOwnPtr<PreloadRequest>); | |
| 105 | |
| 106 RawPtrWillBeMember<Document> m_document; | |
| 107 }; | |
| 108 | |
| 109 } | 75 } |
| 110 | 76 |
| 111 #endif | 77 #endif |
| OLD | NEW |