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