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

Unified Diff: webkit/dom_storage/dom_storage_database.cc

Issue 9389009: Hook up DomStorageArea with a DomStorageDatabase. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments and delete databases on destruction if they are empty. Created 8 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: webkit/dom_storage/dom_storage_database.cc
diff --git a/webkit/dom_storage/dom_storage_database.cc b/webkit/dom_storage/dom_storage_database.cc
index 673ddde5380433e9b6d246b2799765cbef82a548..53adbc670a1cb74c1b085bb5f6bd98218cd274fc 100644
--- a/webkit/dom_storage/dom_storage_database.cc
+++ b/webkit/dom_storage/dom_storage_database.cc
@@ -40,6 +40,16 @@ DomStorageDatabase::DomStorageDatabase(const FilePath& file_path)
}
DomStorageDatabase::~DomStorageDatabase() {
+ if (IsOpen()) {
+ sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE,
+ "SELECT COUNT(key) from ItemTable"));
michaeln 2012/02/23 20:48:48 like we chatted about, can the 'its empty' conditi
benm (inactive) 2012/02/24 12:42:01 Done, but moved to it's own CL in http://coderevie
+ if (statement.Step() && statement.ColumnInt(0) == 0) {
+ // Delete the db from disk, it's empty.
+ statement.Clear();
+ Close();
+ file_util::Delete(file_path_, false);
+ }
+ }
}
void DomStorageDatabase::ReadAllValues(ValuesMap* result) {

Powered by Google App Engine
This is Rietveld 408576698