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; |