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

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

Issue 2891773002: Add a stub implementation of the URLLoaderFactory for AppCache. (Closed)
Patch Set: Address final round of comments Created 3 years, 7 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/common/content_export.h" 19 #include "content/common/content_export.h"
20 #include "content/common/url_loader_factory.mojom.h"
21 #include "content/public/common/resource_type.h" 20 #include "content/public/common/resource_type.h"
22 21
23 namespace net { 22 namespace net {
24 class NetworkDelegate; 23 class NetworkDelegate;
25 class URLRequest; 24 class URLRequest;
26 } // namespace net 25 } // namespace net
27 26
28 namespace content { 27 namespace content {
29 class AppCacheJob; 28 class AppCacheJob;
30 class AppCacheNavigationHandleCore;
31 class AppCacheRequest; 29 class AppCacheRequest;
32 class AppCacheRequestHandlerTest; 30 class AppCacheRequestHandlerTest;
33 class AppCacheURLRequestJob; 31 class AppCacheURLRequestJob;
34 class ResourceContext;
35 32
36 // An instance is created for each net::URLRequest. The instance survives all 33 // An instance is created for each net::URLRequest. The instance survives all
37 // http transactions involved in the processing of its net::URLRequest, and is 34 // http transactions involved in the processing of its net::URLRequest, and is
38 // given the opportunity to hijack the request along the way. Callers 35 // given the opportunity to hijack the request along the way. Callers
39 // should use AppCacheHost::CreateRequestHandler to manufacture instances 36 // should use AppCacheHost::CreateRequestHandler to manufacture instances
40 // that can retrieve resources for a particular host. 37 // that can retrieve resources for a particular host.
41 class CONTENT_EXPORT AppCacheRequestHandler 38 class CONTENT_EXPORT AppCacheRequestHandler
42 : public base::SupportsUserData::Data, 39 : public base::SupportsUserData::Data,
43 public AppCacheHost::Observer, 40 public AppCacheHost::Observer,
44 public AppCacheServiceImpl::Observer, 41 public AppCacheServiceImpl::Observer,
(...skipping 20 matching lines...) Expand all
65 // of cross site transfer navigations. 62 // of cross site transfer navigations.
66 bool SanityCheckIsSameService(AppCacheService* service) { 63 bool SanityCheckIsSameService(AppCacheService* service) {
67 return !host_ || (host_->service() == service); 64 return !host_ || (host_->service() == service);
68 } 65 }
69 66
70 static bool IsMainResourceType(ResourceType type) { 67 static bool IsMainResourceType(ResourceType type) {
71 return IsResourceTypeFrame(type) || 68 return IsResourceTypeFrame(type) ||
72 type == RESOURCE_TYPE_SHARED_WORKER; 69 type == RESOURCE_TYPE_SHARED_WORKER;
73 } 70 }
74 71
75 // PlzNavigate and --enable-network-service.
76 // Checks whether the |resource_request| can be served out of the AppCache
77 // and invokes the |callback| accordingly. If the request can be served
78 // out of the AppCache, we could return a URLLoaderFactory which can serve
79 // requests out of the AppCache to the callback, or we could create the
80 // loader right there. At this point we are leaning towards the latter.
81 static void InitializeForNavigationNetworkService(
82 std::unique_ptr<ResourceRequest> resource_request,
83 ResourceContext* resource_context,
84 AppCacheNavigationHandleCore* navigation_handle_core,
85 ResourceType resource_type,
86 base::Callback<void(mojom::URLLoaderFactoryPtrInfo,
87 std::unique_ptr<ResourceRequest>)> callback);
88
89 private: 72 private:
90 friend class AppCacheHost; 73 friend class AppCacheHost;
91 74
92 // Callers should use AppCacheHost::CreateRequestHandler. 75 // Callers should use AppCacheHost::CreateRequestHandler.
93 AppCacheRequestHandler(AppCacheHost* host, 76 AppCacheRequestHandler(AppCacheHost* host,
94 ResourceType resource_type, 77 ResourceType resource_type,
95 bool should_reset_appcache, 78 bool should_reset_appcache,
96 std::unique_ptr<AppCacheRequest> request); 79 std::unique_ptr<AppCacheRequest> request);
97 80
98 // AppCacheHost::Observer override 81 // AppCacheHost::Observer override
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 195
213 std::unique_ptr<AppCacheRequest> request_; 196 std::unique_ptr<AppCacheRequest> request_;
214 197
215 friend class content::AppCacheRequestHandlerTest; 198 friend class content::AppCacheRequestHandlerTest;
216 DISALLOW_COPY_AND_ASSIGN(AppCacheRequestHandler); 199 DISALLOW_COPY_AND_ASSIGN(AppCacheRequestHandler);
217 }; 200 };
218 201
219 } // namespace content 202 } // namespace content
220 203
221 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ 204 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_HANDLER_H_
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_network_service_handler.cc ('k') | content/browser/appcache/appcache_request_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698