| 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 "content/browser/appcache/appcache_request_handler.h" | 5 #include "content/browser/appcache/appcache_request_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "content/browser/appcache/appcache.h" | 8 #include "content/browser/appcache/appcache.h" |
| 9 #include "content/browser/appcache/appcache_backend_impl.h" | 9 #include "content/browser/appcache/appcache_backend_impl.h" |
| 10 #include "content/browser/appcache/appcache_policy.h" | 10 #include "content/browser/appcache/appcache_policy.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 168 |
| 169 // 6.9.6, step 4: If this results in a 4xx or 5xx status code | 169 // 6.9.6, step 4: If this results in a 4xx or 5xx status code |
| 170 // or there were network errors, get the resource of the fallback entry. | 170 // or there were network errors, get the resource of the fallback entry. |
| 171 scoped_ptr<AppCacheURLRequestJob> job = CreateJob(request, network_delegate); | 171 scoped_ptr<AppCacheURLRequestJob> job = CreateJob(request, network_delegate); |
| 172 DeliverAppCachedResponse( | 172 DeliverAppCachedResponse( |
| 173 found_fallback_entry_, found_cache_id_, found_group_id_, | 173 found_fallback_entry_, found_cache_id_, found_group_id_, |
| 174 found_manifest_url_, true, found_namespace_entry_url_); | 174 found_manifest_url_, true, found_namespace_entry_url_); |
| 175 return job.release(); | 175 return job.release(); |
| 176 } | 176 } |
| 177 | 177 |
| 178 void AppCacheRequestHandler::GetExtraResponseInfo( | 178 void AppCacheRequestHandler::GetExtraResponseInfo(int64_t* cache_id, |
| 179 int64* cache_id, GURL* manifest_url) { | 179 GURL* manifest_url) { |
| 180 *cache_id = cache_id_; | 180 *cache_id = cache_id_; |
| 181 *manifest_url = manifest_url_; | 181 *manifest_url = manifest_url_; |
| 182 } | 182 } |
| 183 | 183 |
| 184 void AppCacheRequestHandler::PrepareForCrossSiteTransfer(int old_process_id) { | 184 void AppCacheRequestHandler::PrepareForCrossSiteTransfer(int old_process_id) { |
| 185 if (!host_) | 185 if (!host_) |
| 186 return; | 186 return; |
| 187 AppCacheBackendImpl* backend = host_->service()->GetBackend(old_process_id); | 187 AppCacheBackendImpl* backend = host_->service()->GetBackend(old_process_id); |
| 188 old_process_id_ = old_process_id; | 188 old_process_id_ = old_process_id; |
| 189 old_host_id_ = host_->host_id(); | 189 old_host_id_ = host_->host_id(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 215 | 215 |
| 216 // Since the host is being deleted, we don't have to complete any job | 216 // Since the host is being deleted, we don't have to complete any job |
| 217 // that is current running. It's destined for the bit bucket anyway. | 217 // that is current running. It's destined for the bit bucket anyway. |
| 218 if (job_.get()) { | 218 if (job_.get()) { |
| 219 job_->Kill(); | 219 job_->Kill(); |
| 220 job_.reset(); | 220 job_.reset(); |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 | 223 |
| 224 void AppCacheRequestHandler::DeliverAppCachedResponse( | 224 void AppCacheRequestHandler::DeliverAppCachedResponse( |
| 225 const AppCacheEntry& entry, int64 cache_id, int64 group_id, | 225 const AppCacheEntry& entry, |
| 226 const GURL& manifest_url, bool is_fallback, | 226 int64_t cache_id, |
| 227 int64_t group_id, |
| 228 const GURL& manifest_url, |
| 229 bool is_fallback, |
| 227 const GURL& namespace_entry_url) { | 230 const GURL& namespace_entry_url) { |
| 228 DCHECK(host_ && job_.get() && job_->is_waiting()); | 231 DCHECK(host_ && job_.get() && job_->is_waiting()); |
| 229 DCHECK(entry.has_response_id()); | 232 DCHECK(entry.has_response_id()); |
| 230 | 233 |
| 231 // Cache information about the response, for use by GetExtraResponseInfo. | 234 // Cache information about the response, for use by GetExtraResponseInfo. |
| 232 cache_id_ = cache_id; | 235 cache_id_ = cache_id; |
| 233 manifest_url_ = manifest_url; | 236 manifest_url_ = manifest_url; |
| 234 | 237 |
| 235 if (IsResourceTypeFrame(resource_type_) && !namespace_entry_url.is_empty()) | 238 if (IsResourceTypeFrame(resource_type_) && !namespace_entry_url.is_empty()) |
| 236 host_->NotifyMainResourceIsNamespaceEntry(namespace_entry_url); | 239 host_->NotifyMainResourceIsNamespaceEntry(namespace_entry_url); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 | 309 |
| 307 // We may have to wait for our storage query to complete, but | 310 // We may have to wait for our storage query to complete, but |
| 308 // this query can also complete syncrhonously. | 311 // this query can also complete syncrhonously. |
| 309 scoped_ptr<AppCacheURLRequestJob> job = CreateJob(request, network_delegate); | 312 scoped_ptr<AppCacheURLRequestJob> job = CreateJob(request, network_delegate); |
| 310 storage()->FindResponseForMainRequest( | 313 storage()->FindResponseForMainRequest( |
| 311 request->url(), preferred_manifest_url, this); | 314 request->url(), preferred_manifest_url, this); |
| 312 return job; | 315 return job; |
| 313 } | 316 } |
| 314 | 317 |
| 315 void AppCacheRequestHandler::OnMainResponseFound( | 318 void AppCacheRequestHandler::OnMainResponseFound( |
| 316 const GURL& url, const AppCacheEntry& entry, | 319 const GURL& url, |
| 317 const GURL& namespace_entry_url, const AppCacheEntry& fallback_entry, | 320 const AppCacheEntry& entry, |
| 318 int64 cache_id, int64 group_id, const GURL& manifest_url) { | 321 const GURL& namespace_entry_url, |
| 322 const AppCacheEntry& fallback_entry, |
| 323 int64_t cache_id, |
| 324 int64_t group_id, |
| 325 const GURL& manifest_url) { |
| 319 DCHECK(host_); | 326 DCHECK(host_); |
| 320 DCHECK(is_main_resource()); | 327 DCHECK(is_main_resource()); |
| 321 DCHECK(!entry.IsForeign()); | 328 DCHECK(!entry.IsForeign()); |
| 322 DCHECK(!fallback_entry.IsForeign()); | 329 DCHECK(!fallback_entry.IsForeign()); |
| 323 DCHECK(!(entry.has_response_id() && fallback_entry.has_response_id())); | 330 DCHECK(!(entry.has_response_id() && fallback_entry.has_response_id())); |
| 324 | 331 |
| 325 // Request may have been canceled, but not yet deleted, while waiting on | 332 // Request may have been canceled, but not yet deleted, while waiting on |
| 326 // the cache. | 333 // the cache. |
| 327 if (!job_.get()) | 334 if (!job_.get()) |
| 328 return; | 335 return; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 if (!host_->associated_cache() || | 477 if (!host_->associated_cache() || |
| 471 !host_->associated_cache()->is_complete()) { | 478 !host_->associated_cache()->is_complete()) { |
| 472 DeliverNetworkResponse(); | 479 DeliverNetworkResponse(); |
| 473 return; | 480 return; |
| 474 } | 481 } |
| 475 | 482 |
| 476 ContinueMaybeLoadSubResource(); | 483 ContinueMaybeLoadSubResource(); |
| 477 } | 484 } |
| 478 | 485 |
| 479 } // namespace content | 486 } // namespace content |
| OLD | NEW |