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

Unified Diff: content/browser/indexed_db/indexed_db_database.cc

Issue 308103004: IndexedDB: Using a mock IndexedDBFactory for unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't use GoogleMock with std::pair types Created 6 years, 5 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: content/browser/indexed_db/indexed_db_database.cc
diff --git a/content/browser/indexed_db/indexed_db_database.cc b/content/browser/indexed_db/indexed_db_database.cc
index 40df481a0b24d160ab2d25acb33bb554974999c4..18265ce6c9af37242deb0427babc14ea19cb5fbe 100644
--- a/content/browser/indexed_db/indexed_db_database.cc
+++ b/content/browser/indexed_db/indexed_db_database.cc
@@ -123,6 +123,7 @@ IndexedDBDatabase::IndexedDBDatabase(const base::string16& name,
kInvalidId),
identifier_(unique_identifier),
factory_(factory) {
+ DCHECK(factory != NULL);
}
void IndexedDBDatabase::AddObjectStore(
@@ -1379,9 +1380,6 @@ void IndexedDBDatabase::TransactionFinished(IndexedDBTransaction* transaction,
}
void IndexedDBDatabase::TransactionCommitFailed(const leveldb::Status& status) {
- // Factory may be null in unit tests.
- if (!factory_)
- return;
if (status.IsCorruption()) {
IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError,
"Error committing transaction");
@@ -1683,8 +1681,7 @@ void IndexedDBDatabase::DeleteDatabaseFinal(
metadata_.int_version = IndexedDBDatabaseMetadata::NO_INT_VERSION;
metadata_.object_stores.clear();
callbacks->OnSuccess(old_version);
- if (factory_)
- factory_->DatabaseDeleted(identifier_);
+ factory_->DatabaseDeleted(identifier_);
}
void IndexedDBDatabase::ForceClose() {
@@ -1753,12 +1750,7 @@ void IndexedDBDatabase::Close(IndexedDBConnection* connection, bool forced) {
const GURL origin_url = backing_store_->origin_url();
backing_store_ = NULL;
- // factory_ should only be null in unit tests.
- // TODO(jsbell): DCHECK(factory_ || !in_unit_tests) - somehow.
- if (factory_) {
- factory_->ReleaseDatabase(identifier_, forced);
- factory_ = NULL;
- }
+ factory_->ReleaseDatabase(identifier_, forced);
}
}

Powered by Google App Engine
This is Rietveld 408576698