Index: webkit/dom_storage/session_storage_database.cc |
diff --git a/webkit/dom_storage/session_storage_database.cc b/webkit/dom_storage/session_storage_database.cc |
index 794473836ba4d2425b6956b84282a0331d9989d8..fc664abaf37171a99aa4fd2f05167dc251b05543 100644 |
--- a/webkit/dom_storage/session_storage_database.cc |
+++ b/webkit/dom_storage/session_storage_database.cc |
@@ -240,6 +240,9 @@ bool SessionStorageDatabase::ReadNamespacesAndOrigins( |
current_namespace_id = |
key.substr(namespace_prefix.length(), |
key.length() - namespace_prefix.length() - 1); |
+ // Ensure that we keep track of the namespace even if it doesn't contain |
+ // any origins. |
+ (*namespaces_and_origins)[current_namespace_id]; |
michaeln
2013/02/12 01:42:46
maybe map->insert(id, std::vector<GURL>()) would b
marja
2013/02/12 09:10:41
Done.
|
} else { |
// The key is of the form "namespace-<namespaceid>-<origin>". |
std::string origin = key.substr(current_namespace_start_key.length()); |
@@ -411,6 +414,26 @@ bool SessionStorageDatabase::DeleteAreaHelper( |
return false; |
std::string namespace_key = NamespaceKey(namespace_id, origin); |
batch->Delete(namespace_key); |
+ |
+ // If this was the only area in the namespace, delete the namespace start key, |
+ // too. |
michaeln
2013/02/12 01:42:46
I doubt this explains the massive size of the file
marja
2013/02/12 09:10:41
Yeah, this is not the reason behind the bug report
|
+ std::string namespace_start_key = NamespaceStartKey(namespace_id); |
+ scoped_ptr<leveldb::Iterator> it(db_->NewIterator(leveldb::ReadOptions())); |
+ it->Seek(namespace_start_key); |
+ if (!ConsistencyCheck(it->Valid())) |
+ return false; |
+ // Advance the iterator 2 times (we still haven't really deleted |
+ // namespace_key). |
+ it->Next(); |
+ if (!ConsistencyCheck(it->Valid())) |
+ return false; |
+ it->Next(); |
+ if (!it->Valid()) |
+ return true; |
+ std::string key = it->key().ToString(); |
+ if (key.find(namespace_start_key) != 0) { |
michaeln
2013/02/12 01:42:46
nit: {} not needed on the one-liner
marja
2013/02/12 09:10:41
Done.
|
+ batch->Delete(namespace_start_key); |
+ } |
return true; |
} |