diff options
author | cmumford <cmumford@chromium.org> | 2015-05-10 09:44:13 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-10 16:45:27 +0000 |
commit | a1f8d834ce9fc89e5e409e08bb00173c37854329 (patch) | |
tree | ae54fc3b6dbc2a36c10cb1c755e858a4a7d10ac0 /content/browser/dom_storage | |
parent | f2d15970289120d1b629168d9c46245a1438f10f (diff) | |
download | chromium_src-a1f8d834ce9fc89e5e409e08bb00173c37854329.zip chromium_src-a1f8d834ce9fc89e5e409e08bb00173c37854329.tar.gz chromium_src-a1f8d834ce9fc89e5e409e08bb00173c37854329.tar.bz2 |
localStorage: Aggressively flush to disk for Android WebView.
Android WebView does not save data during shutdown like Chrome does.
Adding an --enable-aggressive-domstorage-flushing flag to return the
DOM Storage implementation to the prior implementation which had a 1
sec. timer to flush the commit queue.
BUG=479767
Review URL: https://codereview.chromium.org/1129233003
Cr-Commit-Position: refs/heads/master@{#329070}
Diffstat (limited to 'content/browser/dom_storage')
-rw-r--r-- | content/browser/dom_storage/dom_storage_area.cc | 9 | ||||
-rw-r--r-- | content/browser/dom_storage/dom_storage_area.h | 8 |
2 files changed, 17 insertions, 0 deletions
diff --git a/content/browser/dom_storage/dom_storage_area.cc b/content/browser/dom_storage/dom_storage_area.cc index 56a1fd0..67c7b98 100644 --- a/content/browser/dom_storage/dom_storage_area.cc +++ b/content/browser/dom_storage/dom_storage_area.cc @@ -42,6 +42,8 @@ const int kMaxCommitsPerHour = 6; } // namespace +bool DOMStorageArea::s_aggressive_flushing_enabled_ = false; + DOMStorageArea::RateLimiter::RateLimiter(size_t desired_rate, base::TimeDelta time_quantum) : rate_(desired_rate), samples_(0), time_quantum_(time_quantum) { @@ -90,6 +92,10 @@ GURL DOMStorageArea::OriginFromDatabaseFileName(const base::FilePath& name) { return storage::GetOriginFromIdentifier(origin_id); } +void DOMStorageArea::EnableAggressiveCommitDelay() { + s_aggressive_flushing_enabled_ = true; +} + DOMStorageArea::DOMStorageArea(const GURL& origin, const base::FilePath& directory, DOMStorageTaskRunner* task_runner) @@ -388,6 +394,9 @@ void DOMStorageArea::StartCommitTimer() { } base::TimeDelta DOMStorageArea::ComputeCommitDelay() const { + if (s_aggressive_flushing_enabled_) + return base::TimeDelta::FromSeconds(1); + base::TimeDelta elapsed_time = base::TimeTicks::Now() - start_time_; base::TimeDelta delay = std::max( base::TimeDelta::FromSeconds(kCommitDefaultDelaySecs), diff --git a/content/browser/dom_storage/dom_storage_area.h b/content/browser/dom_storage/dom_storage_area.h index 3a4b166..dd0df52 100644 --- a/content/browser/dom_storage/dom_storage_area.h +++ b/content/browser/dom_storage/dom_storage_area.h @@ -35,6 +35,12 @@ class CONTENT_EXPORT DOMStorageArea static base::FilePath DatabaseFileNameFromOrigin(const GURL& origin); static GURL OriginFromDatabaseFileName(const base::FilePath& file_name); + // Commence aggressive flushing. This should be called early in the startup - + // before any localStorage writing. Currently scheduled writes will not be + // rescheduled and will be flushed at the scheduled time after which + // aggressive flushing will commence. + static void EnableAggressiveCommitDelay(); + // Local storage. Backed on disk if directory is nonempty. DOMStorageArea(const GURL& origin, const base::FilePath& directory, @@ -153,6 +159,8 @@ class CONTENT_EXPORT DOMStorageArea void ShutdownInCommitSequence(); + static bool s_aggressive_flushing_enabled_; + int64 namespace_id_; std::string persistent_namespace_id_; GURL origin_; |