Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: content/browser/appcache/appcache_update_job.cc

Issue 1463463003: AppCache: fix a browser crashing bug that can happen during updates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/appcache/appcache_update_job.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 weak_factory_(this) { 399 weak_factory_(this) {
400 service_->AddObserver(this); 400 service_->AddObserver(this);
401 } 401 }
402 402
403 AppCacheUpdateJob::~AppCacheUpdateJob() { 403 AppCacheUpdateJob::~AppCacheUpdateJob() {
404 if (service_) 404 if (service_)
405 service_->RemoveObserver(this); 405 service_->RemoveObserver(this);
406 if (internal_state_ != COMPLETED) 406 if (internal_state_ != COMPLETED)
407 Cancel(); 407 Cancel();
408 408
409 DCHECK(!manifest_fetcher_);
410 DCHECK(pending_url_fetches_.empty());
411 DCHECK(!inprogress_cache_.get()); 409 DCHECK(!inprogress_cache_.get());
412 DCHECK(pending_master_entries_.empty()); 410 DCHECK(pending_master_entries_.empty());
413 DCHECK(master_entry_fetches_.empty()); 411
412 // The job must not outlive any of its fetchers.
413 CHECK(!manifest_fetcher_);
414 CHECK(pending_url_fetches_.empty());
415 CHECK(master_entry_fetches_.empty());
414 416
415 if (group_) 417 if (group_)
416 group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE); 418 group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE);
417 } 419 }
418 420
419 void AppCacheUpdateJob::StartUpdate(AppCacheHost* host, 421 void AppCacheUpdateJob::StartUpdate(AppCacheHost* host,
420 const GURL& new_master_resource) { 422 const GURL& new_master_resource) {
421 DCHECK(group_->update_job() == this); 423 DCHECK(group_->update_job() == this);
422 DCHECK(!group_->is_obsolete()); 424 DCHECK(!group_->is_obsolete());
423 425
424 bool is_new_pending_master_entry = false; 426 bool is_new_pending_master_entry = false;
425 if (!new_master_resource.is_empty()) { 427 if (!new_master_resource.is_empty()) {
426 DCHECK(new_master_resource == host->pending_master_entry_url()); 428 DCHECK(new_master_resource == host->pending_master_entry_url());
427 DCHECK(!new_master_resource.has_ref()); 429 DCHECK(!new_master_resource.has_ref());
428 DCHECK(new_master_resource.GetOrigin() == manifest_url_.GetOrigin()); 430 DCHECK(new_master_resource.GetOrigin() == manifest_url_.GetOrigin());
429 431
432 if (ContainsKey(failed_master_entries_, new_master_resource))
433 return;
434
430 // Cannot add more to this update if already terminating. 435 // Cannot add more to this update if already terminating.
431 if (IsTerminating()) { 436 if (IsTerminating()) {
432 group_->QueueUpdate(host, new_master_resource); 437 group_->QueueUpdate(host, new_master_resource);
433 return; 438 return;
434 } 439 }
435 440
436 std::pair<PendingMasters::iterator, bool> ret = 441 std::pair<PendingMasters::iterator, bool> ret =
437 pending_master_entries_.insert( 442 pending_master_entries_.insert(
438 PendingMasters::value_type(new_master_resource, PendingHosts())); 443 PendingMasters::value_type(new_master_resource, PendingHosts()));
439 is_new_pending_master_entry = ret.second; 444 is_new_pending_master_entry = ret.second;
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 host_notifier.AddHost(host); 862 host_notifier.AddHost(host);
858 863
859 // In downloading case, disassociate host from inprogress cache. 864 // In downloading case, disassociate host from inprogress cache.
860 if (inprogress_cache_.get()) 865 if (inprogress_cache_.get())
861 host->AssociateNoCache(GURL()); 866 host->AssociateNoCache(GURL());
862 867
863 host->RemoveObserver(this); 868 host->RemoveObserver(this);
864 } 869 }
865 hosts.clear(); 870 hosts.clear();
866 871
872 failed_master_entries_.insert(url);
873
867 const char* kFormatString = "Manifest fetch failed (%d) %s"; 874 const char* kFormatString = "Manifest fetch failed (%d) %s";
868 std::string message = FormatUrlErrorMessage( 875 std::string message = FormatUrlErrorMessage(
869 kFormatString, request->url(), fetcher->result(), response_code); 876 kFormatString, request->url(), fetcher->result(), response_code);
870 host_notifier.SendErrorNotifications( 877 host_notifier.SendErrorNotifications(
871 AppCacheErrorDetails(message, 878 AppCacheErrorDetails(message,
872 APPCACHE_MANIFEST_ERROR, 879 APPCACHE_MANIFEST_ERROR,
873 request->url(), 880 request->url(),
874 response_code, 881 response_code,
875 false /*is_cross_origin*/)); 882 false /*is_cross_origin*/));
876 883
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 // on this object after we've posted a task to delete ourselves. 1706 // on this object after we've posted a task to delete ourselves.
1700 if (group_) { 1707 if (group_) {
1701 group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE); 1708 group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE);
1702 group_ = NULL; 1709 group_ = NULL;
1703 } 1710 }
1704 1711
1705 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 1712 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
1706 } 1713 }
1707 1714
1708 } // namespace content 1715 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_update_job.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698