Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: content/browser/appcache/appcache_request_handler.h

Issue 2956373002: Add support for subresource request loads in AppCache for the network service. (Closed)
Patch Set: Use the precreated AppCacheHost from the AppCacheNavigationHandleCore instance. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_REQUEST_HANDLER_H_ 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_HANDLER_H_
6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_HANDLER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/supports_user_data.h" 15 #include "base/supports_user_data.h"
16 #include "content/browser/appcache/appcache_entry.h" 16 #include "content/browser/appcache/appcache_entry.h"
17 #include "content/browser/appcache/appcache_host.h" 17 #include "content/browser/appcache/appcache_host.h"
18 #include "content/browser/appcache/appcache_service_impl.h" 18 #include "content/browser/appcache/appcache_service_impl.h"
19 #include "content/browser/appcache/appcache_subresource_url_factory.h"
19 #include "content/browser/loader/url_loader_request_handler.h" 20 #include "content/browser/loader/url_loader_request_handler.h"
20 #include "content/browser/url_loader_factory_getter.h" 21 #include "content/browser/url_loader_factory_getter.h"
21 #include "content/common/content_export.h" 22 #include "content/common/content_export.h"
22 #include "content/public/common/resource_type.h" 23 #include "content/public/common/resource_type.h"
23 24
24 namespace net { 25 namespace net {
25 class NetworkDelegate; 26 class NetworkDelegate;
26 class URLRequest; 27 class URLRequest;
27 } // namespace net 28 } // namespace net
28 29
29 namespace content { 30 namespace content {
30 class AppCacheJob; 31 class AppCacheJob;
31 class AppCacheNavigationHandleCore; 32 class AppCacheNavigationHandleCore;
32 class AppCacheRequest; 33 class AppCacheRequest;
33 class AppCacheRequestHandlerTest; 34 class AppCacheRequestHandlerTest;
34 class AppCacheURLRequestJob; 35 class AppCacheURLRequestJob;
35 struct ResourceRequest; 36 class AppCacheHost;
36 37
37 // An instance is created for each net::URLRequest. The instance survives all 38 // An instance is created for each net::URLRequest. The instance survives all
38 // http transactions involved in the processing of its net::URLRequest, and is 39 // http transactions involved in the processing of its net::URLRequest, and is
39 // given the opportunity to hijack the request along the way. Callers 40 // given the opportunity to hijack the request along the way. Callers
40 // should use AppCacheHost::CreateRequestHandler to manufacture instances 41 // should use AppCacheHost::CreateRequestHandler to manufacture instances
41 // that can retrieve resources for a particular host. 42 // that can retrieve resources for a particular host.
42 class CONTENT_EXPORT AppCacheRequestHandler 43 class CONTENT_EXPORT AppCacheRequestHandler
43 : public base::SupportsUserData::Data, 44 : public base::SupportsUserData::Data,
44 public AppCacheHost::Observer, 45 public AppCacheHost::Observer,
45 public AppCacheServiceImpl::Observer, 46 public AppCacheServiceImpl::Observer,
(...skipping 27 matching lines...) Expand all
73 return IsResourceTypeFrame(type) || 74 return IsResourceTypeFrame(type) ||
74 type == RESOURCE_TYPE_SHARED_WORKER; 75 type == RESOURCE_TYPE_SHARED_WORKER;
75 } 76 }
76 77
77 static std::unique_ptr<AppCacheRequestHandler> 78 static std::unique_ptr<AppCacheRequestHandler>
78 InitializeForNavigationNetworkService( 79 InitializeForNavigationNetworkService(
79 const ResourceRequest& request, 80 const ResourceRequest& request,
80 AppCacheNavigationHandleCore* appcache_handle_core, 81 AppCacheNavigationHandleCore* appcache_handle_core,
81 URLLoaderFactoryGetter* url_loader_factory_getter); 82 URLLoaderFactoryGetter* url_loader_factory_getter);
82 83
84 // The following setters only apply for the network service code.
85 void set_network_url_loader_factory_getter(
86 URLLoaderFactoryGetter* url_loader_factory_getter) {
87 network_url_loader_factory_getter_ = url_loader_factory_getter;
88 }
89
90 void set_subresource_request_load_info(
91 std::unique_ptr<SubresourceLoadInfo> subresource_load_info) {
92 subresource_load_info_ = std::move(subresource_load_info);
93 }
94
83 private: 95 private:
84 friend class AppCacheHost; 96 friend class AppCacheHost;
85 97
86 // Callers should use AppCacheHost::CreateRequestHandler. 98 // Callers should use AppCacheHost::CreateRequestHandler.
87 AppCacheRequestHandler(AppCacheHost* host, 99 AppCacheRequestHandler(AppCacheHost* host,
88 ResourceType resource_type, 100 ResourceType resource_type,
89 bool should_reset_appcache, 101 bool should_reset_appcache,
90 std::unique_ptr<AppCacheRequest> request); 102 std::unique_ptr<AppCacheRequest> request);
91 103
92 // AppCacheHost::Observer override 104 // AppCacheHost::Observer override
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 157
146 // AppCacheHost::Observer override 158 // AppCacheHost::Observer override
147 void OnCacheSelectionComplete(AppCacheHost* host) override; 159 void OnCacheSelectionComplete(AppCacheHost* host) override;
148 160
149 // URLLoaderRequestHandler override 161 // URLLoaderRequestHandler override
150 void MaybeCreateLoader(const ResourceRequest& resource_request, 162 void MaybeCreateLoader(const ResourceRequest& resource_request,
151 ResourceContext* resource_context, 163 ResourceContext* resource_context,
152 LoaderCallback callback) override; 164 LoaderCallback callback) override;
153 mojom::URLLoaderFactoryPtr MaybeCreateSubresourceFactory() override; 165 mojom::URLLoaderFactoryPtr MaybeCreateSubresourceFactory() override;
154 166
155 void set_network_url_loader_factory_getter(
156 URLLoaderFactoryGetter* url_loader_factory_getter) {
157 network_url_loader_factory_getter_ = url_loader_factory_getter;
158 }
159
160 // Data members ----------------------------------------------- 167 // Data members -----------------------------------------------
161 168
162 // What host we're servicing a request for. 169 // What host we're servicing a request for.
163 AppCacheHost* host_; 170 AppCacheHost* host_;
164 171
165 // Frame vs subresource vs sharedworker loads are somewhat different. 172 // Frame vs subresource vs sharedworker loads are somewhat different.
166 ResourceType resource_type_; 173 ResourceType resource_type_;
167 174
168 // True if corresponding AppCache group should be resetted before load. 175 // True if corresponding AppCache group should be resetted before load.
169 bool should_reset_appcache_; 176 bool should_reset_appcache_;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // Cached information about the response being currently served by the 217 // Cached information about the response being currently served by the
211 // AppCache, if there is one. 218 // AppCache, if there is one.
212 int cache_id_; 219 int cache_id_;
213 GURL manifest_url_; 220 GURL manifest_url_;
214 221
215 // Backptr to the central service object. 222 // Backptr to the central service object.
216 AppCacheServiceImpl* service_; 223 AppCacheServiceImpl* service_;
217 224
218 std::unique_ptr<AppCacheRequest> request_; 225 std::unique_ptr<AppCacheRequest> request_;
219 226
227 // Network service related members.
228
220 // In the network service world we are queried via the URLLoaderRequestHandler 229 // In the network service world we are queried via the URLLoaderRequestHandler
221 // interface to see if the navigation request can be handled via the 230 // interface to see if the navigation request can be handled via the
222 // AppCache. We hold onto the AppCache job created here until the client 231 // AppCache. We hold onto the AppCache job created here until the client
223 // binds to it (Serviced via AppCache). If the request cannot be handled via 232 // binds to it (Serviced via AppCache). If the request cannot be handled via
224 // the AppCache, we delete the job. 233 // the AppCache, we delete the job.
225 std::unique_ptr<AppCacheJob> navigation_request_job_; 234 std::unique_ptr<AppCacheJob> navigation_request_job_;
226 235
227 // In the network service world, points to the getter for the network URL 236 // In the network service world, points to the getter for the network URL
228 // loader. 237 // loader.
229 scoped_refptr<URLLoaderFactoryGetter> network_url_loader_factory_getter_; 238 scoped_refptr<URLLoaderFactoryGetter> network_url_loader_factory_getter_;
230 239
231 friend class content::AppCacheRequestHandlerTest; 240 friend class content::AppCacheRequestHandlerTest;
232 241
242 // Subresource load information.
243 std::unique_ptr<SubresourceLoadInfo> subresource_load_info_;
244
245 // The AppCache host instance. We pass this to the
246 // AppCacheSubresourceURLFactory instance on creation.
247 base::WeakPtr<AppCacheHost> appcache_host_;
248
233 DISALLOW_COPY_AND_ASSIGN(AppCacheRequestHandler); 249 DISALLOW_COPY_AND_ASSIGN(AppCacheRequestHandler);
234 }; 250 };
235 251
236 } // namespace content 252 } // namespace content
237 253
238 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ 254 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698