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

Unified Diff: webkit/dom_storage/dom_storage_namespace.cc

Issue 9817011: DomStorage data deletion and memory purging. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 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: webkit/dom_storage/dom_storage_namespace.cc
===================================================================
--- webkit/dom_storage/dom_storage_namespace.cc (revision 127981)
+++ webkit/dom_storage/dom_storage_namespace.cc (working copy)
@@ -64,8 +64,42 @@
return clone;
}
+void DomStorageNamespace::DeleteOrigin(const GURL& origin) {
+ AreaHolder* holder = GetAreaHolder(origin);
+ if (holder) {
+ holder->area_->DeleteOrigin();
+ return;
+ }
+ if (!directory_.empty()) {
+ scoped_refptr<DomStorageArea> area =
+ new DomStorageArea(namespace_id_, origin, directory_, task_runner_);
+ area->DeleteOrigin();
+ }
+}
+
void DomStorageNamespace::PurgeMemory() {
- // TODO(michaeln): write me
+ if (directory_.empty())
+ 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()) {
+ ++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();
+ areas_.erase(it++);
+ continue;
+ }
+
+ // Otherwise, we can clear caches and such.
+ it->second.area_->PurgeMemory();
+ ++it;
+ }
}
void DomStorageNamespace::Shutdown() {
« webkit/dom_storage/dom_storage_context.cc ('K') | « webkit/dom_storage/dom_storage_namespace.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698