summaryrefslogtreecommitdiffstats
path: root/content/browser/dom_storage
diff options
context:
space:
mode:
Diffstat (limited to 'content/browser/dom_storage')
-rw-r--r--content/browser/dom_storage/dom_storage_area.cc9
-rw-r--r--content/browser/dom_storage/dom_storage_area.h8
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_;