| 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 21 matching lines...) Expand all Loading... |
| 32 #include "core/CoreExport.h" | 32 #include "core/CoreExport.h" |
| 33 #include "core/fetch/ResourceLoaderOptions.h" | 33 #include "core/fetch/ResourceLoaderOptions.h" |
| 34 #include "platform/network/ResourceRequest.h" | 34 #include "platform/network/ResourceRequest.h" |
| 35 #include "public/platform/WebURLLoader.h" | 35 #include "public/platform/WebURLLoader.h" |
| 36 #include "public/platform/WebURLLoaderClient.h" | 36 #include "public/platform/WebURLLoaderClient.h" |
| 37 #include "wtf/Forward.h" | 37 #include "wtf/Forward.h" |
| 38 #include <memory> | 38 #include <memory> |
| 39 | 39 |
| 40 namespace blink { | 40 namespace blink { |
| 41 | 41 |
| 42 class FetchContext; |
| 42 class Resource; | 43 class Resource; |
| 43 class ResourceError; | 44 class ResourceError; |
| 44 class ResourceFetcher; | 45 class ResourceFetcher; |
| 45 | 46 |
| 47 // A ResourceLoader is created for each Resource by the ResourceFetcher when it |
| 48 // needs to load the specified resource. A ResourceLoader creates a |
| 49 // WebURLLoader and loads the resource using it. Any per-load logic should be |
| 50 // implemented in this class basically. |
| 46 class CORE_EXPORT ResourceLoader final | 51 class CORE_EXPORT ResourceLoader final |
| 47 : public GarbageCollectedFinalized<ResourceLoader>, | 52 : public GarbageCollectedFinalized<ResourceLoader>, |
| 48 protected WebURLLoaderClient { | 53 protected WebURLLoaderClient { |
| 49 public: | 54 public: |
| 50 static ResourceLoader* create(ResourceFetcher*, Resource*); | 55 static ResourceLoader* create(ResourceFetcher*, Resource*); |
| 51 ~ResourceLoader() override; | 56 ~ResourceLoader() override; |
| 52 DECLARE_TRACE(); | 57 DECLARE_TRACE(); |
| 53 | 58 |
| 54 void start(const ResourceRequest&, | 59 void start(const ResourceRequest&); |
| 55 WebTaskRunner* loadingTaskRunner, | |
| 56 bool defersLoading); | |
| 57 | |
| 58 // This method is currently only used for service worker fallback request and | |
| 59 // cache-aware loading, other users should be careful not to break | |
| 60 // ResourceLoader state. | |
| 61 void restart(const ResourceRequest&, | |
| 62 WebTaskRunner* loadingTaskRunner, | |
| 63 bool defersLoading); | |
| 64 | 60 |
| 65 void cancel(); | 61 void cancel(); |
| 66 | 62 |
| 67 void setDefersLoading(bool); | 63 void setDefersLoading(bool); |
| 68 | 64 |
| 69 void didChangePriority(ResourceLoadPriority, int intraPriorityValue); | 65 void didChangePriority(ResourceLoadPriority, int intraPriorityValue); |
| 70 | 66 |
| 71 // Called before start() to activate cache-aware loading if enabled in | 67 // Called before start() to activate cache-aware loading if enabled in |
| 72 // |m_resource->options()| and applicable. | 68 // |m_resource->options()| and applicable. |
| 73 void activateCacheAwareLoadingIfNeeded(const ResourceRequest&); | 69 void activateCacheAwareLoadingIfNeeded(const ResourceRequest&); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 98 void didReceiveCachedMetadata(const char* data, int length) override; | 94 void didReceiveCachedMetadata(const char* data, int length) override; |
| 99 void didReceiveData(const char*, int) override; | 95 void didReceiveData(const char*, int) override; |
| 100 void didReceiveTransferSizeUpdate(int transferSizeDiff) override; | 96 void didReceiveTransferSizeUpdate(int transferSizeDiff) override; |
| 101 void didDownloadData(int, int) override; | 97 void didDownloadData(int, int) override; |
| 102 void didFinishLoading(double finishTime, | 98 void didFinishLoading(double finishTime, |
| 103 int64_t encodedDataLength, | 99 int64_t encodedDataLength, |
| 104 int64_t encodedBodyLength) override; | 100 int64_t encodedBodyLength) override; |
| 105 void didFail(const WebURLError&, | 101 void didFail(const WebURLError&, |
| 106 int64_t encodedDataLength, | 102 int64_t encodedDataLength, |
| 107 int64_t encodedBodyLength) override; | 103 int64_t encodedBodyLength) override; |
| 104 void handleError(const ResourceError&); |
| 108 | 105 |
| 109 void didFinishLoadingFirstPartInMultipart(); | 106 void didFinishLoadingFirstPartInMultipart(); |
| 110 void didFail(const ResourceError&); | |
| 111 | 107 |
| 112 private: | 108 private: |
| 113 // Assumes ResourceFetcher and Resource are non-null. | 109 // Assumes ResourceFetcher and Resource are non-null. |
| 114 ResourceLoader(ResourceFetcher*, Resource*); | 110 ResourceLoader(ResourceFetcher*, Resource*); |
| 115 | 111 |
| 112 // This method is currently only used for service worker fallback request and |
| 113 // cache-aware loading, other users should be careful not to break |
| 114 // ResourceLoader state. |
| 115 void restart(const ResourceRequest&); |
| 116 |
| 117 FetchContext& context() const; |
| 118 ResourceRequestBlockedReason canAccessResponse(Resource*, |
| 119 const ResourceResponse&) const; |
| 120 |
| 116 void cancelForRedirectAccessCheckError(const KURL&, | 121 void cancelForRedirectAccessCheckError(const KURL&, |
| 117 ResourceRequestBlockedReason); | 122 ResourceRequestBlockedReason); |
| 118 void requestSynchronously(const ResourceRequest&); | 123 void requestSynchronously(const ResourceRequest&); |
| 119 | 124 |
| 120 std::unique_ptr<WebURLLoader> m_loader; | 125 std::unique_ptr<WebURLLoader> m_loader; |
| 121 Member<ResourceFetcher> m_fetcher; | 126 Member<ResourceFetcher> m_fetcher; |
| 122 Member<Resource> m_resource; | 127 Member<Resource> m_resource; |
| 123 bool m_isCacheAwareLoadingActivated; | 128 bool m_isCacheAwareLoadingActivated; |
| 124 }; | 129 }; |
| 125 | 130 |
| 126 } // namespace blink | 131 } // namespace blink |
| 127 | 132 |
| 128 #endif | 133 #endif |
| OLD | NEW |