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

Unified Diff: content/browser/dom_storage/dom_storage_namespace.cc

Issue 896643002: [DOMStorage] Rate limiting writes to disk. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
Index: content/browser/dom_storage/dom_storage_namespace.cc
diff --git a/content/browser/dom_storage/dom_storage_namespace.cc b/content/browser/dom_storage/dom_storage_namespace.cc
index 75bfdaacb71bcee82a6a52b89f0940a58c207198..fc85d83396a319177252cdeee6ae46e3054cfb0b 100644
--- a/content/browser/dom_storage/dom_storage_namespace.cc
+++ b/content/browser/dom_storage/dom_storage_namespace.cc
@@ -123,16 +123,23 @@ void DOMStorageNamespace::PurgeMemory(PurgeOption option) {
return; // We can't purge w/o backing on disk.
AreaMap::iterator it = areas_.begin();
while (it != areas_.end()) {
- // Leave it alone if changes are pending
- if (it->second.area_->HasUncommittedChanges()) {
+ const AreaHolder& holder = it->second;
+
+ // We can't purge if there are changes pending.
+ if (holder.area_->HasUncommittedChanges()) {
+ if (holder.open_count_ == 0) {
+ // Schedule an immediate commit so the next time we're asked to purge,
+ // we can drop it from memory.
+ holder.area_->ScheduleImmediateCommit();
+ }
++it;
continue;
}
// If not in use, we can shut it down and remove
// it from our collection entirely.
- if (it->second.open_count_ == 0) {
- it->second.area_->Shutdown();
+ if (holder.open_count_ == 0) {
+ holder.area_->Shutdown();
areas_.erase(it++);
continue;
}
@@ -140,7 +147,7 @@ void DOMStorageNamespace::PurgeMemory(PurgeOption option) {
if (option == PURGE_AGGRESSIVE) {
// If aggressive is true, we clear caches and such
// for opened areas.
- it->second.area_->PurgeMemory();
+ holder.area_->PurgeMemory();
}
++it;

Powered by Google App Engine
This is Rietveld 408576698