| 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_url_request_job.h" | 10 #include "webkit/appcache/appcache_url_request_job.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // earlier call thru this method. To send the request thru | 51 // earlier call thru this method. To send the request thru |
| 52 // to the network involves restarting the request altogether, | 52 // to the network involves restarting the request altogether, |
| 53 // which will call thru to our interception layer again. | 53 // which will call thru to our interception layer again. |
| 54 // This time thru, we return NULL so the request hits the wire. | 54 // This time thru, we return NULL so the request hits the wire. |
| 55 if (job_) { | 55 if (job_) { |
| 56 DCHECK(job_->is_delivering_network_response() || | 56 DCHECK(job_->is_delivering_network_response() || |
| 57 job_->cache_entry_not_found()); | 57 job_->cache_entry_not_found()); |
| 58 if (job_->cache_entry_not_found()) | 58 if (job_->cache_entry_not_found()) |
| 59 cache_entry_not_found_ = true; | 59 cache_entry_not_found_ = true; |
| 60 job_ = NULL; | 60 job_ = NULL; |
| 61 storage()->CancelDelegateCallbacks(this); |
| 61 return NULL; | 62 return NULL; |
| 62 } | 63 } |
| 63 | 64 |
| 64 // Clear out our 'found' fields since we're starting a request for a | 65 // Clear out our 'found' fields since we're starting a request for a |
| 65 // new resource, any values in those fields are no longer valid. | 66 // new resource, any values in those fields are no longer valid. |
| 66 found_entry_ = AppCacheEntry(); | 67 found_entry_ = AppCacheEntry(); |
| 67 found_fallback_entry_ = AppCacheEntry(); | 68 found_fallback_entry_ = AppCacheEntry(); |
| 68 found_cache_id_ = kNoCacheId; | 69 found_cache_id_ = kNoCacheId; |
| 69 found_manifest_url_ = GURL(); | 70 found_manifest_url_ = GURL(); |
| 70 found_network_namespace_ = false; | 71 found_network_namespace_ = false; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 bool was_blocked_by_policy) { |
| 222 DCHECK(job_); |
| 221 DCHECK(host_); | 223 DCHECK(host_); |
| 222 DCHECK(is_main_resource()); | 224 DCHECK(is_main_resource()); |
| 223 DCHECK(!entry.IsForeign()); | 225 DCHECK(!entry.IsForeign()); |
| 224 DCHECK(!fallback_entry.IsForeign()); | 226 DCHECK(!fallback_entry.IsForeign()); |
| 225 DCHECK(!(entry.has_response_id() && fallback_entry.has_response_id())); | 227 DCHECK(!(entry.has_response_id() && fallback_entry.has_response_id())); |
| 226 | 228 |
| 229 if (!job_) |
| 230 return; |
| 231 |
| 227 if (ResourceType::IsFrame(resource_type_)) { | 232 if (ResourceType::IsFrame(resource_type_)) { |
| 228 if (was_blocked_by_policy) | 233 if (was_blocked_by_policy) |
| 229 host_->NotifyMainResourceBlocked(manifest_url); | 234 host_->NotifyMainResourceBlocked(manifest_url); |
| 230 | 235 |
| 231 if (cache_id != kNoCacheId) { | 236 if (cache_id != kNoCacheId) { |
| 232 // AppCacheHost loads and holds a reference to the main resource cache | 237 // AppCacheHost loads and holds a reference to the main resource cache |
| 233 // for two reasons, firstly to preload the cache into the working set | 238 // for two reasons, firstly to preload the cache into the working set |
| 234 // in advance of subresource loads happening, secondly to prevent the | 239 // in advance of subresource loads happening, secondly to prevent the |
| 235 // AppCache from falling out of the working set on frame navigations. | 240 // AppCache from falling out of the working set on frame navigations. |
| 236 host_->LoadMainResourceCache(cache_id); | 241 host_->LoadMainResourceCache(cache_id); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 if (!host_->associated_cache() || | 349 if (!host_->associated_cache() || |
| 345 !host_->associated_cache()->is_complete()) { | 350 !host_->associated_cache()->is_complete()) { |
| 346 DeliverNetworkResponse(); | 351 DeliverNetworkResponse(); |
| 347 return; | 352 return; |
| 348 } | 353 } |
| 349 | 354 |
| 350 ContinueMaybeLoadSubResource(); | 355 ContinueMaybeLoadSubResource(); |
| 351 } | 356 } |
| 352 | 357 |
| 353 } // namespace appcache | 358 } // namespace appcache |
| OLD | NEW |