Chromium Code Reviews| 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,45 @@ |
| return clone; |
| } |
| +void DomStorageNamespace::DeleteOrigin(const GURL& origin) { |
| + AreaHolder* holder = GetAreaHolder(origin); |
| + if (holder) { |
| + holder->area_->DeleteOrigin(); |
| + return; |
| + } |
| + if (directory_.empty()) |
| + return; |
| + scoped_refptr<DomStorageArea> area = |
| + new DomStorageArea(namespace_id_, origin, directory_, task_runner_); |
| + area->DeleteOrigin(); |
| +} |
| + |
| void DomStorageNamespace::PurgeMemory() { |
| - // TODO(michaeln): write me |
| + DCHECK_EQ(kLocalStorageNamespaceId, namespace_id_); |
| + if (directory_.empty()) |
| + return; // We can't purge w/o backing on disk. |
| + AreaMap::const_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(); |
| + AreaMap::const_iterator delete_it = it; |
|
jsbell
2012/03/21 20:26:29
Can you just do: areas_.erase(it++) ?
michaeln
2012/03/21 20:30:20
looks like i could
michaeln
2012/03/21 20:46:10
Done.
|
| + ++it; |
| + areas_.erase(delete_it); |
| + continue; |
| + } |
| + |
| + // Otherwise, we can clear caches and such. |
| + it->second.area_->PurgeMemory(); |
| + ++it; |
| + } |
| } |
| void DomStorageNamespace::Shutdown() { |