OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "content/browser/appcache/appcache_interceptor.h" | 5 #include "content/browser/appcache/appcache_interceptor.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/debug/crash_logging.h" | 9 #include "base/debug/crash_logging.h" |
10 #include "content/browser/appcache/appcache_backend_impl.h" | 10 #include "content/browser/appcache/appcache_backend_impl.h" |
11 #include "content/browser/appcache/appcache_host.h" | 11 #include "content/browser/appcache/appcache_host.h" |
12 #include "content/browser/appcache/appcache_request_handler.h" | 12 #include "content/browser/appcache/appcache_request_handler.h" |
13 #include "content/browser/appcache/appcache_service_impl.h" | 13 #include "content/browser/appcache/appcache_service_impl.h" |
| 14 #include "content/browser/appcache/appcache_url_request.h" |
14 #include "content/browser/appcache/appcache_url_request_job.h" | 15 #include "content/browser/appcache/appcache_url_request_job.h" |
15 #include "content/browser/appcache/chrome_appcache_service.h" | 16 #include "content/browser/appcache/chrome_appcache_service.h" |
16 #include "content/browser/bad_message.h" | 17 #include "content/browser/bad_message.h" |
17 #include "content/browser/loader/resource_message_filter.h" | 18 #include "content/browser/loader/resource_message_filter.h" |
18 #include "content/browser/loader/resource_requester_info.h" | 19 #include "content/browser/loader/resource_requester_info.h" |
19 #include "content/common/appcache_interfaces.h" | 20 #include "content/common/appcache_interfaces.h" |
20 #include "net/url_request/url_request.h" | 21 #include "net/url_request/url_request.h" |
21 | 22 |
22 static int kHandlerKey; // Value is not used. | 23 static int kHandlerKey; // Value is not used. |
23 | 24 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 should_reset_appcache); | 59 should_reset_appcache); |
59 } | 60 } |
60 | 61 |
61 void AppCacheInterceptor::SetExtraRequestInfoForHost( | 62 void AppCacheInterceptor::SetExtraRequestInfoForHost( |
62 net::URLRequest* request, | 63 net::URLRequest* request, |
63 AppCacheHost* host, | 64 AppCacheHost* host, |
64 ResourceType resource_type, | 65 ResourceType resource_type, |
65 bool should_reset_appcache) { | 66 bool should_reset_appcache) { |
66 // Create a handler for this request and associate it with the request. | 67 // Create a handler for this request and associate it with the request. |
67 std::unique_ptr<AppCacheRequestHandler> handler = | 68 std::unique_ptr<AppCacheRequestHandler> handler = |
68 host->CreateRequestHandler(request, resource_type, should_reset_appcache); | 69 host->CreateRequestHandler(AppCacheURLRequest::Create(request), |
| 70 resource_type, should_reset_appcache); |
69 if (handler) | 71 if (handler) |
70 SetHandler(request, std::move(handler)); | 72 SetHandler(request, std::move(handler)); |
71 } | 73 } |
72 | 74 |
73 void AppCacheInterceptor::GetExtraResponseInfo(net::URLRequest* request, | 75 void AppCacheInterceptor::GetExtraResponseInfo(net::URLRequest* request, |
74 int64_t* cache_id, | 76 int64_t* cache_id, |
75 GURL* manifest_url) { | 77 GURL* manifest_url) { |
76 DCHECK(*cache_id == kAppCacheNoCacheId); | 78 DCHECK(*cache_id == kAppCacheNoCacheId); |
77 DCHECK(manifest_url->is_empty()); | 79 DCHECK(manifest_url->is_empty()); |
78 AppCacheRequestHandler* handler = GetHandler(request); | 80 AppCacheRequestHandler* handler = GetHandler(request); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 } | 136 } |
135 | 137 |
136 AppCacheInterceptor::~AppCacheInterceptor() { | 138 AppCacheInterceptor::~AppCacheInterceptor() { |
137 } | 139 } |
138 | 140 |
139 net::URLRequestJob* AppCacheInterceptor::MaybeInterceptRequest( | 141 net::URLRequestJob* AppCacheInterceptor::MaybeInterceptRequest( |
140 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { | 142 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { |
141 AppCacheRequestHandler* handler = GetHandler(request); | 143 AppCacheRequestHandler* handler = GetHandler(request); |
142 if (!handler) | 144 if (!handler) |
143 return NULL; | 145 return NULL; |
144 return handler->MaybeLoadResource(request, network_delegate); | 146 return handler->MaybeLoadResource(network_delegate); |
145 } | 147 } |
146 | 148 |
147 net::URLRequestJob* AppCacheInterceptor::MaybeInterceptRedirect( | 149 net::URLRequestJob* AppCacheInterceptor::MaybeInterceptRedirect( |
148 net::URLRequest* request, | 150 net::URLRequest* request, |
149 net::NetworkDelegate* network_delegate, | 151 net::NetworkDelegate* network_delegate, |
150 const GURL& location) const { | 152 const GURL& location) const { |
151 AppCacheRequestHandler* handler = GetHandler(request); | 153 AppCacheRequestHandler* handler = GetHandler(request); |
152 if (!handler) | 154 if (!handler) |
153 return NULL; | 155 return NULL; |
154 return handler->MaybeLoadFallbackForRedirect( | 156 return handler->MaybeLoadFallbackForRedirect(network_delegate, location); |
155 request, network_delegate, location); | |
156 } | 157 } |
157 | 158 |
158 net::URLRequestJob* AppCacheInterceptor::MaybeInterceptResponse( | 159 net::URLRequestJob* AppCacheInterceptor::MaybeInterceptResponse( |
159 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { | 160 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { |
160 AppCacheRequestHandler* handler = GetHandler(request); | 161 AppCacheRequestHandler* handler = GetHandler(request); |
161 if (!handler) | 162 if (!handler) |
162 return NULL; | 163 return NULL; |
163 return handler->MaybeLoadFallbackForResponse(request, network_delegate); | 164 return handler->MaybeLoadFallbackForResponse(network_delegate); |
164 } | 165 } |
165 | 166 |
166 } // namespace content | 167 } // namespace content |
OLD | NEW |