| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_update_job.h" | 5 #include "content/browser/appcache/appcache_update_job.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 weak_factory_(this) { | 398 weak_factory_(this) { |
| 399 service_->AddObserver(this); | 399 service_->AddObserver(this); |
| 400 } | 400 } |
| 401 | 401 |
| 402 AppCacheUpdateJob::~AppCacheUpdateJob() { | 402 AppCacheUpdateJob::~AppCacheUpdateJob() { |
| 403 if (service_) | 403 if (service_) |
| 404 service_->RemoveObserver(this); | 404 service_->RemoveObserver(this); |
| 405 if (internal_state_ != COMPLETED) | 405 if (internal_state_ != COMPLETED) |
| 406 Cancel(); | 406 Cancel(); |
| 407 | 407 |
| 408 DCHECK(!manifest_fetcher_); | |
| 409 DCHECK(pending_url_fetches_.empty()); | |
| 410 DCHECK(!inprogress_cache_.get()); | 408 DCHECK(!inprogress_cache_.get()); |
| 411 DCHECK(pending_master_entries_.empty()); | 409 DCHECK(pending_master_entries_.empty()); |
| 412 DCHECK(master_entry_fetches_.empty()); | 410 |
| 411 // The job must not outlive any of its fetchers. |
| 412 CHECK(!manifest_fetcher_); |
| 413 CHECK(pending_url_fetches_.empty()); |
| 414 CHECK(master_entry_fetches_.empty()); |
| 413 | 415 |
| 414 if (group_) | 416 if (group_) |
| 415 group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE); | 417 group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE); |
| 416 } | 418 } |
| 417 | 419 |
| 418 void AppCacheUpdateJob::StartUpdate(AppCacheHost* host, | 420 void AppCacheUpdateJob::StartUpdate(AppCacheHost* host, |
| 419 const GURL& new_master_resource) { | 421 const GURL& new_master_resource) { |
| 420 DCHECK(group_->update_job() == this); | 422 DCHECK(group_->update_job() == this); |
| 421 DCHECK(!group_->is_obsolete()); | 423 DCHECK(!group_->is_obsolete()); |
| 422 | 424 |
| 423 bool is_new_pending_master_entry = false; | 425 bool is_new_pending_master_entry = false; |
| 424 if (!new_master_resource.is_empty()) { | 426 if (!new_master_resource.is_empty()) { |
| 425 DCHECK(new_master_resource == host->pending_master_entry_url()); | 427 DCHECK(new_master_resource == host->pending_master_entry_url()); |
| 426 DCHECK(!new_master_resource.has_ref()); | 428 DCHECK(!new_master_resource.has_ref()); |
| 427 DCHECK(new_master_resource.GetOrigin() == manifest_url_.GetOrigin()); | 429 DCHECK(new_master_resource.GetOrigin() == manifest_url_.GetOrigin()); |
| 428 | 430 |
| 431 if (ContainsKey(failed_master_entries_, new_master_resource)) |
| 432 return; |
| 433 |
| 429 // Cannot add more to this update if already terminating. | 434 // Cannot add more to this update if already terminating. |
| 430 if (IsTerminating()) { | 435 if (IsTerminating()) { |
| 431 group_->QueueUpdate(host, new_master_resource); | 436 group_->QueueUpdate(host, new_master_resource); |
| 432 return; | 437 return; |
| 433 } | 438 } |
| 434 | 439 |
| 435 std::pair<PendingMasters::iterator, bool> ret = | 440 std::pair<PendingMasters::iterator, bool> ret = |
| 436 pending_master_entries_.insert( | 441 pending_master_entries_.insert( |
| 437 PendingMasters::value_type(new_master_resource, PendingHosts())); | 442 PendingMasters::value_type(new_master_resource, PendingHosts())); |
| 438 is_new_pending_master_entry = ret.second; | 443 is_new_pending_master_entry = ret.second; |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 host_notifier.AddHost(host); | 861 host_notifier.AddHost(host); |
| 857 | 862 |
| 858 // In downloading case, disassociate host from inprogress cache. | 863 // In downloading case, disassociate host from inprogress cache. |
| 859 if (inprogress_cache_.get()) | 864 if (inprogress_cache_.get()) |
| 860 host->AssociateNoCache(GURL()); | 865 host->AssociateNoCache(GURL()); |
| 861 | 866 |
| 862 host->RemoveObserver(this); | 867 host->RemoveObserver(this); |
| 863 } | 868 } |
| 864 hosts.clear(); | 869 hosts.clear(); |
| 865 | 870 |
| 871 failed_master_entries_.insert(url); |
| 872 |
| 866 const char* kFormatString = "Manifest fetch failed (%d) %s"; | 873 const char* kFormatString = "Manifest fetch failed (%d) %s"; |
| 867 std::string message = FormatUrlErrorMessage( | 874 std::string message = FormatUrlErrorMessage( |
| 868 kFormatString, request->url(), fetcher->result(), response_code); | 875 kFormatString, request->url(), fetcher->result(), response_code); |
| 869 host_notifier.SendErrorNotifications( | 876 host_notifier.SendErrorNotifications( |
| 870 AppCacheErrorDetails(message, | 877 AppCacheErrorDetails(message, |
| 871 APPCACHE_MANIFEST_ERROR, | 878 APPCACHE_MANIFEST_ERROR, |
| 872 request->url(), | 879 request->url(), |
| 873 response_code, | 880 response_code, |
| 874 false /*is_cross_origin*/)); | 881 false /*is_cross_origin*/)); |
| 875 | 882 |
| (...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1698 // on this object after we've posted a task to delete ourselves. | 1705 // on this object after we've posted a task to delete ourselves. |
| 1699 if (group_) { | 1706 if (group_) { |
| 1700 group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE); | 1707 group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE); |
| 1701 group_ = NULL; | 1708 group_ = NULL; |
| 1702 } | 1709 } |
| 1703 | 1710 |
| 1704 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 1711 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 1705 } | 1712 } |
| 1706 | 1713 |
| 1707 } // namespace content | 1714 } // namespace content |
| OLD | NEW |