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 97fd3da47d8f0dafaf81a31025b7ec3e181eba30..3a86c9d3594da95907f5e0027d084cb9766476ca 100644 |
--- a/webkit/dom_storage/dom_storage_database.cc |
+++ b/webkit/dom_storage/dom_storage_database.cc |
@@ -20,7 +20,7 @@ class HistogramUniquifier { |
static const char* name() { return "Sqlite.DomStorageDatabase.Error"; } |
}; |
-sql::ErrorDelegate* GetErrorHandlerForDomStorageDatabase() { |
+sql::ErrorDelegate* GetErrorHandlerForLocalStorageDatabase() { |
return new sql::DiagnosticErrorDelegate<HistogramUniquifier>(); |
} |
@@ -29,7 +29,7 @@ sql::ErrorDelegate* GetErrorHandlerForDomStorageDatabase() { |
namespace dom_storage { |
// static |
-FilePath DomStorageDatabase::GetJournalFilePath( |
+FilePath LocalStorageDatabase::GetJournalFilePath( |
const FilePath& database_path) { |
FilePath::StringType journal_file_name = |
database_path.BaseName().value() + kJournal; |
@@ -37,24 +37,31 @@ FilePath DomStorageDatabase::GetJournalFilePath( |
} |
DomStorageDatabase::DomStorageDatabase(const FilePath& file_path) |
- : file_path_(file_path) { |
+ : file_path_(file_path), |
+ failed_to_open_(false) { } |
+ |
+DomStorageDatabase::~DomStorageDatabase() { } |
+ |
+LocalStorageDatabase::LocalStorageDatabase(const FilePath& file_path) |
+ : DomStorageDatabase(file_path) { |
// Note: in normal use we should never get an empty backing path here. |
// However, the unit test for this class can contruct an instance |
// with an empty path. |
Init(); |
} |
-DomStorageDatabase::DomStorageDatabase() { |
+LocalStorageDatabase::LocalStorageDatabase() |
+ : DomStorageDatabase(FilePath(FILE_PATH_LITERAL(""))) { |
Init(); |
} |
-void DomStorageDatabase::Init() { |
+void LocalStorageDatabase::Init() { |
failed_to_open_ = false; |
tried_to_recreate_ = false; |
known_to_be_empty_ = false; |
} |
-DomStorageDatabase::~DomStorageDatabase() { |
+LocalStorageDatabase::~LocalStorageDatabase() { |
if (known_to_be_empty_ && !file_path_.empty()) { |
// Delete the db and any lingering journal file from disk. |
Close(); |
@@ -63,7 +70,8 @@ DomStorageDatabase::~DomStorageDatabase() { |
} |
} |
-void DomStorageDatabase::ReadAllValues(ValuesMap* result) { |
+void LocalStorageDatabase::ReadAllValues( |
+ int64 namespace_id, const GURL& origin, ValuesMap* result) { |
if (!LazyOpen(false)) |
return; |
@@ -80,8 +88,9 @@ void DomStorageDatabase::ReadAllValues(ValuesMap* result) { |
known_to_be_empty_ = result->empty(); |
} |
-bool DomStorageDatabase::CommitChanges(bool clear_all_first, |
- const ValuesMap& changes) { |
+bool LocalStorageDatabase::CommitChanges( |
+ int64 namespace_id, const GURL& origin, bool clear_all_first, |
+ const ValuesMap& changes) { |
if (!LazyOpen(!changes.empty())) { |
// If we're being asked to commit changes that will result in an |
// empty database, we return true if the database file doesn't exist. |
@@ -138,7 +147,7 @@ bool DomStorageDatabase::CommitChanges(bool clear_all_first, |
return success; |
} |
-bool DomStorageDatabase::LazyOpen(bool create_if_needed) { |
+bool LocalStorageDatabase::LazyOpen(bool create_if_needed) { |
if (failed_to_open_) { |
// Don't try to open a database that we know has failed |
// already. |
@@ -159,7 +168,7 @@ bool DomStorageDatabase::LazyOpen(bool create_if_needed) { |
} |
db_.reset(new sql::Connection()); |
- db_->set_error_delegate(GetErrorHandlerForDomStorageDatabase()); |
+ db_->set_error_delegate(GetErrorHandlerForLocalStorageDatabase()); |
if (file_path_.empty()) { |
// This code path should only be triggered by unit tests. |
@@ -207,7 +216,8 @@ bool DomStorageDatabase::LazyOpen(bool create_if_needed) { |
return DeleteFileAndRecreate(); |
} |
-DomStorageDatabase::SchemaVersion DomStorageDatabase::DetectSchemaVersion() { |
+LocalStorageDatabase::SchemaVersion |
+LocalStorageDatabase::DetectSchemaVersion() { |
DCHECK(IsOpen()); |
// Connection::Open() may succeed even if the file we try and open is not a |
@@ -243,7 +253,7 @@ DomStorageDatabase::SchemaVersion DomStorageDatabase::DetectSchemaVersion() { |
return INVALID; |
} |
-bool DomStorageDatabase::CreateTableV2() { |
+bool LocalStorageDatabase::CreateTableV2() { |
DCHECK(IsOpen()); |
return db_->Execute( |
@@ -252,7 +262,7 @@ bool DomStorageDatabase::CreateTableV2() { |
"value BLOB NOT NULL ON CONFLICT FAIL)"); |
} |
-bool DomStorageDatabase::DeleteFileAndRecreate() { |
+bool LocalStorageDatabase::DeleteFileAndRecreate() { |
DCHECK(!IsOpen()); |
DCHECK(file_util::PathExists(file_path_)); |
@@ -271,7 +281,7 @@ bool DomStorageDatabase::DeleteFileAndRecreate() { |
return false; |
} |
-bool DomStorageDatabase::UpgradeVersion1To2() { |
+bool LocalStorageDatabase::UpgradeVersion1To2() { |
DCHECK(IsOpen()); |
DCHECK(DetectSchemaVersion() == V1); |
@@ -293,11 +303,15 @@ bool DomStorageDatabase::UpgradeVersion1To2() { |
return migration.Begin() && |
db_->Execute("DROP TABLE ItemTable") && |
CreateTableV2() && |
- CommitChanges(false, values) && |
+ CommitChanges(0, GURL(""), false, values) && |
migration.Commit(); |
} |
-void DomStorageDatabase::Close() { |
+bool LocalStorageDatabase::IsOpen() const { |
+ return db_.get() ? db_->is_open() : false; |
+} |
+ |
+void LocalStorageDatabase::Close() { |
db_.reset(NULL); |
} |