[email protected] | 0a60884 | 2011-09-08 10:55:19 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | 97e3edc | 2009-09-15 22:07:15 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 5 | #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ |
| 6 | #define CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ |
[email protected] | 97e3edc | 2009-09-15 22:07:15 | [diff] [blame] | 7 | |
avi | b734894 | 2015-12-25 20:57:10 | [diff] [blame] | 8 | #include <stdint.h> |
| 9 | |
dcheng | 5971627 | 2016-04-09 05:19:08 | [diff] [blame] | 10 | #include <memory> |
| 11 | |
[email protected] | bfe1948 | 2011-09-30 22:14:57 | [diff] [blame] | 12 | #include "base/compiler_specific.h" |
avi | b734894 | 2015-12-25 20:57:10 | [diff] [blame] | 13 | #include "base/macros.h" |
mmenke | 5289cbfd | 2015-10-29 19:36:17 | [diff] [blame] | 14 | #include "base/memory/weak_ptr.h" |
[email protected] | ea8e181 | 2012-02-15 22:07:34 | [diff] [blame] | 15 | #include "base/supports_user_data.h" |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 16 | #include "content/browser/appcache/appcache_entry.h" |
| 17 | #include "content/browser/appcache/appcache_host.h" |
Anantanarayanan Iyengar | d125c460 | 2017-08-19 00:46:56 | [diff] [blame] | 18 | #include "content/browser/appcache/appcache_request_handler.h" |
michaeln | b861840 | 2016-08-02 20:14:33 | [diff] [blame] | 19 | #include "content/browser/appcache/appcache_service_impl.h" |
Kinuko Yasuda | 7f3e172 | 2018-03-26 08:58:58 | [diff] [blame] | 20 | #include "content/browser/loader/navigation_loader_interceptor.h" |
Clark DuVall | f77e164d | 2019-10-24 23:53:25 | [diff] [blame] | 21 | #include "content/browser/loader/single_request_url_loader_factory.h" |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 22 | #include "content/common/content_export.h" |
[email protected] | 7491ad0 | 2014-07-05 19:10:07 | [diff] [blame] | 23 | #include "content/public/common/resource_type.h" |
Kinuko Yasuda | be4ad29 | 2018-07-06 01:33:39 | [diff] [blame] | 24 | #include "services/network/public/cpp/shared_url_loader_factory.h" |
[email protected] | 97e3edc | 2009-09-15 22:07:15 | [diff] [blame] | 25 | |
[email protected] | edfe7fab | 2010-11-28 13:11:52 | [diff] [blame] | 26 | namespace net { |
[email protected] | 9f17046 | 2012-08-24 01:06:58 | [diff] [blame] | 27 | class NetworkDelegate; |
[email protected] | 97e3edc | 2009-09-15 22:07:15 | [diff] [blame] | 28 | class URLRequest; |
[email protected] | edfe7fab | 2010-11-28 13:11:52 | [diff] [blame] | 29 | } // namespace net |
[email protected] | 97e3edc | 2009-09-15 22:07:15 | [diff] [blame] | 30 | |
John Abd-El-Malek | 4624803 | 2018-01-17 19:11:23 | [diff] [blame] | 31 | namespace network { |
| 32 | struct ResourceResponseHead; |
| 33 | } |
| 34 | |
[email protected] | 073f24d | 2014-04-09 00:00:23 | [diff] [blame] | 35 | namespace content { |
ananta | 46f3e94 | 2017-05-09 04:56:30 | [diff] [blame] | 36 | class AppCacheJob; |
Anantanarayanan Iyengar | 2130d27 | 2017-09-01 18:21:14 | [diff] [blame] | 37 | class AppCacheSubresourceURLFactory; |
ananta | 4e8a529 | 2017-05-04 03:07:15 | [diff] [blame] | 38 | class AppCacheRequest; |
[email protected] | 073f24d | 2014-04-09 00:00:23 | [diff] [blame] | 39 | class AppCacheRequestHandlerTest; |
ananta | 2533bff6 | 2017-07-12 04:07:27 | [diff] [blame] | 40 | class AppCacheHost; |
[email protected] | 3367fc1d | 2009-11-09 00:09:21 | [diff] [blame] | 41 | |
[email protected] | 6981d963 | 2010-11-30 21:34:02 | [diff] [blame] | 42 | // An instance is created for each net::URLRequest. The instance survives all |
| 43 | // http transactions involved in the processing of its net::URLRequest, and is |
[email protected] | 97e3edc | 2009-09-15 22:07:15 | [diff] [blame] | 44 | // given the opportunity to hijack the request along the way. Callers |
| 45 | // should use AppCacheHost::CreateRequestHandler to manufacture instances |
| 46 | // that can retrieve resources for a particular host. |
Findit | b796d00 | 2018-10-21 07:15:22 | [diff] [blame] | 47 | class CONTENT_EXPORT AppCacheRequestHandler |
[email protected] | ea8e181 | 2012-02-15 22:07:34 | [diff] [blame] | 48 | : public base::SupportsUserData::Data, |
[email protected] | bfe1948 | 2011-09-30 22:14:57 | [diff] [blame] | 49 | public AppCacheHost::Observer, |
michaeln | b861840 | 2016-08-02 20:14:33 | [diff] [blame] | 50 | public AppCacheServiceImpl::Observer, |
ananta | a2c8ec6 | 2017-06-09 23:44:05 | [diff] [blame] | 51 | public AppCacheStorage::Delegate, |
Kinuko Yasuda | 7f3e172 | 2018-03-26 08:58:58 | [diff] [blame] | 52 | public NavigationLoaderInterceptor { |
[email protected] | 97e3edc | 2009-09-15 22:07:15 | [diff] [blame] | 53 | public: |
Clark DuVall | f77e164d | 2019-10-24 23:53:25 | [diff] [blame] | 54 | using AppCacheLoaderCallback = |
| 55 | base::OnceCallback<void(SingleRequestURLLoaderFactory::RequestHandler)>; |
| 56 | |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 57 | ~AppCacheRequestHandler() override; |
[email protected] | 7e8e3dd | 2009-09-18 01:05:09 | [diff] [blame] | 58 | |
Michael Nordman | 85243a8 | 2017-10-24 01:24:50 | [diff] [blame] | 59 | // NetworkService loading |
Anantanarayanan Iyengar | d125c460 | 2017-08-19 00:46:56 | [diff] [blame] | 60 | |
Kinuko Yasuda | 7f3e172 | 2018-03-26 08:58:58 | [diff] [blame] | 61 | // NavigationLoaderInterceptor overrides - main resource loading. |
arthursonzogni | 1fd60e6 | 2018-05-09 15:57:32 | [diff] [blame] | 62 | // These methods are used by the NavigationURLLoaderImpl. |
Victor Costan | c65793b | 2019-09-02 23:38:36 | [diff] [blame] | 63 | // Internally they use MaybeLoadResource and MaybeLoadFallbackForResponse. |
Michael Nordman | 85243a8 | 2017-10-24 01:24:50 | [diff] [blame] | 64 | // Eventually one of the Deliver*Response() methods is called and the |
| 65 | // LoaderCallback is invoked. |
Matt Falkenhagen | 4376512 | 2018-08-22 19:37:22 | [diff] [blame] | 66 | void MaybeCreateLoader( |
| 67 | const network::ResourceRequest& tentative_resource_request, |
Clark DuVall | 1cc8323a | 2019-06-28 00:27:05 | [diff] [blame] | 68 | BrowserContext* browser_context, |
Matt Falkenhagen | 4376512 | 2018-08-22 19:37:22 | [diff] [blame] | 69 | LoaderCallback callback, |
| 70 | FallbackCallback fallback_callback) override; |
Michael Nordman | 85243a8 | 2017-10-24 01:24:50 | [diff] [blame] | 71 | // MaybeCreateLoaderForResponse always returns synchronously. |
| 72 | bool MaybeCreateLoaderForResponse( |
Tsuyoshi Horo | d0a953d | 2019-01-23 04:38:14 | [diff] [blame] | 73 | const network::ResourceRequest& request, |
Minggang Wang | 47a7822 | 2019-06-28 17:05:46 | [diff] [blame] | 74 | const network::ResourceResponseHead& response_head, |
| 75 | mojo::ScopedDataPipeConsumerHandle* response_body, |
John Abd-El-Malek | b165dc5 | 2018-01-18 17:12:18 | [diff] [blame] | 76 | network::mojom::URLLoaderPtr* loader, |
Tsuyoshi Horo | b8d512a | 2018-01-25 17:01:59 | [diff] [blame] | 77 | network::mojom::URLLoaderClientRequest* client_request, |
Minggang Wang | f8b459d | 2019-10-25 11:08:38 | [diff] [blame^] | 78 | blink::ThrottlingURLLoader* url_loader, |
Tsuyoshi Horo | 91727e9 | 2019-09-26 05:01:02 | [diff] [blame] | 79 | bool* skip_other_interceptors, |
| 80 | bool* will_return_unsafe_redirect) override; |
Kinuko Yasuda | 250577c | 2017-10-29 02:51:24 | [diff] [blame] | 81 | base::Optional<SubresourceLoaderParams> MaybeCreateSubresourceLoaderParams() |
| 82 | override; |
Michael Nordman | 85243a8 | 2017-10-24 01:24:50 | [diff] [blame] | 83 | |
| 84 | // These methods are used for subresource loading by the |
| 85 | // AppCacheSubresourceURLFactory::SubresourceLoader class. |
Victor Costan | c65793b | 2019-09-02 23:38:36 | [diff] [blame] | 86 | // Internally they use MaybeLoadResource, MaybeLoadFallbackForResponse, and |
Michael Nordman | 85243a8 | 2017-10-24 01:24:50 | [diff] [blame] | 87 | // MaybeLoadFallbackForRedirect. Eventually one of the Deliver*Response() |
| 88 | // methods is called and the LoaderCallback is invoked. |
John Abd-El-Malek | 1df6179 | 2018-01-12 20:40:45 | [diff] [blame] | 89 | void MaybeCreateSubresourceLoader( |
| 90 | const network::ResourceRequest& resource_request, |
Clark DuVall | f77e164d | 2019-10-24 23:53:25 | [diff] [blame] | 91 | AppCacheLoaderCallback callback); |
John Abd-El-Malek | 4624803 | 2018-01-17 19:11:23 | [diff] [blame] | 92 | void MaybeFallbackForSubresourceResponse( |
| 93 | const network::ResourceResponseHead& response, |
Clark DuVall | f77e164d | 2019-10-24 23:53:25 | [diff] [blame] | 94 | AppCacheLoaderCallback callback); |
Michael Nordman | 85243a8 | 2017-10-24 01:24:50 | [diff] [blame] | 95 | void MaybeFallbackForSubresourceRedirect( |
| 96 | const net::RedirectInfo& redirect_info, |
Clark DuVall | f77e164d | 2019-10-24 23:53:25 | [diff] [blame] | 97 | AppCacheLoaderCallback callback); |
Michael Nordman | 85243a8 | 2017-10-24 01:24:50 | [diff] [blame] | 98 | void MaybeFollowSubresourceRedirect(const net::RedirectInfo& redirect_info, |
Clark DuVall | f77e164d | 2019-10-24 23:53:25 | [diff] [blame] | 99 | AppCacheLoaderCallback callback); |
[email protected] | 15f9cded | 2010-05-20 20:51:06 | [diff] [blame] | 100 | |
ananta | a2c8ec6 | 2017-06-09 23:44:05 | [diff] [blame] | 101 | static std::unique_ptr<AppCacheRequestHandler> |
Hiroki Nakagawa | ff43e447 | 2018-07-26 07:06:46 | [diff] [blame] | 102 | InitializeForMainResourceNetworkService( |
John Abd-El-Malek | 1df6179 | 2018-01-12 20:40:45 | [diff] [blame] | 103 | const network::ResourceRequest& request, |
John Abd-El-Malek | 0d9f17b | 2018-12-05 00:02:38 | [diff] [blame] | 104 | base::WeakPtr<AppCacheHost> appcache_host); |
ananta | a2c8ec6 | 2017-06-09 23:44:05 | [diff] [blame] | 105 | |
Hiroki Nakagawa | 599efcb | 2019-02-27 12:22:33 | [diff] [blame] | 106 | static bool IsMainResourceType(ResourceType type); |
Michael Nordman | 85243a8 | 2017-10-24 01:24:50 | [diff] [blame] | 107 | |
Anantanarayanan Iyengar | d125c460 | 2017-08-19 00:46:56 | [diff] [blame] | 108 | // Called by unittests to indicate that we are in test mode. |
| 109 | static void SetRunningInTests(bool in_tests); |
Anantanarayanan Iyengar | d125c460 | 2017-08-19 00:46:56 | [diff] [blame] | 110 | static bool IsRunningInTests(); |
ananta | 2533bff6 | 2017-07-12 04:07:27 | [diff] [blame] | 111 | |
[email protected] | 97e3edc | 2009-09-15 22:07:15 | [diff] [blame] | 112 | private: |
| 113 | friend class AppCacheHost; |
Michael Nordman | 85243a8 | 2017-10-24 01:24:50 | [diff] [blame] | 114 | friend class AppCacheRequestHandlerTest; |
[email protected] | 97e3edc | 2009-09-15 22:07:15 | [diff] [blame] | 115 | |
[email protected] | 7e8e3dd | 2009-09-18 01:05:09 | [diff] [blame] | 116 | // Callers should use AppCacheHost::CreateRequestHandler. |
ananta | 4e8a529 | 2017-05-04 03:07:15 | [diff] [blame] | 117 | AppCacheRequestHandler(AppCacheHost* host, |
| 118 | ResourceType resource_type, |
| 119 | bool should_reset_appcache, |
| 120 | std::unique_ptr<AppCacheRequest> request); |
[email protected] | 97e3edc | 2009-09-15 22:07:15 | [diff] [blame] | 121 | |
Clark DuVall | f77e164d | 2019-10-24 23:53:25 | [diff] [blame] | 122 | void MaybeCreateLoaderInternal( |
| 123 | const network::ResourceRequest& resource_request, |
| 124 | AppCacheLoaderCallback callback); |
| 125 | |
Victor Costan | c65793b | 2019-09-02 23:38:36 | [diff] [blame] | 126 | // AppCacheHost::Observer. |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 127 | void OnDestructionImminent(AppCacheHost* host) override; |
[email protected] | 97e3edc | 2009-09-15 22:07:15 | [diff] [blame] | 128 | |
Victor Costan | c65793b | 2019-09-02 23:38:36 | [diff] [blame] | 129 | // AppCacheServiceImpl::Observer. |
michaeln | b861840 | 2016-08-02 20:14:33 | [diff] [blame] | 130 | void OnServiceDestructionImminent(AppCacheServiceImpl* service) override; |
| 131 | |
[email protected] | 3367fc1d | 2009-11-09 00:09:21 | [diff] [blame] | 132 | // Helpers to instruct a waiting job with what response to |
| 133 | // deliver for the request we're handling. |
avi | b734894 | 2015-12-25 20:57:10 | [diff] [blame] | 134 | void DeliverAppCachedResponse(const AppCacheEntry& entry, |
| 135 | int64_t cache_id, |
avi | b734894 | 2015-12-25 20:57:10 | [diff] [blame] | 136 | const GURL& manifest_url, |
[email protected] | 2abcade | 2012-01-05 00:19:40 | [diff] [blame] | 137 | bool is_fallback, |
| 138 | const GURL& namespace_entry_url); |
[email protected] | 3367fc1d | 2009-11-09 00:09:21 | [diff] [blame] | 139 | void DeliverNetworkResponse(); |
| 140 | void DeliverErrorResponse(); |
| 141 | |
ananta | 46f3e94 | 2017-05-09 04:56:30 | [diff] [blame] | 142 | // Helper method to create an AppCacheJob and populate job_. |
mmenke | 5289cbfd | 2015-10-29 19:36:17 | [diff] [blame] | 143 | // Caller takes ownership of returned value. |
ananta | 46f3e94 | 2017-05-09 04:56:30 | [diff] [blame] | 144 | std::unique_ptr<AppCacheJob> CreateJob( |
mmenke | ed0498b | 2015-12-08 23:20:42 | [diff] [blame] | 145 | net::NetworkDelegate* network_delegate); |
mmenke | 5289cbfd | 2015-10-29 19:36:17 | [diff] [blame] | 146 | |
[email protected] | 3367fc1d | 2009-11-09 00:09:21 | [diff] [blame] | 147 | // Helper to retrieve a pointer to the storage object. |
[email protected] | 15f9cded | 2010-05-20 20:51:06 | [diff] [blame] | 148 | AppCacheStorage* storage() const; |
| 149 | |
| 150 | bool is_main_resource() const { |
| 151 | return IsMainResourceType(resource_type_); |
| 152 | } |
[email protected] | 3367fc1d | 2009-11-09 00:09:21 | [diff] [blame] | 153 | |
Victor Costan | c65793b | 2019-09-02 23:38:36 | [diff] [blame] | 154 | // These are called on each request intercept opportunity, by the various |
| 155 | // MaybeCreateLoader methods in the public API. |
| 156 | AppCacheJob* MaybeLoadResource(net::NetworkDelegate* network_delegate); |
| 157 | AppCacheJob* MaybeLoadFallbackForRedirect( |
| 158 | net::NetworkDelegate* network_delegate, |
| 159 | const GURL& location); |
| 160 | AppCacheJob* MaybeLoadFallbackForResponse( |
| 161 | net::NetworkDelegate* network_delegate); |
| 162 | |
| 163 | void GetExtraResponseInfo(int64_t* cache_id, GURL* manifest_url); |
| 164 | |
[email protected] | 3367fc1d | 2009-11-09 00:09:21 | [diff] [blame] | 165 | // Main-resource loading ------------------------------------- |
[email protected] | 15f9cded | 2010-05-20 20:51:06 | [diff] [blame] | 166 | // Frame and SharedWorker main resources are handled here. |
[email protected] | 3367fc1d | 2009-11-09 00:09:21 | [diff] [blame] | 167 | |
ananta | 46f3e94 | 2017-05-09 04:56:30 | [diff] [blame] | 168 | std::unique_ptr<AppCacheJob> MaybeLoadMainResource( |
mmenke | 5289cbfd | 2015-10-29 19:36:17 | [diff] [blame] | 169 | net::NetworkDelegate* network_delegate); |
[email protected] | 3367fc1d | 2009-11-09 00:09:21 | [diff] [blame] | 170 | |
| 171 | // AppCacheStorage::Delegate methods |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 172 | void OnMainResponseFound(const GURL& url, |
| 173 | const AppCacheEntry& entry, |
| 174 | const GURL& fallback_url, |
| 175 | const AppCacheEntry& fallback_entry, |
avi | b734894 | 2015-12-25 20:57:10 | [diff] [blame] | 176 | int64_t cache_id, |
| 177 | int64_t group_id, |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 178 | const GURL& mainfest_url) override; |
[email protected] | 3367fc1d | 2009-11-09 00:09:21 | [diff] [blame] | 179 | |
Kinuko Yasuda | 8757204a | 2017-11-04 07:50:13 | [diff] [blame] | 180 | // NetworkService loading: |
Ken Rockot | 387ddd5a | 2018-01-30 19:18:40 | [diff] [blame] | 181 | // Called when a |callback| that is originally given to |MaybeCreateLoader()| |
| 182 | // runs for the main resource. This flips |should_create_subresource_loader_| |
| 183 | // if a non-null |handler| is given. Always invokes |callback| with |handler|. |
Kinuko Yasuda | 8757204a | 2017-11-04 07:50:13 | [diff] [blame] | 184 | void RunLoaderCallbackForMainResource( |
Clark DuVall | f77e164d | 2019-10-24 23:53:25 | [diff] [blame] | 185 | int frame_tree_node_id, |
| 186 | BrowserContext* browser_context, |
Kinuko Yasuda | 8757204a | 2017-11-04 07:50:13 | [diff] [blame] | 187 | LoaderCallback callback, |
Ken Rockot | 387ddd5a | 2018-01-30 19:18:40 | [diff] [blame] | 188 | SingleRequestURLLoaderFactory::RequestHandler handler); |
Kinuko Yasuda | 8757204a | 2017-11-04 07:50:13 | [diff] [blame] | 189 | |
[email protected] | 3367fc1d | 2009-11-09 00:09:21 | [diff] [blame] | 190 | // Sub-resource loading ------------------------------------- |
[email protected] | 15f9cded | 2010-05-20 20:51:06 | [diff] [blame] | 191 | // Dedicated worker and all manner of sub-resources are handled here. |
[email protected] | 3367fc1d | 2009-11-09 00:09:21 | [diff] [blame] | 192 | |
ananta | 46f3e94 | 2017-05-09 04:56:30 | [diff] [blame] | 193 | std::unique_ptr<AppCacheJob> MaybeLoadSubResource( |
mmenke | 5289cbfd | 2015-10-29 19:36:17 | [diff] [blame] | 194 | net::NetworkDelegate* network_delegate); |
[email protected] | 3367fc1d | 2009-11-09 00:09:21 | [diff] [blame] | 195 | void ContinueMaybeLoadSubResource(); |
| 196 | |
| 197 | // AppCacheHost::Observer override |
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 198 | void OnCacheSelectionComplete(AppCacheHost* host) override; |
[email protected] | 3367fc1d | 2009-11-09 00:09:21 | [diff] [blame] | 199 | |
| 200 | // Data members ----------------------------------------------- |
| 201 | |
| 202 | // What host we're servicing a request for. |
[email protected] | 7e8e3dd | 2009-09-18 01:05:09 | [diff] [blame] | 203 | AppCacheHost* host_; |
[email protected] | 3367fc1d | 2009-11-09 00:09:21 | [diff] [blame] | 204 | |
[email protected] | 15f9cded | 2010-05-20 20:51:06 | [diff] [blame] | 205 | // Frame vs subresource vs sharedworker loads are somewhat different. |
[email protected] | 6c1e0521 | 2014-07-31 00:59:40 | [diff] [blame] | 206 | ResourceType resource_type_; |
[email protected] | 3367fc1d | 2009-11-09 00:09:21 | [diff] [blame] | 207 | |
eustas | 2787684 | 2014-11-27 10:48:00 | [diff] [blame] | 208 | // True if corresponding AppCache group should be resetted before load. |
| 209 | bool should_reset_appcache_; |
| 210 | |
[email protected] | 3367fc1d | 2009-11-09 00:09:21 | [diff] [blame] | 211 | // Subresource requests wait until after cache selection completes. |
| 212 | bool is_waiting_for_cache_selection_; |
| 213 | |
| 214 | // Info about the type of response we found for delivery. |
| 215 | // These are relevant for both main and subresource requests. |
avi | b734894 | 2015-12-25 20:57:10 | [diff] [blame] | 216 | int64_t found_group_id_; |
| 217 | int64_t found_cache_id_; |
[email protected] | 3367fc1d | 2009-11-09 00:09:21 | [diff] [blame] | 218 | AppCacheEntry found_entry_; |
| 219 | AppCacheEntry found_fallback_entry_; |
[email protected] | 2abcade | 2012-01-05 00:19:40 | [diff] [blame] | 220 | GURL found_namespace_entry_url_; |
[email protected] | 3367fc1d | 2009-11-09 00:09:21 | [diff] [blame] | 221 | GURL found_manifest_url_; |
| 222 | bool found_network_namespace_; |
| 223 | |
[email protected] | 1e1f7d5 | 2010-08-25 21:38:20 | [diff] [blame] | 224 | // True if a cache entry this handler attempted to return was |
| 225 | // not found in the disk cache. Once set, the handler will take |
| 226 | // no action on all subsequent intercept opportunities, so the |
| 227 | // request and any redirects will be handled by the network library. |
| 228 | bool cache_entry_not_found_; |
| 229 | |
mmenke | 5289cbfd | 2015-10-29 19:36:17 | [diff] [blame] | 230 | // True if the next time this request is started, the response should be |
| 231 | // delivered from the network, bypassing the AppCache. Cleared after the next |
| 232 | // intercept opportunity. |
| 233 | bool is_delivering_network_response_; |
| 234 | |
[email protected] | 17d64785 | 2012-09-08 17:45:52 | [diff] [blame] | 235 | // True if this->MaybeLoadResource(...) has been called in the past. |
| 236 | bool maybe_load_resource_executed_; |
| 237 | |
mmenke | 5289cbfd | 2015-10-29 19:36:17 | [diff] [blame] | 238 | // The job we use to deliver a response. Only NULL during the following times: |
| 239 | // 1) Before request has started a job. |
| 240 | // 2) Request is not being handled by appcache. |
| 241 | // 3) Request has been cancelled, and the job killed. |
ananta | 46f3e94 | 2017-05-09 04:56:30 | [diff] [blame] | 242 | base::WeakPtr<AppCacheJob> job_; |
[email protected] | 3367fc1d | 2009-11-09 00:09:21 | [diff] [blame] | 243 | |
mmenke | 5289cbfd | 2015-10-29 19:36:17 | [diff] [blame] | 244 | // Cached information about the response being currently served by the |
| 245 | // AppCache, if there is one. |
| 246 | int cache_id_; |
| 247 | GURL manifest_url_; |
| 248 | |
michaeln | b861840 | 2016-08-02 20:14:33 | [diff] [blame] | 249 | // Backptr to the central service object. |
| 250 | AppCacheServiceImpl* service_; |
| 251 | |
ananta | 4e8a529 | 2017-05-04 03:07:15 | [diff] [blame] | 252 | std::unique_ptr<AppCacheRequest> request_; |
| 253 | |
ananta | 2533bff6 | 2017-07-12 04:07:27 | [diff] [blame] | 254 | // Network service related members. |
| 255 | |
Clark DuVall | f77e164d | 2019-10-24 23:53:25 | [diff] [blame] | 256 | AppCacheLoaderCallback loader_callback_; |
ananta | a2c8ec6 | 2017-06-09 23:44:05 | [diff] [blame] | 257 | |
Kinuko Yasuda | 8757204a | 2017-11-04 07:50:13 | [diff] [blame] | 258 | // Flipped to true if AppCache wants to handle subresource requests |
Ken Rockot | 387ddd5a | 2018-01-30 19:18:40 | [diff] [blame] | 259 | // (i.e. when |loader_callback_| is fired with a non-null |
| 260 | // RequestHandler for non-error cases. |
Kinuko Yasuda | 8757204a | 2017-11-04 07:50:13 | [diff] [blame] | 261 | bool should_create_subresource_loader_ = false; |
| 262 | |
ananta | 2533bff6 | 2017-07-12 04:07:27 | [diff] [blame] | 263 | // The AppCache host instance. We pass this to the |
| 264 | // AppCacheSubresourceURLFactory instance on creation. |
| 265 | base::WeakPtr<AppCacheHost> appcache_host_; |
| 266 | |
Jeremy Roman | 3bca4bf | 2019-07-11 03:41:25 | [diff] [blame] | 267 | base::WeakPtrFactory<AppCacheRequestHandler> weak_factory_{this}; |
Kinuko Yasuda | 8757204a | 2017-11-04 07:50:13 | [diff] [blame] | 268 | |
[email protected] | 3367fc1d | 2009-11-09 00:09:21 | [diff] [blame] | 269 | DISALLOW_COPY_AND_ASSIGN(AppCacheRequestHandler); |
[email protected] | 97e3edc | 2009-09-15 22:07:15 | [diff] [blame] | 270 | }; |
| 271 | |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 272 | } // namespace content |
[email protected] | 97e3edc | 2009-09-15 22:07:15 | [diff] [blame] | 273 | |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 274 | #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ |