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 #include "webkit/appcache/appcache_request_handler.h" | 5 #include "webkit/appcache/appcache_request_handler.h" |
6 | 6 |
7 #include "net/url_request/url_request.h" | 7 #include "net/url_request/url_request.h" |
8 #include "net/url_request/url_request_job.h" | 8 #include "net/url_request/url_request_job.h" |
9 #include "webkit/appcache/appcache.h" | 9 #include "webkit/appcache/appcache.h" |
10 #include "webkit/appcache/appcache_policy.h" | |
10 #include "webkit/appcache/appcache_url_request_job.h" | 11 #include "webkit/appcache/appcache_url_request_job.h" |
11 | 12 |
12 namespace appcache { | 13 namespace appcache { |
13 | 14 |
14 AppCacheRequestHandler::AppCacheRequestHandler(AppCacheHost* host, | 15 AppCacheRequestHandler::AppCacheRequestHandler(AppCacheHost* host, |
15 ResourceType::Type resource_type) | 16 ResourceType::Type resource_type) |
16 : host_(host), resource_type_(resource_type), | 17 : host_(host), resource_type_(resource_type), |
17 is_waiting_for_cache_selection_(false), found_cache_id_(0), | 18 is_waiting_for_cache_selection_(false), found_cache_id_(0), |
18 found_network_namespace_(false), cache_entry_not_found_(false) { | 19 found_network_namespace_(false), cache_entry_not_found_(false) { |
19 DCHECK(host_); | 20 DCHECK(host_); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 // We may have to wait for our storage query to complete, but | 210 // We may have to wait for our storage query to complete, but |
210 // this query can also complete syncrhonously. | 211 // this query can also complete syncrhonously. |
211 job_ = new AppCacheURLRequestJob(request, storage()); | 212 job_ = new AppCacheURLRequestJob(request, storage()); |
212 storage()->FindResponseForMainRequest( | 213 storage()->FindResponseForMainRequest( |
213 request->url(), preferred_manifest_url, this); | 214 request->url(), preferred_manifest_url, this); |
214 } | 215 } |
215 | 216 |
216 void AppCacheRequestHandler::OnMainResponseFound( | 217 void AppCacheRequestHandler::OnMainResponseFound( |
217 const GURL& url, const AppCacheEntry& entry, | 218 const GURL& url, const AppCacheEntry& entry, |
218 const GURL& fallback_url, const AppCacheEntry& fallback_entry, | 219 const GURL& fallback_url, const AppCacheEntry& fallback_entry, |
219 int64 cache_id, const GURL& manifest_url, | 220 int64 cache_id, const GURL& manifest_url) { |
220 bool was_blocked_by_policy) { | |
221 DCHECK(host_); | 221 DCHECK(host_); |
222 DCHECK(is_main_resource()); | 222 DCHECK(is_main_resource()); |
223 DCHECK(!entry.IsForeign()); | 223 DCHECK(!entry.IsForeign()); |
224 DCHECK(!fallback_entry.IsForeign()); | 224 DCHECK(!fallback_entry.IsForeign()); |
225 DCHECK(!(entry.has_response_id() && fallback_entry.has_response_id())); | 225 DCHECK(!(entry.has_response_id() && fallback_entry.has_response_id())); |
226 | 226 |
227 AppCachePolicy* policy = host_->service()->appcache_policy(); | |
228 bool was_blocked_by_policy = policy && | |
229 !policy->CanLoadAppCache(manifest_url, host_->first_party_url()); | |
michaeln
2011/09/02 18:47:47
in most cases (the "nothing was found" case), mani
marja
2011/09/05 10:42:24
Ok, in the current code in AppCacheStorageImpl::Ch
| |
230 | |
227 if (ResourceType::IsFrame(resource_type_)) { | 231 if (ResourceType::IsFrame(resource_type_)) { |
228 if (was_blocked_by_policy) | 232 if (was_blocked_by_policy) |
229 host_->NotifyMainResourceBlocked(manifest_url); | 233 host_->NotifyMainResourceBlocked(manifest_url); |
230 | 234 |
231 if (cache_id != kNoCacheId) { | 235 if (cache_id != kNoCacheId) { |
232 // AppCacheHost loads and holds a reference to the main resource cache | 236 // AppCacheHost loads and holds a reference to the main resource cache |
233 // for two reasons, firstly to preload the cache into the working set | 237 // for two reasons, firstly to preload the cache into the working set |
234 // in advance of subresource loads happening, secondly to prevent the | 238 // in advance of subresource loads happening, secondly to prevent the |
235 // AppCache from falling out of the working set on frame navigations. | 239 // AppCache from falling out of the working set on frame navigations. |
236 host_->LoadMainResourceCache(cache_id); | 240 host_->LoadMainResourceCache(cache_id); |
michaeln
2011/08/31 23:42:08
we shouldn't do these things if 'blocked'
marja
2011/09/02 13:40:24
Hmm, I don't understand. They were done when the w
michaeln
2011/09/02 18:47:47
Here's the current callsite for OnMainResponseFoun
marja
2011/09/05 10:42:24
Ah, of course, thanks.
| |
237 host_->set_preferred_manifest_url(manifest_url); | 241 host_->set_preferred_manifest_url(manifest_url); |
238 } | 242 } |
239 } else { | 243 } else { |
240 DCHECK(ResourceType::IsSharedWorker(resource_type_)); | 244 DCHECK(ResourceType::IsSharedWorker(resource_type_)); |
241 if (was_blocked_by_policy) | 245 if (was_blocked_by_policy) |
242 host_->frontend()->OnContentBlocked(host_->host_id(), manifest_url); | 246 host_->frontend()->OnContentBlocked(host_->host_id(), manifest_url); |
243 } | 247 } |
244 | 248 |
245 // 6.11.1 Navigating across documents, steps 10 and 14. | 249 // 6.11.1 Navigating across documents, steps 10 and 14. |
246 | 250 |
247 found_entry_ = entry; | 251 found_entry_ = entry; |
michaeln
2011/08/31 23:42:08
if was_blocked, these data members cannot be set t
marja
2011/09/02 13:40:24
Done.
| |
248 found_fallback_url_ = fallback_url; | 252 found_fallback_url_ = fallback_url; |
249 found_fallback_entry_ = fallback_entry; | 253 found_fallback_entry_ = fallback_entry; |
250 found_cache_id_ = cache_id; | 254 found_cache_id_ = cache_id; |
251 found_manifest_url_ = manifest_url; | 255 found_manifest_url_ = manifest_url; |
252 found_network_namespace_ = false; // not applicable to main requests | 256 found_network_namespace_ = false; // not applicable to main requests |
253 | 257 |
254 if (found_entry_.has_response_id()) { | 258 if (found_entry_.has_response_id()) { |
255 DeliverAppCachedResponse( | 259 DeliverAppCachedResponse( |
256 found_entry_, found_cache_id_, found_manifest_url_, | 260 found_entry_, found_cache_id_, found_manifest_url_, |
257 false, GURL()); | 261 false, GURL()); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
344 if (!host_->associated_cache() || | 348 if (!host_->associated_cache() || |
345 !host_->associated_cache()->is_complete()) { | 349 !host_->associated_cache()->is_complete()) { |
346 DeliverNetworkResponse(); | 350 DeliverNetworkResponse(); |
347 return; | 351 return; |
348 } | 352 } |
349 | 353 |
350 ContinueMaybeLoadSubResource(); | 354 ContinueMaybeLoadSubResource(); |
351 } | 355 } |
352 | 356 |
353 } // namespace appcache | 357 } // namespace appcache |
OLD | NEW |