| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2011 Apple 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 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #ifndef ResourceLoader_h | 29 #ifndef ResourceLoader_h |
| 30 #define ResourceLoader_h | 30 #define ResourceLoader_h |
| 31 | 31 |
| 32 #include "core/CoreExport.h" |
| 32 #include "core/fetch/ResourceLoaderOptions.h" | 33 #include "core/fetch/ResourceLoaderOptions.h" |
| 33 #include "platform/network/ResourceRequest.h" | 34 #include "platform/network/ResourceRequest.h" |
| 34 #include "public/platform/WebURLLoader.h" | 35 #include "public/platform/WebURLLoader.h" |
| 35 #include "public/platform/WebURLLoaderClient.h" | 36 #include "public/platform/WebURLLoaderClient.h" |
| 36 #include "wtf/Forward.h" | 37 #include "wtf/Forward.h" |
| 37 #include "wtf/RefCounted.h" | 38 #include "wtf/RefCounted.h" |
| 38 | 39 |
| 39 namespace blink { | 40 namespace blink { |
| 40 | 41 |
| 41 class Resource; | 42 class Resource; |
| 42 class KURL; | 43 class KURL; |
| 43 class ResourceError; | 44 class ResourceError; |
| 44 class ResourceFetcher; | 45 class ResourceFetcher; |
| 45 class ThreadedDataReceiver; | 46 class ThreadedDataReceiver; |
| 46 | 47 |
| 47 class ResourceLoader final : public RefCountedWillBeGarbageCollectedFinalized<Re
sourceLoader>, protected WebURLLoaderClient { | 48 class CORE_EXPORT ResourceLoader final : public RefCountedWillBeGarbageCollected
Finalized<ResourceLoader>, protected WebURLLoaderClient { |
| 48 public: | 49 public: |
| 49 static PassRefPtrWillBeRawPtr<ResourceLoader> create(ResourceFetcher*, Resou
rce*, const ResourceRequest&, const ResourceLoaderOptions&); | 50 static PassRefPtrWillBeRawPtr<ResourceLoader> create(ResourceFetcher*, Resou
rce*, const ResourceRequest&, const ResourceLoaderOptions&); |
| 50 virtual ~ResourceLoader(); | 51 virtual ~ResourceLoader(); |
| 51 DECLARE_TRACE(); | 52 DECLARE_TRACE(); |
| 52 | 53 |
| 53 void start(); | 54 void start(); |
| 54 void changeToSynchronous(); | 55 void changeToSynchronous(); |
| 55 | 56 |
| 56 void cancel(); | 57 void cancel(); |
| 57 void cancel(const ResourceError&); | 58 void cancel(const ResourceError&); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 79 void didFinishLoading(WebURLLoader*, double finishTime, int64_t encodedDataL
ength) override; | 80 void didFinishLoading(WebURLLoader*, double finishTime, int64_t encodedDataL
ength) override; |
| 80 void didFail(WebURLLoader*, const WebURLError&) override; | 81 void didFail(WebURLLoader*, const WebURLError&) override; |
| 81 void didDownloadData(WebURLLoader*, int, int) override; | 82 void didDownloadData(WebURLLoader*, int, int) override; |
| 82 | 83 |
| 83 const KURL& url() const { return m_request.url(); } | 84 const KURL& url() const { return m_request.url(); } |
| 84 bool isLoadedBy(ResourceFetcher*) const; | 85 bool isLoadedBy(ResourceFetcher*) const; |
| 85 | 86 |
| 86 bool reachedTerminalState() const { return m_state == Terminated; } | 87 bool reachedTerminalState() const { return m_state == Terminated; } |
| 87 const ResourceRequest& request() const { return m_request; } | 88 const ResourceRequest& request() const { return m_request; } |
| 88 | 89 |
| 90 bool loadingMultipartContent() const { return m_loadingMultipartContent; } |
| 91 |
| 89 private: | 92 private: |
| 90 ResourceLoader(ResourceFetcher*, Resource*, const ResourceLoaderOptions&); | 93 ResourceLoader(ResourceFetcher*, Resource*, const ResourceLoaderOptions&); |
| 91 | 94 |
| 92 void init(const ResourceRequest&); | 95 void init(const ResourceRequest&); |
| 93 void requestSynchronously(); | 96 void requestSynchronously(); |
| 94 | 97 |
| 95 void didFinishLoadingOnePart(double finishTime, int64_t encodedDataLength); | 98 void didFinishLoadingOnePart(double finishTime, int64_t encodedDataLength); |
| 96 | 99 |
| 97 bool responseNeedsAccessControlCheck() const; | 100 bool responseNeedsAccessControlCheck() const; |
| 98 | 101 |
| 99 ResourceRequest& applyOptions(ResourceRequest&) const; | 102 ResourceRequest& applyOptions(ResourceRequest&) const; |
| 100 | 103 |
| 101 OwnPtr<WebURLLoader> m_loader; | 104 OwnPtr<WebURLLoader> m_loader; |
| 102 RefPtrWillBeMember<ResourceFetcher> m_fetcher; | 105 RefPtrWillBeMember<ResourceFetcher> m_fetcher; |
| 103 | 106 |
| 104 ResourceRequest m_request; | 107 ResourceRequest m_request; |
| 105 ResourceRequest m_originalRequest; // Before redirects. | 108 ResourceRequest m_originalRequest; // Before redirects. |
| 106 | 109 |
| 107 bool m_notifiedLoadComplete; | 110 bool m_notifiedLoadComplete; |
| 108 | 111 |
| 109 bool m_defersLoading; | 112 bool m_defersLoading; |
| 113 bool m_loadingMultipartContent; |
| 110 OwnPtr<ResourceRequest> m_fallbackRequestForServiceWorker; | 114 OwnPtr<ResourceRequest> m_fallbackRequestForServiceWorker; |
| 111 ResourceRequest m_deferredRequest; | 115 ResourceRequest m_deferredRequest; |
| 112 ResourceLoaderOptions m_options; | 116 ResourceLoaderOptions m_options; |
| 113 | 117 |
| 114 enum ResourceLoaderState { | 118 enum ResourceLoaderState { |
| 115 Initialized, | 119 Initialized, |
| 116 Finishing, | 120 Finishing, |
| 117 Terminated | 121 Terminated |
| 118 }; | 122 }; |
| 119 | 123 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 131 ResourceLoaderState m_state; | 135 ResourceLoaderState m_state; |
| 132 | 136 |
| 133 // Used for sanity checking to make sure we don't experience illegal state | 137 // Used for sanity checking to make sure we don't experience illegal state |
| 134 // transitions. | 138 // transitions. |
| 135 ConnectionState m_connectionState; | 139 ConnectionState m_connectionState; |
| 136 }; | 140 }; |
| 137 | 141 |
| 138 } | 142 } |
| 139 | 143 |
| 140 #endif | 144 #endif |
| OLD | NEW |