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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 const GURL& new_master_resource) { | 420 const GURL& new_master_resource) { |
421 DCHECK(group_->update_job() == this); | 421 DCHECK(group_->update_job() == this); |
422 DCHECK(!group_->is_obsolete()); | 422 DCHECK(!group_->is_obsolete()); |
423 | 423 |
424 bool is_new_pending_master_entry = false; | 424 bool is_new_pending_master_entry = false; |
425 if (!new_master_resource.is_empty()) { | 425 if (!new_master_resource.is_empty()) { |
426 DCHECK(new_master_resource == host->pending_master_entry_url()); | 426 DCHECK(new_master_resource == host->pending_master_entry_url()); |
427 DCHECK(!new_master_resource.has_ref()); | 427 DCHECK(!new_master_resource.has_ref()); |
428 DCHECK(new_master_resource.GetOrigin() == manifest_url_.GetOrigin()); | 428 DCHECK(new_master_resource.GetOrigin() == manifest_url_.GetOrigin()); |
429 | 429 |
430 if (ContainsKey(failed_master_entries_, new_master_resource)) | |
431 return; | |
gzobqq
2015/11/20 06:10:54
Do we care about lack of host notification?
michaeln
2015/11/20 20:38:55
we care more about the crash
for this to happen,
michaeln
2015/11/20 21:19:15
If we were to care... looks like the sequence of e
| |
432 | |
430 // Cannot add more to this update if already terminating. | 433 // Cannot add more to this update if already terminating. |
431 if (IsTerminating()) { | 434 if (IsTerminating()) { |
432 group_->QueueUpdate(host, new_master_resource); | 435 group_->QueueUpdate(host, new_master_resource); |
433 return; | 436 return; |
434 } | 437 } |
435 | 438 |
436 std::pair<PendingMasters::iterator, bool> ret = | 439 std::pair<PendingMasters::iterator, bool> ret = |
437 pending_master_entries_.insert( | 440 pending_master_entries_.insert( |
438 PendingMasters::value_type(new_master_resource, PendingHosts())); | 441 PendingMasters::value_type(new_master_resource, PendingHosts())); |
439 is_new_pending_master_entry = ret.second; | 442 is_new_pending_master_entry = ret.second; |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
857 host_notifier.AddHost(host); | 860 host_notifier.AddHost(host); |
858 | 861 |
859 // In downloading case, disassociate host from inprogress cache. | 862 // In downloading case, disassociate host from inprogress cache. |
860 if (inprogress_cache_.get()) | 863 if (inprogress_cache_.get()) |
861 host->AssociateNoCache(GURL()); | 864 host->AssociateNoCache(GURL()); |
862 | 865 |
863 host->RemoveObserver(this); | 866 host->RemoveObserver(this); |
864 } | 867 } |
865 hosts.clear(); | 868 hosts.clear(); |
866 | 869 |
870 failed_master_entries_.insert(url); | |
871 | |
867 const char* kFormatString = "Manifest fetch failed (%d) %s"; | 872 const char* kFormatString = "Manifest fetch failed (%d) %s"; |
868 std::string message = FormatUrlErrorMessage( | 873 std::string message = FormatUrlErrorMessage( |
869 kFormatString, request->url(), fetcher->result(), response_code); | 874 kFormatString, request->url(), fetcher->result(), response_code); |
870 host_notifier.SendErrorNotifications( | 875 host_notifier.SendErrorNotifications( |
871 AppCacheErrorDetails(message, | 876 AppCacheErrorDetails(message, |
872 APPCACHE_MANIFEST_ERROR, | 877 APPCACHE_MANIFEST_ERROR, |
873 request->url(), | 878 request->url(), |
874 response_code, | 879 response_code, |
875 false /*is_cross_origin*/)); | 880 false /*is_cross_origin*/)); |
876 | 881 |
877 // In downloading case, update result is different if all master entries | 882 // In downloading case, update result is different if all master entries |
878 // failed vs. only some failing. | 883 // failed vs. only some failing. |
879 if (inprogress_cache_.get()) { | 884 if (inprogress_cache_.get()) { |
880 // Only count successful downloads to know if all master entries failed. | 885 // Only count successful downloads to know if all master entries failed. |
881 pending_master_entries_.erase(found); | 886 pending_master_entries_.erase(found); |
882 --master_entries_completed_; | 887 --master_entries_completed_; |
gzobqq
2015/11/20 06:10:54
Another possible fix would be to do this erase() a
michaeln
2015/11/20 20:38:55
This is very tricky code, the concern for breaking
| |
883 | 888 |
884 // Section 6.9.4, step 22.3. | 889 // Section 6.9.4, step 22.3. |
885 if (update_type_ == CACHE_ATTEMPT && pending_master_entries_.empty()) { | 890 if (update_type_ == CACHE_ATTEMPT && pending_master_entries_.empty()) { |
886 HandleCacheFailure(AppCacheErrorDetails(message, | 891 HandleCacheFailure(AppCacheErrorDetails(message, |
887 APPCACHE_MANIFEST_ERROR, | 892 APPCACHE_MANIFEST_ERROR, |
888 request->url(), | 893 request->url(), |
889 response_code, | 894 response_code, |
890 false /*is_cross_origin*/), | 895 false /*is_cross_origin*/), |
891 fetcher->result(), | 896 fetcher->result(), |
892 GURL()); | 897 GURL()); |
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1681 !failed_resource_url.is_empty() && | 1686 !failed_resource_url.is_empty() && |
1682 (failed_resource_url.GetOrigin() != manifest_url_.GetOrigin()); | 1687 (failed_resource_url.GetOrigin() != manifest_url_.GetOrigin()); |
1683 | 1688 |
1684 AppCacheHistograms::LogUpdateFailureStats( | 1689 AppCacheHistograms::LogUpdateFailureStats( |
1685 manifest_url_.GetOrigin(), | 1690 manifest_url_.GetOrigin(), |
1686 percent_complete, | 1691 percent_complete, |
1687 was_making_progress, | 1692 was_making_progress, |
1688 off_origin_resource_failure); | 1693 off_origin_resource_failure); |
1689 } | 1694 } |
1690 | 1695 |
1691 void AppCacheUpdateJob::DeleteSoon() { | 1696 void AppCacheUpdateJob::DeleteSoon() { |
gzobqq
2015/11/20 06:10:54
In any case, perhaps double check here or in the d
michaeln
2015/11/20 20:38:55
I've converted a few DCHECKs in the dtor to CHECKs
| |
1692 ClearPendingMasterEntries(); | 1697 ClearPendingMasterEntries(); |
1693 manifest_response_writer_.reset(); | 1698 manifest_response_writer_.reset(); |
1694 storage_->CancelDelegateCallbacks(this); | 1699 storage_->CancelDelegateCallbacks(this); |
1695 service_->RemoveObserver(this); | 1700 service_->RemoveObserver(this); |
1696 service_ = NULL; | 1701 service_ = NULL; |
1697 | 1702 |
1698 // Break the connection with the group so the group cannot call delete | 1703 // Break the connection with the group so the group cannot call delete |
1699 // on this object after we've posted a task to delete ourselves. | 1704 // on this object after we've posted a task to delete ourselves. |
1700 if (group_) { | 1705 if (group_) { |
1701 group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE); | 1706 group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE); |
1702 group_ = NULL; | 1707 group_ = NULL; |
1703 } | 1708 } |
1704 | 1709 |
1705 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 1710 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
1706 } | 1711 } |
1707 | 1712 |
1708 } // namespace content | 1713 } // namespace content |
OLD | NEW |