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

Side by Side Diff: webkit/appcache/appcache_update_job.cc

Issue 10207020: Workaround for a crashing appcache bug seen on the crash servers (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « webkit/appcache/appcache_update_job.h ('k') | webkit/appcache/appcache_update_job_unittest.cc » ('j') | 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 "webkit/appcache/appcache_update_job.h" 5 #include "webkit/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/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/stringprintf.h" 12 #include "base/stringprintf.h"
13 #include "net/base/io_buffer.h" 13 #include "net/base/io_buffer.h"
14 #include "net/base/load_flags.h" 14 #include "net/base/load_flags.h"
15 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
16 #include "net/http/http_request_headers.h" 16 #include "net/http/http_request_headers.h"
17 #include "net/http/http_response_headers.h" 17 #include "net/http/http_response_headers.h"
18 #include "webkit/appcache/appcache_group.h" 18 #include "webkit/appcache/appcache_group.h"
19 #include "webkit/appcache/appcache_histograms.h"
19 20
20 namespace appcache { 21 namespace appcache {
21 22
22 static const int kBufferSize = 32768; 23 static const int kBufferSize = 32768;
23 static const size_t kMaxConcurrentUrlFetches = 2; 24 static const size_t kMaxConcurrentUrlFetches = 2;
24 static const int kMax503Retries = 3; 25 static const int kMax503Retries = 3;
25 26
26 // Helper class for collecting hosts per frontend when sending notifications 27 // Helper class for collecting hosts per frontend when sending notifications
27 // so that only one notification is sent for all hosts using the same frontend. 28 // so that only one notification is sent for all hosts using the same frontend.
28 class HostNotifier { 29 class HostNotifier {
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 288 }
288 ++retry_503_attempts_; 289 ++retry_503_attempts_;
289 request_.reset(new net::URLRequest(url_, this)); 290 request_.reset(new net::URLRequest(url_, this));
290 Start(); 291 Start();
291 return true; 292 return true;
292 } 293 }
293 294
294 AppCacheUpdateJob::AppCacheUpdateJob(AppCacheService* service, 295 AppCacheUpdateJob::AppCacheUpdateJob(AppCacheService* service,
295 AppCacheGroup* group) 296 AppCacheGroup* group)
296 : service_(service), 297 : service_(service),
298 manifest_url_(group->manifest_url()),
297 group_(group), 299 group_(group),
298 update_type_(UNKNOWN_TYPE), 300 update_type_(UNKNOWN_TYPE),
299 internal_state_(FETCH_MANIFEST), 301 internal_state_(FETCH_MANIFEST),
300 master_entries_completed_(0), 302 master_entries_completed_(0),
301 url_fetches_completed_(0), 303 url_fetches_completed_(0),
302 manifest_fetcher_(NULL), 304 manifest_fetcher_(NULL),
303 stored_state_(UNSTORED) { 305 stored_state_(UNSTORED) {
304 DCHECK(group_);
305 manifest_url_ = group_->manifest_url();
306 } 306 }
307 307
308 AppCacheUpdateJob::~AppCacheUpdateJob() { 308 AppCacheUpdateJob::~AppCacheUpdateJob() {
309 if (internal_state_ != COMPLETED) 309 if (internal_state_ != COMPLETED)
310 Cancel(); 310 Cancel();
311 311
312 DCHECK(!manifest_fetcher_); 312 DCHECK(!manifest_fetcher_);
313 DCHECK(pending_url_fetches_.empty()); 313 DCHECK(pending_url_fetches_.empty());
314 DCHECK(!inprogress_cache_); 314 DCHECK(!inprogress_cache_);
315 DCHECK(pending_master_entries_.empty()); 315 DCHECK(pending_master_entries_.empty());
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 744
745 void AppCacheUpdateJob::StoreGroupAndCache() { 745 void AppCacheUpdateJob::StoreGroupAndCache() {
746 DCHECK(stored_state_ == UNSTORED); 746 DCHECK(stored_state_ == UNSTORED);
747 stored_state_ = STORING; 747 stored_state_ = STORING;
748 scoped_refptr<AppCache> newest_cache; 748 scoped_refptr<AppCache> newest_cache;
749 if (inprogress_cache_) 749 if (inprogress_cache_)
750 newest_cache.swap(inprogress_cache_); 750 newest_cache.swap(inprogress_cache_);
751 else 751 else
752 newest_cache = group_->newest_complete_cache(); 752 newest_cache = group_->newest_complete_cache();
753 newest_cache->set_update_time(base::Time::Now()); 753 newest_cache->set_update_time(base::Time::Now());
754
755 // TODO(michaeln): dcheck is fishing for clues to crbug/95101
756 DCHECK_EQ(manifest_url_, group_->manifest_url());
754 service_->storage()->StoreGroupAndNewestCache(group_, newest_cache, 757 service_->storage()->StoreGroupAndNewestCache(group_, newest_cache,
755 this); // async 758 this); // async
756 } 759 }
757 760
758 void AppCacheUpdateJob::OnGroupAndNewestCacheStored(AppCacheGroup* group, 761 void AppCacheUpdateJob::OnGroupAndNewestCacheStored(AppCacheGroup* group,
759 AppCache* newest_cache, 762 AppCache* newest_cache,
760 bool success, 763 bool success,
761 bool would_exceed_quota) { 764 bool would_exceed_quota) {
762 DCHECK(stored_state_ == STORING); 765 DCHECK(stored_state_ == STORING);
763 if (success) { 766 if (success) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 PendingHosts& hosts = found->second; 838 PendingHosts& hosts = found->second;
836 PendingHosts::iterator it = std::find(hosts.begin(), hosts.end(), host); 839 PendingHosts::iterator it = std::find(hosts.begin(), hosts.end(), host);
837 DCHECK(it != hosts.end()); 840 DCHECK(it != hosts.end());
838 hosts.erase(it); 841 hosts.erase(it);
839 } 842 }
840 843
841 void AppCacheUpdateJob::CheckIfManifestChanged() { 844 void AppCacheUpdateJob::CheckIfManifestChanged() {
842 DCHECK(update_type_ == UPGRADE_ATTEMPT); 845 DCHECK(update_type_ == UPGRADE_ATTEMPT);
843 AppCacheEntry* entry = 846 AppCacheEntry* entry =
844 group_->newest_complete_cache()->GetEntry(manifest_url_); 847 group_->newest_complete_cache()->GetEntry(manifest_url_);
845 DCHECK(entry); 848 if (!entry) {
849 // TODO(michaeln): This is just a bandaid to avoid a crash.
850 // http://code.google.com/p/chromium/issues/detail?id=95101
851 HandleCacheFailure("Manifest entry not found in existing cache");
852 AppCacheHistograms::AddMissingManifestEntrySample();
853 service_->DeleteAppCacheGroup(manifest_url_, net::CompletionCallback());
854 return;
855 }
846 856
847 // Load manifest data from storage to compare against fetched manifest. 857 // Load manifest data from storage to compare against fetched manifest.
848 manifest_response_reader_.reset( 858 manifest_response_reader_.reset(
849 service_->storage()->CreateResponseReader(manifest_url_, 859 service_->storage()->CreateResponseReader(manifest_url_,
850 group_->group_id(), 860 group_->group_id(),
851 entry->response_id())); 861 entry->response_id()));
852 read_manifest_buffer_ = new net::IOBuffer(kBufferSize); 862 read_manifest_buffer_ = new net::IOBuffer(kBufferSize);
853 manifest_response_reader_->ReadData( 863 manifest_response_reader_->ReadData(
854 read_manifest_buffer_, kBufferSize, 864 read_manifest_buffer_, kBufferSize,
855 base::Bind(&AppCacheUpdateJob::OnManifestDataReadComplete, 865 base::Bind(&AppCacheUpdateJob::OnManifestDataReadComplete,
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 1338
1329 // Break the connection with the group so the group cannot call delete 1339 // Break the connection with the group so the group cannot call delete
1330 // on this object after we've posted a task to delete ourselves. 1340 // on this object after we've posted a task to delete ourselves.
1331 group_->SetUpdateStatus(AppCacheGroup::IDLE); 1341 group_->SetUpdateStatus(AppCacheGroup::IDLE);
1332 group_ = NULL; 1342 group_ = NULL;
1333 1343
1334 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 1344 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
1335 } 1345 }
1336 1346
1337 } // namespace appcache 1347 } // namespace appcache
OLDNEW
« no previous file with comments | « webkit/appcache/appcache_update_job.h ('k') | webkit/appcache/appcache_update_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698