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

Unified Diff: webkit/browser/appcache/appcache_service.cc

Issue 137493003: Appcache::OnCorruptionDetected handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/browser/appcache/appcache_service.h ('k') | webkit/browser/appcache/appcache_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/browser/appcache/appcache_service.cc
diff --git a/webkit/browser/appcache/appcache_service.cc b/webkit/browser/appcache/appcache_service.cc
index e951ad018a23e7cb85ef0dc56702f5268c0e6569..575355a599fd8b116dca91a531314a6f22544747 100644
--- a/webkit/browser/appcache/appcache_service.cc
+++ b/webkit/browser/appcache/appcache_service.cc
@@ -425,7 +425,6 @@ void AppCacheService::CheckResponseHelper::OnReadDataComplete(int result) {
delete this;
}
-
// AppCacheStorageReference ------
AppCacheStorageReference::AppCacheStorageReference(
@@ -439,8 +438,7 @@ AppCacheService::AppCacheService(quota::QuotaManagerProxy* quota_manager_proxy)
: appcache_policy_(NULL), quota_client_(NULL), handler_factory_(NULL),
quota_manager_proxy_(quota_manager_proxy),
request_context_(NULL),
- force_keep_session_state_(false),
- was_reinitialized_(false) {
+ force_keep_session_state_(false) {
if (quota_manager_proxy_.get()) {
quota_client_ = new AppCacheQuotaClient(this);
quota_manager_proxy_->RegisterClient(quota_client_);
@@ -473,13 +471,36 @@ void AppCacheService::Initialize(const base::FilePath& cache_directory,
storage_.reset(storage);
}
-void AppCacheService::Reinitialize() {
- AppCacheHistograms::CountReinitAttempt(was_reinitialized_);
-
- // To avoid thrashing, we only do this once.
- if (was_reinitialized_)
+void AppCacheService::ScheduleReinitialize() {
+ if (reinit_timer_.IsRunning())
return;
- was_reinitialized_ = true;
+
+ // Reinitialization only happens when corruption has been noticed.
+ // We don't want to thrash the disk but we also don't want to
+ // leave the appcache disabled for an indefinite period of time. Some
+ // users never shutdown the browser.
+
+ const base::TimeDelta kZeroDelta;
+ const base::TimeDelta kOneHour(base::TimeDelta::FromHours(1));
+ const base::TimeDelta k30Seconds(base::TimeDelta::FromSeconds(30));
+
+ // If the system managed to stay up for long enough, reset the
+ // delay so a new failure won't incur a long wait to get going again.
+ base::TimeDelta up_time = base::Time::Now() - last_reinit_time_;
+ if (next_reinit_delay_ != kZeroDelta && up_time > kOneHour)
+ next_reinit_delay_ = kZeroDelta;
+
+ reinit_timer_.Start(FROM_HERE, next_reinit_delay_,
+ this, &AppCacheService::Reinitialize);
+
+ // Adjust the delay for next time.
+ base::TimeDelta increment = std::max(k30Seconds, next_reinit_delay_);
+ next_reinit_delay_ = std::min(next_reinit_delay_ + increment, kOneHour);
+}
+
+void AppCacheService::Reinitialize() {
+ AppCacheHistograms::CountReinitAttempt(!last_reinit_time_.is_null());
+ last_reinit_time_ = base::Time::Now();
// Inform observers of about this and give them a chance to
// defer deletion of the old storage object.
« no previous file with comments | « webkit/browser/appcache/appcache_service.h ('k') | webkit/browser/appcache/appcache_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698