Index: content/browser/dom_storage/dom_storage_area.cc |
diff --git a/content/browser/dom_storage/dom_storage_area.cc b/content/browser/dom_storage/dom_storage_area.cc |
index a2611ebc26c62c409c828ad4f0881ec3a412c6e2..2cc31b558f89a4da8daec6e8731e551248534164 100644 |
--- a/content/browser/dom_storage/dom_storage_area.cc |
+++ b/content/browser/dom_storage/dom_storage_area.cc |
@@ -11,6 +11,7 @@ |
#include "base/logging.h" |
#include "base/metrics/histogram.h" |
#include "base/process/process_info.h" |
+#include "base/rand_util.h" |
#include "base/strings/utf_string_conversions.h" |
#include "base/time/time.h" |
#include "content/browser/dom_storage/dom_storage_namespace.h" |
@@ -20,6 +21,7 @@ |
#include "content/browser/dom_storage/session_storage_database_adapter.h" |
#include "content/common/dom_storage/dom_storage_map.h" |
#include "content/common/dom_storage/dom_storage_types.h" |
+#include "content/public/browser/browser_main_runner.h" |
#include "storage/browser/database/database_util.h" |
#include "storage/common/database/database_identifier.h" |
#include "storage/common/fileapi/file_system_util.h" |
@@ -396,6 +398,18 @@ void DOMStorageArea::OnCommitTimer() { |
if (!commit_batch_) |
return; |
+ // Don't mind the double counting of the few that are deferred compared |
+ // to the masses that aren't. |
+ // TODO: edit histogram.xml |
+ bool defer_commit = IsBrowserStartingUp(); |
+ UMA_HISTOGRAM_BOOLEAN("LocalStorage.Commit", !defer_commit); |
+ if (defer_commit) { |
+ task_runner_->PostDelayedTask( |
+ FROM_HERE, base::Bind(&DOMStorageArea::OnCommitTimer, this), |
+ base::TimeDelta::FromSeconds(base::RandInt(5, 15))); |
+ return; |
+ } |
+ |
PostCommitTask(); |
} |