OLD | NEW |
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" |
20 #include "content/public/common/resource_type.h" | 21 #include "content/public/common/resource_type.h" |
21 | 22 |
22 namespace net { | 23 namespace net { |
23 class NetworkDelegate; | 24 class NetworkDelegate; |
24 class URLRequest; | 25 class URLRequest; |
25 } // namespace net | 26 } // namespace net |
26 | 27 |
27 namespace content { | 28 namespace content { |
28 class AppCacheJob; | 29 class AppCacheJob; |
| 30 class AppCacheNavigationHandleCore; |
29 class AppCacheRequest; | 31 class AppCacheRequest; |
30 class AppCacheRequestHandlerTest; | 32 class AppCacheRequestHandlerTest; |
31 class AppCacheURLRequestJob; | 33 class AppCacheURLRequestJob; |
| 34 class ResourceContext; |
32 | 35 |
33 // An instance is created for each net::URLRequest. The instance survives all | 36 // An instance is created for each net::URLRequest. The instance survives all |
34 // http transactions involved in the processing of its net::URLRequest, and is | 37 // http transactions involved in the processing of its net::URLRequest, and is |
35 // given the opportunity to hijack the request along the way. Callers | 38 // given the opportunity to hijack the request along the way. Callers |
36 // should use AppCacheHost::CreateRequestHandler to manufacture instances | 39 // should use AppCacheHost::CreateRequestHandler to manufacture instances |
37 // that can retrieve resources for a particular host. | 40 // that can retrieve resources for a particular host. |
38 class CONTENT_EXPORT AppCacheRequestHandler | 41 class CONTENT_EXPORT AppCacheRequestHandler |
39 : public base::SupportsUserData::Data, | 42 : public base::SupportsUserData::Data, |
40 public AppCacheHost::Observer, | 43 public AppCacheHost::Observer, |
41 public AppCacheServiceImpl::Observer, | 44 public AppCacheServiceImpl::Observer, |
(...skipping 20 matching lines...) Expand all Loading... |
62 // of cross site transfer navigations. | 65 // of cross site transfer navigations. |
63 bool SanityCheckIsSameService(AppCacheService* service) { | 66 bool SanityCheckIsSameService(AppCacheService* service) { |
64 return !host_ || (host_->service() == service); | 67 return !host_ || (host_->service() == service); |
65 } | 68 } |
66 | 69 |
67 static bool IsMainResourceType(ResourceType type) { | 70 static bool IsMainResourceType(ResourceType type) { |
68 return IsResourceTypeFrame(type) || | 71 return IsResourceTypeFrame(type) || |
69 type == RESOURCE_TYPE_SHARED_WORKER; | 72 type == RESOURCE_TYPE_SHARED_WORKER; |
70 } | 73 } |
71 | 74 |
| 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 |
72 private: | 89 private: |
73 friend class AppCacheHost; | 90 friend class AppCacheHost; |
74 | 91 |
75 // Callers should use AppCacheHost::CreateRequestHandler. | 92 // Callers should use AppCacheHost::CreateRequestHandler. |
76 AppCacheRequestHandler(AppCacheHost* host, | 93 AppCacheRequestHandler(AppCacheHost* host, |
77 ResourceType resource_type, | 94 ResourceType resource_type, |
78 bool should_reset_appcache, | 95 bool should_reset_appcache, |
79 std::unique_ptr<AppCacheRequest> request); | 96 std::unique_ptr<AppCacheRequest> request); |
80 | 97 |
81 // AppCacheHost::Observer override | 98 // AppCacheHost::Observer override |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 212 |
196 std::unique_ptr<AppCacheRequest> request_; | 213 std::unique_ptr<AppCacheRequest> request_; |
197 | 214 |
198 friend class content::AppCacheRequestHandlerTest; | 215 friend class content::AppCacheRequestHandlerTest; |
199 DISALLOW_COPY_AND_ASSIGN(AppCacheRequestHandler); | 216 DISALLOW_COPY_AND_ASSIGN(AppCacheRequestHandler); |
200 }; | 217 }; |
201 | 218 |
202 } // namespace content | 219 } // namespace content |
203 | 220 |
204 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ | 221 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ |
OLD | NEW |