| OLD | NEW |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_ | 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_ |
| 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_ | 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_ |
| 7 | 7 |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 void OnReceiveCachedMetadata(const std::vector<uint8_t>& data) override; | 89 void OnReceiveCachedMetadata(const std::vector<uint8_t>& data) override; |
| 90 void OnTransferSizeUpdated(int32_t transfer_size_diff) override; | 90 void OnTransferSizeUpdated(int32_t transfer_size_diff) override; |
| 91 void OnStartLoadingResponseBody( | 91 void OnStartLoadingResponseBody( |
| 92 mojo::ScopedDataPipeConsumerHandle body) override; | 92 mojo::ScopedDataPipeConsumerHandle body) override; |
| 93 void OnComplete(const ResourceRequestCompletionStatus& status) override; | 93 void OnComplete(const ResourceRequestCompletionStatus& status) override; |
| 94 | 94 |
| 95 void set_main_resource_loader_callback(LoaderCallback callback) { | 95 void set_main_resource_loader_callback(LoaderCallback callback) { |
| 96 main_resource_loader_callback_ = std::move(callback); | 96 main_resource_loader_callback_ = std::move(callback); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void set_main_resource_fallback_handler(ResponseFallback fallback_handler) { |
| 100 main_resource_fallback_handler_ = std::move(fallback_handler); |
| 101 } |
| 102 |
| 99 // Subresource request load information is passed in the | 103 // Subresource request load information is passed in the |
| 100 // |subresource_load_info| parameter. This includes the request id, the | 104 // |subresource_load_info| parameter. This includes the request id, the |
| 101 // client pointer, etc. | 105 // client pointer, etc. |
| 102 // |default_url_loader| is used to retrieve the network loader for requests | 106 // |default_url_loader| is used to retrieve the network loader for requests |
| 103 // intended to be sent to the network. | 107 // intended to be sent to the network. |
| 104 void SetSubresourceLoadInfo( | 108 void SetSubresourceLoadInfo( |
| 105 std::unique_ptr<SubresourceLoadInfo> subresource_load_info, | 109 std::unique_ptr<SubresourceLoadInfo> subresource_load_info, |
| 106 URLLoaderFactoryGetter* default_url_loader); | 110 URLLoaderFactoryGetter* default_url_loader); |
| 107 | 111 |
| 108 // Ownership of the |handler| is transferred to us via this call. This is | 112 // Ownership of the |handler| is transferred to us via this call. This is |
| 109 // only for subresource requests. | 113 // only for subresource requests. |
| 110 void set_request_handler(std::unique_ptr<AppCacheRequestHandler> handler) { | 114 void set_request_handler(std::unique_ptr<AppCacheRequestHandler> handler) { |
| 111 sub_resource_handler_ = std::move(handler); | 115 sub_resource_handler_ = std::move(handler); |
| 112 } | 116 } |
| 113 | 117 |
| 118 // Binds to the URLLoaderRequest instance passed in the |request| parameter. |
| 119 // The URLLoaderClient instance is passed in the |client| parameter. This |
| 120 // enables the client to receive notifications/data, etc for the ensuing |
| 121 // URL load. |
| 122 void BindRequest(mojom::URLLoaderClientPtr client, |
| 123 mojom::URLLoaderRequest request); |
| 124 |
| 114 protected: | 125 protected: |
| 115 // AppCacheJob::Create() creates this instance. | 126 // AppCacheJob::Create() creates this instance. |
| 116 friend class AppCacheJob; | 127 friend class AppCacheJob; |
| 117 | 128 |
| 118 AppCacheURLLoaderJob(const ResourceRequest& request, | 129 AppCacheURLLoaderJob(const ResourceRequest& request, |
| 119 AppCacheURLLoaderRequest* appcache_request, | 130 AppCacheURLLoaderRequest* appcache_request, |
| 120 AppCacheStorage* storage); | 131 AppCacheStorage* storage); |
| 121 | 132 |
| 122 // AppCacheStorage::Delegate methods | 133 // AppCacheStorage::Delegate methods |
| 123 void OnResponseInfoLoaded(AppCacheResponseInfo* response_info, | 134 void OnResponseInfoLoaded(AppCacheResponseInfo* response_info, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 // Used for subresource requests which go to the network. | 210 // Used for subresource requests which go to the network. |
| 200 mojom::URLLoaderPtr network_loader_; | 211 mojom::URLLoaderPtr network_loader_; |
| 201 | 212 |
| 202 // Network URLLoaderClient binding for subresource requests. | 213 // Network URLLoaderClient binding for subresource requests. |
| 203 mojo::Binding<mojom::URLLoaderClient> network_loader_client_binding_; | 214 mojo::Binding<mojom::URLLoaderClient> network_loader_client_binding_; |
| 204 | 215 |
| 205 // The AppCacheURLLoaderRequest instance. We use this to set the response | 216 // The AppCacheURLLoaderRequest instance. We use this to set the response |
| 206 // info when we receive it. | 217 // info when we receive it. |
| 207 AppCacheURLLoaderRequest* appcache_request_; | 218 AppCacheURLLoaderRequest* appcache_request_; |
| 208 | 219 |
| 220 // Contains the fallback response handler for the main resource, which is |
| 221 // invoked by the client to request fallback responses. |
| 222 ResponseFallback main_resource_fallback_handler_; |
| 223 |
| 209 DISALLOW_COPY_AND_ASSIGN(AppCacheURLLoaderJob); | 224 DISALLOW_COPY_AND_ASSIGN(AppCacheURLLoaderJob); |
| 210 }; | 225 }; |
| 211 | 226 |
| 212 } // namespace content | 227 } // namespace content |
| 213 | 228 |
| 214 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_ | 229 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_ |
| OLD | NEW |