| 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 19 matching lines...) Expand all Loading... |
| 30 #include "core/fetch/Resource.h" | 30 #include "core/fetch/Resource.h" |
| 31 #include "wtf/CurrentTime.h" | 31 #include "wtf/CurrentTime.h" |
| 32 #include "wtf/text/TextPosition.h" | 32 #include "wtf/text/TextPosition.h" |
| 33 | 33 |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 class Document; | 36 class Document; |
| 37 | 37 |
| 38 class PreloadRequest { | 38 class PreloadRequest { |
| 39 public: | 39 public: |
| 40 static PassOwnPtr<PreloadRequest> create(const String& initiatorName, const
TextPosition& initiatorPosition, const String& resourceURL, const KURL& baseURL,
Resource::Type resourceType) | 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 { | 41 { |
| 42 return adoptPtr(new PreloadRequest(initiatorName, initiatorPosition, res
ourceURL, baseURL, resourceType)); | 42 return adoptPtr(new PreloadRequest(initiatorName, initiatorPosition, res
ourceURL, baseURL, resourceType, resourceWidth)); |
| 43 } | 43 } |
| 44 | 44 |
| 45 bool isSafeToSendToAnotherThread() const; | 45 bool isSafeToSendToAnotherThread() const; |
| 46 | 46 |
| 47 FetchRequest resourceRequest(Document*); | 47 FetchRequest resourceRequest(Document*); |
| 48 | 48 |
| 49 const String& charset() const { return m_charset; } | 49 const String& charset() const { return m_charset; } |
| 50 double discoveryTime() const { return m_discoveryTime; } | 50 double discoveryTime() const { return m_discoveryTime; } |
| 51 void setDefer(FetchRequest::DeferOption defer) { m_defer = defer; } | 51 void setDefer(FetchRequest::DeferOption defer) { m_defer = defer; } |
| 52 void setCharset(const String& charset) { m_charset = charset.isolatedCopy();
} | 52 void setCharset(const String& charset) { m_charset = charset.isolatedCopy();
} |
| 53 void setCrossOriginEnabled(StoredCredentials allowCredentials) | 53 void setCrossOriginEnabled(StoredCredentials allowCredentials) |
| 54 { | 54 { |
| 55 m_isCORSEnabled = true; | 55 m_isCORSEnabled = true; |
| 56 m_allowCredentials = allowCredentials; | 56 m_allowCredentials = allowCredentials; |
| 57 } | 57 } |
| 58 | 58 |
| 59 Resource::Type resourceType() const { return m_resourceType; } | 59 Resource::Type resourceType() const { return m_resourceType; } |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 PreloadRequest(const String& initiatorName, const TextPosition& initiatorPos
ition, const String& resourceURL, const KURL& baseURL, Resource::Type resourceTy
pe) | 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) | 63 : m_initiatorName(initiatorName) |
| 64 , m_initiatorPosition(initiatorPosition) | 64 , m_initiatorPosition(initiatorPosition) |
| 65 , m_resourceURL(resourceURL.isolatedCopy()) | 65 , m_resourceURL(resourceURL.isolatedCopy()) |
| 66 , m_baseURL(baseURL.copy()) | 66 , m_baseURL(baseURL.copy()) |
| 67 , m_resourceType(resourceType) | 67 , m_resourceType(resourceType) |
| 68 , m_isCORSEnabled(false) | 68 , m_isCORSEnabled(false) |
| 69 , m_allowCredentials(DoNotAllowStoredCredentials) | 69 , m_allowCredentials(DoNotAllowStoredCredentials) |
| 70 , m_discoveryTime(monotonicallyIncreasingTime()) | 70 , m_discoveryTime(monotonicallyIncreasingTime()) |
| 71 , m_defer(FetchRequest::NoDefer) | 71 , m_defer(FetchRequest::NoDefer) |
| 72 , m_resourceWidth(resourceWidth) |
| 72 { | 73 { |
| 73 } | 74 } |
| 74 | 75 |
| 75 KURL completeURL(Document*); | 76 KURL completeURL(Document*); |
| 76 | 77 |
| 77 String m_initiatorName; | 78 String m_initiatorName; |
| 78 TextPosition m_initiatorPosition; | 79 TextPosition m_initiatorPosition; |
| 79 String m_resourceURL; | 80 String m_resourceURL; |
| 80 KURL m_baseURL; | 81 KURL m_baseURL; |
| 81 String m_charset; | 82 String m_charset; |
| 82 Resource::Type m_resourceType; | 83 Resource::Type m_resourceType; |
| 83 bool m_isCORSEnabled; | 84 bool m_isCORSEnabled; |
| 84 StoredCredentials m_allowCredentials; | 85 StoredCredentials m_allowCredentials; |
| 85 double m_discoveryTime; | 86 double m_discoveryTime; |
| 86 FetchRequest::DeferOption m_defer; | 87 FetchRequest::DeferOption m_defer; |
| 88 FetchRequest::ResourceWidth m_resourceWidth; |
| 87 }; | 89 }; |
| 88 | 90 |
| 89 typedef Vector<OwnPtr<PreloadRequest>> PreloadRequestStream; | 91 typedef Vector<OwnPtr<PreloadRequest>> PreloadRequestStream; |
| 90 | 92 |
| 91 class HTMLResourcePreloader final : public NoBaseWillBeGarbageCollected<HTMLReso
urcePreloader> { | 93 class HTMLResourcePreloader final : public NoBaseWillBeGarbageCollected<HTMLReso
urcePreloader> { |
| 92 WTF_MAKE_NONCOPYABLE(HTMLResourcePreloader); WTF_MAKE_FAST_ALLOCATED_WILL_BE
_REMOVED(HTMLResourcePreloader); | 94 WTF_MAKE_NONCOPYABLE(HTMLResourcePreloader); WTF_MAKE_FAST_ALLOCATED_WILL_BE
_REMOVED(HTMLResourcePreloader); |
| 93 public: | 95 public: |
| 94 static PassOwnPtrWillBeRawPtr<HTMLResourcePreloader> create(Document&); | 96 static PassOwnPtrWillBeRawPtr<HTMLResourcePreloader> create(Document&); |
| 95 DECLARE_TRACE(); | 97 DECLARE_TRACE(); |
| 96 | 98 |
| 97 void takeAndPreload(PreloadRequestStream&); | 99 void takeAndPreload(PreloadRequestStream&); |
| 98 | 100 |
| 99 private: | 101 private: |
| 100 explicit HTMLResourcePreloader(Document&); | 102 explicit HTMLResourcePreloader(Document&); |
| 101 | 103 |
| 102 void preload(PassOwnPtr<PreloadRequest>); | 104 void preload(PassOwnPtr<PreloadRequest>); |
| 103 | 105 |
| 104 RawPtrWillBeMember<Document> m_document; | 106 RawPtrWillBeMember<Document> m_document; |
| 105 }; | 107 }; |
| 106 | 108 |
| 107 } | 109 } |
| 108 | 110 |
| 109 #endif | 111 #endif |
| OLD | NEW |