Chromium Code Reviews| 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 85b6f9d6911e032eca78054e44ad448925585203..f04993d80e4eec52937e6055638fd155ea254817 100644 |
| --- a/content/browser/indexed_db/indexed_db_database.cc |
| +++ b/content/browser/indexed_db/indexed_db_database.cc |
| @@ -46,6 +46,7 @@ using base::Int64ToString16; |
| using blink::WebIDBKeyTypeNumber; |
| namespace content { |
| +using OperationResult = IndexedDBDatabase::OperationResult; |
| namespace { |
| @@ -712,11 +713,8 @@ void IndexedDBDatabase::CreateIndex(int64_t transaction_id, |
| index_id)); |
| } |
| -void IndexedDBDatabase::CreateIndexAbortOperation( |
| - int64_t object_store_id, |
| - int64_t index_id, |
| - IndexedDBTransaction* transaction) { |
| - DCHECK(!transaction); |
| +void IndexedDBDatabase::CreateIndexAbortOperation(int64_t object_store_id, |
| + int64_t index_id) { |
| IDB_TRACE("IndexedDBDatabase::CreateIndexAbortOperation"); |
| RemoveIndex(object_store_id, index_id); |
| } |
| @@ -740,7 +738,7 @@ void IndexedDBDatabase::DeleteIndex(int64_t transaction_id, |
| index_id)); |
| } |
| -void IndexedDBDatabase::DeleteIndexOperation( |
| +OperationResult IndexedDBDatabase::DeleteIndexOperation( |
| int64_t object_store_id, |
| int64_t index_id, |
| IndexedDBTransaction* transaction) { |
| @@ -762,9 +760,7 @@ void IndexedDBDatabase::DeleteIndexOperation( |
| IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
| error_string); |
| transaction->Abort(error); |
| - if (s.IsCorruption()) |
| - factory_->HandleBackingStoreCorruption(backing_store_->origin(), error); |
| - return; |
| + return s; |
| } |
| RemoveIndex(object_store_id, index_id); |
| @@ -773,13 +769,12 @@ void IndexedDBDatabase::DeleteIndexOperation( |
| this, |
| object_store_id, |
| index_metadata)); |
| + return s; |
| } |
| void IndexedDBDatabase::DeleteIndexAbortOperation( |
| int64_t object_store_id, |
| - const IndexedDBIndexMetadata& index_metadata, |
| - IndexedDBTransaction* transaction) { |
| - DCHECK(!transaction); |
| + const IndexedDBIndexMetadata& index_metadata) { |
| IDB_TRACE("IndexedDBDatabase::DeleteIndexAbortOperation"); |
| AddIndex(object_store_id, index_metadata, IndexedDBIndexMetadata::kInvalidId); |
| } |
| @@ -814,8 +809,13 @@ void IndexedDBDatabase::RenameIndex(int64_t transaction_id, |
| ASCIIToUTF16("Internal error renaming index '") + |
| index_metadata.name + ASCIIToUTF16("' to '") + new_name + |
| ASCIIToUTF16("'."); |
| - transaction->Abort(IndexedDBDatabaseError( |
| - blink::WebIDBDatabaseExceptionUnknownError, error_string)); |
| + IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
| + error_string); |
| + transaction->Abort(error); |
| + if (s.IsCorruption()) |
| + factory_->HandleBackingStoreCorruption(origin(), error); |
| + else |
| + factory_->HandleBackingStoreFailure(origin()); |
| return; |
| } |
| @@ -831,9 +831,7 @@ void IndexedDBDatabase::RenameIndex(int64_t transaction_id, |
| void IndexedDBDatabase::RenameIndexAbortOperation( |
| int64_t object_store_id, |
| int64_t index_id, |
| - const base::string16& old_name, |
| - IndexedDBTransaction* transaction) { |
| - DCHECK(!transaction); |
| + const base::string16& old_name) { |
| IDB_TRACE("IndexedDBDatabase::RenameIndexAbortOperation"); |
| SetIndexName(object_store_id, index_id, old_name); |
| } |
| @@ -977,7 +975,7 @@ void IndexedDBDatabase::Get(int64_t transaction_id, |
| callbacks)); |
| } |
| -void IndexedDBDatabase::GetOperation( |
| +OperationResult IndexedDBDatabase::GetOperation( |
| int64_t object_store_id, |
| int64_t index_id, |
| std::unique_ptr<IndexedDBKeyRange> key_range, |
| @@ -993,7 +991,7 @@ void IndexedDBDatabase::GetOperation( |
| const IndexedDBKey* key; |
| - leveldb::Status s; |
| + leveldb::Status s = leveldb::Status::OK(); |
|
cmumford
2016/11/21 18:29:22
leveldb::Status defaults to OK.
dmurph
2016/11/22 23:33:11
mmmmm I think I prefer this if that's ok, it makes
|
| std::unique_ptr<IndexedDBBackingStore::Cursor> backing_store_cursor; |
| if (key_range->IsOnlyKey()) { |
| key = &key_range->lower(); |
| @@ -1035,14 +1033,14 @@ void IndexedDBDatabase::GetOperation( |
| DLOG(ERROR) << "Unable to open cursor operation: " << s.ToString(); |
| IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
| "Internal error deleting data in range"); |
| - if (s.IsCorruption()) { |
| - factory_->HandleBackingStoreCorruption(backing_store_->origin(), error); |
|
cmumford
2016/11/21 18:29:22
I'm OK with returning the status, and having the c
dmurph
2016/11/22 23:33:11
Yeah... We now put the leveldb error string in the
|
| - } |
| + callbacks->OnError(error); |
| + return s; |
| } |
| if (!backing_store_cursor) { |
| + // This means we've run out of data. |
| callbacks->OnSuccess(); |
| - return; |
| + return s; |
| } |
| key = &backing_store_cursor->key(); |
| @@ -1061,20 +1059,17 @@ void IndexedDBDatabase::GetOperation( |
| IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
| "Internal error in GetRecord."); |
| callbacks->OnError(error); |
| - |
| - if (s.IsCorruption()) |
| - factory_->HandleBackingStoreCorruption(backing_store_->origin(), error); |
| - return; |
| + return s; |
| } |
| if (value.empty()) { |
| callbacks->OnSuccess(); |
| - return; |
| + return s; |
| } |
| if (cursor_type == indexed_db::CURSOR_KEY_ONLY) { |
| callbacks->OnSuccess(*key); |
| - return; |
| + return s; |
| } |
| if (object_store_metadata.auto_increment && |
| @@ -1084,7 +1079,7 @@ void IndexedDBDatabase::GetOperation( |
| } |
| callbacks->OnSuccess(&value); |
| - return; |
| + return s; |
| } |
| // From here we are dealing only with indexes. |
| @@ -1099,18 +1094,16 @@ void IndexedDBDatabase::GetOperation( |
| IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
| "Internal error in GetPrimaryKeyViaIndex."); |
| callbacks->OnError(error); |
| - if (s.IsCorruption()) |
| - factory_->HandleBackingStoreCorruption(backing_store_->origin(), error); |
| - return; |
| + return s; |
| } |
| if (!primary_key) { |
| callbacks->OnSuccess(); |
| - return; |
| + return s; |
| } |
| if (cursor_type == indexed_db::CURSOR_KEY_ONLY) { |
| // Index Value Retrieval Operation |
| callbacks->OnSuccess(*primary_key); |
| - return; |
| + return s; |
| } |
| // Index Referenced Value Retrieval Operation |
| @@ -1124,14 +1117,12 @@ void IndexedDBDatabase::GetOperation( |
| IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
| "Internal error in GetRecord."); |
| callbacks->OnError(error); |
| - if (s.IsCorruption()) |
| - factory_->HandleBackingStoreCorruption(backing_store_->origin(), error); |
| - return; |
| + return s; |
| } |
| if (value.empty()) { |
| callbacks->OnSuccess(); |
| - return; |
| + return s; |
| } |
| if (object_store_metadata.auto_increment && |
| !object_store_metadata.key_path.IsNull()) { |
| @@ -1139,9 +1130,10 @@ void IndexedDBDatabase::GetOperation( |
| value.key_path = object_store_metadata.key_path; |
| } |
| callbacks->OnSuccess(&value); |
| + return s; |
| } |
| -void IndexedDBDatabase::GetAllOperation( |
| +OperationResult IndexedDBDatabase::GetAllOperation( |
| int64_t object_store_id, |
| int64_t index_id, |
| std::unique_ptr<IndexedDBKeyRange> key_range, |
| @@ -1158,7 +1150,7 @@ void IndexedDBDatabase::GetAllOperation( |
| const IndexedDBObjectStoreMetadata& object_store_metadata = |
| metadata_.object_stores[object_store_id]; |
| - leveldb::Status s; |
| + leveldb::Status s = leveldb::Status::OK(); |
| std::unique_ptr<IndexedDBBackingStore::Cursor> cursor; |
| @@ -1195,10 +1187,7 @@ void IndexedDBDatabase::GetAllOperation( |
| IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
| "Internal error in GetAllOperation"); |
| callbacks->OnError(error); |
| - if (s.IsCorruption()) { |
| - factory_->HandleBackingStoreCorruption(backing_store_->origin(), error); |
| - } |
| - return; |
| + return s; |
| } |
| std::vector<IndexedDBKey> found_keys; |
| @@ -1207,7 +1196,7 @@ void IndexedDBDatabase::GetAllOperation( |
| // Doesn't matter if key or value array here - will be empty array when it |
| // hits JavaScript. |
| callbacks->OnSuccessArray(&found_values); |
| - return; |
| + return s; |
| } |
| bool did_first_seek = false; |
| @@ -1228,9 +1217,7 @@ void IndexedDBDatabase::GetAllOperation( |
| IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
| "Internal error in GetAllOperation."); |
| callbacks->OnError(error); |
| - if (s.IsCorruption()) |
| - factory_->HandleBackingStoreCorruption(backing_store_->origin(), error); |
| - return; |
| + return s; |
| } |
| if (!cursor_valid) |
| @@ -1258,7 +1245,7 @@ void IndexedDBDatabase::GetAllOperation( |
| callbacks->OnError( |
| IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError, |
| "Maximum IPC message size exceeded.")); |
| - return; |
| + return s; |
| } |
| if (cursor_type == indexed_db::CURSOR_KEY_ONLY) |
| @@ -1274,6 +1261,7 @@ void IndexedDBDatabase::GetAllOperation( |
| } else { |
| callbacks->OnSuccessArray(&found_values); |
| } |
| + return s; |
| } |
| static std::unique_ptr<IndexedDBKey> GenerateKey( |
| @@ -1358,11 +1346,13 @@ void IndexedDBDatabase::Put( |
| &IndexedDBDatabase::PutOperation, this, base::Passed(¶ms))); |
| } |
| -void IndexedDBDatabase::PutOperation(std::unique_ptr<PutOperationParams> params, |
| - IndexedDBTransaction* transaction) { |
| +OperationResult IndexedDBDatabase::PutOperation( |
| + std::unique_ptr<PutOperationParams> params, |
| + IndexedDBTransaction* transaction) { |
| IDB_TRACE1("IndexedDBDatabase::PutOperation", "txn.id", transaction->id()); |
| DCHECK_NE(transaction->mode(), blink::WebIDBTransactionModeReadOnly); |
| bool key_was_generated = false; |
| + leveldb::Status s = leveldb::Status::OK(); |
|
cmumford
2016/11/21 18:29:22
You probably want to reuse this |s| down below whe
dmurph
2016/11/22 23:33:10
Done.
|
| DCHECK(metadata_.object_stores.find(params->object_store_id) != |
| metadata_.object_stores.end()); |
| @@ -1380,7 +1370,7 @@ void IndexedDBDatabase::PutOperation(std::unique_ptr<PutOperationParams> params, |
| params->callbacks->OnError( |
| IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionConstraintError, |
| "Maximum key generator value reached.")); |
| - return; |
| + return s; |
| } |
| key = std::move(auto_inc_key); |
| } else { |
| @@ -1403,15 +1393,13 @@ void IndexedDBDatabase::PutOperation(std::unique_ptr<PutOperationParams> params, |
| IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
| "Internal error checking key existence."); |
| params->callbacks->OnError(error); |
| - if (s.IsCorruption()) |
| - factory_->HandleBackingStoreCorruption(backing_store_->origin(), error); |
| - return; |
| + return s; |
| } |
| if (found) { |
| params->callbacks->OnError( |
| IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionConstraintError, |
| "Key already exists in the object store.")); |
| - return; |
| + return s; |
| } |
| } |
| @@ -1432,32 +1420,25 @@ void IndexedDBDatabase::PutOperation(std::unique_ptr<PutOperationParams> params, |
| params->callbacks->OnError(IndexedDBDatabaseError( |
| blink::WebIDBDatabaseExceptionUnknownError, |
| "Internal error: backing store error updating index keys.")); |
| - return; |
| + return s; |
| } |
| if (!obeys_constraints) { |
| params->callbacks->OnError(IndexedDBDatabaseError( |
| blink::WebIDBDatabaseExceptionConstraintError, error_message)); |
| - return; |
| + return s; |
| } |
| // Before this point, don't do any mutation. After this point, rollback the |
| // transaction in case of error. |
| - leveldb::Status s = |
| - backing_store_->PutRecord(transaction->BackingStoreTransaction(), |
| - id(), |
| - params->object_store_id, |
| - *key, |
| - ¶ms->value, |
| - ¶ms->handles, |
| - &record_identifier); |
| + s = backing_store_->PutRecord(transaction->BackingStoreTransaction(), id(), |
| + params->object_store_id, *key, ¶ms->value, |
| + ¶ms->handles, &record_identifier); |
| if (!s.ok()) { |
| IndexedDBDatabaseError error( |
| blink::WebIDBDatabaseExceptionUnknownError, |
| "Internal error: backing store error performing put/add."); |
| params->callbacks->OnError(error); |
| - if (s.IsCorruption()) |
| - factory_->HandleBackingStoreCorruption(backing_store_->origin(), error); |
| - return; |
| + return s; |
| } |
| { |
| IDB_TRACE1("IndexedDBDatabase::PutOperation.UpdateIndexes", "txn.id", |
| @@ -1484,9 +1465,7 @@ void IndexedDBDatabase::PutOperation(std::unique_ptr<PutOperationParams> params, |
| IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
| "Internal error updating key generator."); |
| params->callbacks->OnError(error); |
| - if (s.IsCorruption()) |
| - factory_->HandleBackingStoreCorruption(backing_store_->origin(), error); |
| - return; |
| + return s; |
| } |
| } |
| { |
| @@ -1499,6 +1478,7 @@ void IndexedDBDatabase::PutOperation(std::unique_ptr<PutOperationParams> params, |
| ? blink::WebIDBAdd |
| : blink::WebIDBPut, |
| IndexedDBKeyRange(*key)); |
| + return s; |
| } |
| void IndexedDBDatabase::SetIndexKeys( |
| @@ -1507,6 +1487,7 @@ void IndexedDBDatabase::SetIndexKeys( |
| std::unique_ptr<IndexedDBKey> primary_key, |
| const std::vector<IndexedDBIndexKeys>& index_keys) { |
| IDB_TRACE1("IndexedDBDatabase::SetIndexKeys", "txn.id", transaction_id); |
| + |
| IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
| if (!transaction) |
| return; |
| @@ -1529,7 +1510,6 @@ void IndexedDBDatabase::SetIndexKeys( |
| transaction->Abort(error); |
| if (s.IsCorruption()) |
| factory_->HandleBackingStoreCorruption(backing_store_->origin(), error); |
| - return; |
| } |
| if (!found) { |
| transaction->Abort(IndexedDBDatabaseError( |
| @@ -1589,11 +1569,12 @@ void IndexedDBDatabase::SetIndexesReady(int64_t transaction_id, |
| index_ids.size())); |
| } |
| -void IndexedDBDatabase::SetIndexesReadyOperation( |
| +OperationResult IndexedDBDatabase::SetIndexesReadyOperation( |
| size_t index_count, |
| IndexedDBTransaction* transaction) { |
| for (size_t i = 0; i < index_count; ++i) |
| transaction->DidCompletePreemptiveEvent(); |
| + return leveldb::Status::OK(); |
| } |
| struct IndexedDBDatabase::OpenCursorOperationParams { |
| @@ -1641,7 +1622,7 @@ void IndexedDBDatabase::OpenCursor( |
| &IndexedDBDatabase::OpenCursorOperation, this, base::Passed(¶ms))); |
| } |
| -void IndexedDBDatabase::OpenCursorOperation( |
| +OperationResult IndexedDBDatabase::OpenCursorOperation( |
| std::unique_ptr<OpenCursorOperationParams> params, |
| IndexedDBTransaction* transaction) { |
| IDB_TRACE1( |
| @@ -1654,7 +1635,7 @@ void IndexedDBDatabase::OpenCursorOperation( |
| if (params->task_type == blink::WebIDBTaskTypePreemptive) |
| transaction->AddPreemptiveEvent(); |
| - leveldb::Status s; |
| + leveldb::Status s = leveldb::Status::OK(); |
| std::unique_ptr<IndexedDBBackingStore::Cursor> backing_store_cursor; |
| if (params->index_id == IndexedDBIndexMetadata::kInvalidId) { |
| if (params->cursor_type == indexed_db::CURSOR_KEY_ONLY) { |
| @@ -1702,15 +1683,13 @@ void IndexedDBDatabase::OpenCursorOperation( |
| DLOG(ERROR) << "Unable to open cursor operation: " << s.ToString(); |
| IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
| "Internal error opening cursor operation"); |
| - if (s.IsCorruption()) { |
| - factory_->HandleBackingStoreCorruption(backing_store_->origin(), error); |
| - } |
| + return s; |
| } |
| if (!backing_store_cursor) { |
| - // Why is Success being called? |
| - params->callbacks->OnSuccess(nullptr); |
| - return; |
| + // Occurs when we've reached the end of cursor's data. |
| + params->callbacks->OnSuccess(); |
| + return s; |
| } |
| scoped_refptr<IndexedDBCursor> cursor = |
| @@ -1718,6 +1697,7 @@ void IndexedDBDatabase::OpenCursorOperation( |
| params->task_type, transaction); |
| params->callbacks->OnSuccess( |
| cursor, cursor->key(), cursor->primary_key(), cursor->Value()); |
| + return s; |
| } |
| void IndexedDBDatabase::Count(int64_t transaction_id, |
| @@ -1741,7 +1721,7 @@ void IndexedDBDatabase::Count(int64_t transaction_id, |
| callbacks)); |
| } |
| -void IndexedDBDatabase::CountOperation( |
| +OperationResult IndexedDBDatabase::CountOperation( |
| int64_t object_store_id, |
| int64_t index_id, |
| std::unique_ptr<IndexedDBKeyRange> key_range, |
| @@ -1751,7 +1731,7 @@ void IndexedDBDatabase::CountOperation( |
| uint32_t count = 0; |
| std::unique_ptr<IndexedDBBackingStore::Cursor> backing_store_cursor; |
| - leveldb::Status s; |
| + leveldb::Status s = leveldb::Status::OK(); |
| if (index_id == IndexedDBIndexMetadata::kInvalidId) { |
| backing_store_cursor = backing_store_->OpenObjectStoreKeyCursor( |
| transaction->BackingStoreTransaction(), |
| @@ -1774,22 +1754,21 @@ void IndexedDBDatabase::CountOperation( |
| DLOG(ERROR) << "Unable perform count operation: " << s.ToString(); |
| IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
| "Internal error performing count operation"); |
| - if (s.IsCorruption()) { |
| - factory_->HandleBackingStoreCorruption(backing_store_->origin(), error); |
| - } |
| + return s; |
| } |
| if (!backing_store_cursor) { |
| callbacks->OnSuccess(count); |
| - return; |
| + return s; |
| } |
| do { |
| + if (!s.ok()) |
| + return s; |
| ++count; |
| } while (backing_store_cursor->Continue(&s)); |
| - // TODO(cmumford): Check for database corruption. |
| - |
| callbacks->OnSuccess(count); |
| + return s; |
| } |
| void IndexedDBDatabase::DeleteRange( |
| @@ -1813,7 +1792,7 @@ void IndexedDBDatabase::DeleteRange( |
| callbacks)); |
| } |
| -void IndexedDBDatabase::DeleteRangeOperation( |
| +OperationResult IndexedDBDatabase::DeleteRangeOperation( |
| int64_t object_store_id, |
| std::unique_ptr<IndexedDBKeyRange> key_range, |
| scoped_refptr<IndexedDBCallbacks> callbacks, |
| @@ -1830,14 +1809,12 @@ void IndexedDBDatabase::DeleteRangeOperation( |
| IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
| error_string); |
| transaction->Abort(error); |
| - if (s.IsCorruption()) { |
| - factory_->HandleBackingStoreCorruption(backing_store_->origin(), error); |
| - } |
| - return; |
| + return s; |
| } |
| callbacks->OnSuccess(); |
| FilterObservation(transaction, object_store_id, blink::WebIDBDelete, |
| *key_range); |
| + return s; |
| } |
| void IndexedDBDatabase::Clear(int64_t transaction_id, |
| @@ -1856,7 +1833,7 @@ void IndexedDBDatabase::Clear(int64_t transaction_id, |
| &IndexedDBDatabase::ClearOperation, this, object_store_id, callbacks)); |
| } |
| -void IndexedDBDatabase::ClearOperation( |
| +OperationResult IndexedDBDatabase::ClearOperation( |
| int64_t object_store_id, |
| scoped_refptr<IndexedDBCallbacks> callbacks, |
| IndexedDBTransaction* transaction) { |
| @@ -1867,18 +1844,16 @@ void IndexedDBDatabase::ClearOperation( |
| IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
| "Internal error clearing object store"); |
| callbacks->OnError(error); |
| - if (s.IsCorruption()) { |
| - factory_->HandleBackingStoreCorruption(backing_store_->origin(), error); |
| - } |
| - return; |
| + return s; |
| } |
| callbacks->OnSuccess(); |
| FilterObservation(transaction, object_store_id, blink::WebIDBClear, |
| IndexedDBKeyRange()); |
| + return s; |
| } |
| -void IndexedDBDatabase::DeleteObjectStoreOperation( |
| +OperationResult IndexedDBDatabase::DeleteObjectStoreOperation( |
| int64_t object_store_id, |
| IndexedDBTransaction* transaction) { |
| IDB_TRACE1("IndexedDBDatabase::DeleteObjectStoreOperation", |
| @@ -1898,9 +1873,7 @@ void IndexedDBDatabase::DeleteObjectStoreOperation( |
| IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
| error_string); |
| transaction->Abort(error); |
| - if (s.IsCorruption()) |
| - factory_->HandleBackingStoreCorruption(backing_store_->origin(), error); |
| - return; |
| + return s; |
| } |
| RemoveObjectStore(object_store_id); |
| @@ -1908,9 +1881,10 @@ void IndexedDBDatabase::DeleteObjectStoreOperation( |
| base::Bind(&IndexedDBDatabase::DeleteObjectStoreAbortOperation, |
| this, |
| object_store_metadata)); |
| + return s; |
| } |
| -void IndexedDBDatabase::VersionChangeOperation( |
| +OperationResult IndexedDBDatabase::VersionChangeOperation( |
| int64_t version, |
| scoped_refptr<IndexedDBCallbacks> callbacks, |
| IndexedDBTransaction* transaction) { |
| @@ -1919,17 +1893,8 @@ void IndexedDBDatabase::VersionChangeOperation( |
| int64_t old_version = metadata_.version; |
| DCHECK_GT(version, old_version); |
| - if (!backing_store_->UpdateIDBDatabaseIntVersion( |
| - transaction->BackingStoreTransaction(), id(), version)) { |
| - IndexedDBDatabaseError error( |
| - blink::WebIDBDatabaseExceptionUnknownError, |
| - ASCIIToUTF16( |
| - "Internal error writing data to stable storage when " |
| - "updating version.")); |
| - callbacks->OnError(error); |
| - transaction->Abort(error); |
| - return; |
| - } |
| + backing_store_->UpdateIDBDatabaseIntVersion( |
| + transaction->BackingStoreTransaction(), id(), version); |
| transaction->ScheduleAbortTask( |
| base::Bind(&IndexedDBDatabase::VersionChangeAbortOperation, this, |
| @@ -1937,6 +1902,7 @@ void IndexedDBDatabase::VersionChangeOperation( |
| metadata_.version = version; |
| active_request_->UpgradeTransactionStarted(old_version); |
| + return leveldb::Status::OK(); |
| } |
| void IndexedDBDatabase::TransactionFinished(IndexedDBTransaction* transaction, |
| @@ -1955,16 +1921,6 @@ void IndexedDBDatabase::TransactionFinished(IndexedDBTransaction* transaction, |
| } |
| } |
| -void IndexedDBDatabase::TransactionCommitFailed(const leveldb::Status& status) { |
| - if (status.IsCorruption()) { |
| - IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
| - "Error committing transaction"); |
| - factory_->HandleBackingStoreCorruption(backing_store_->origin(), error); |
| - } else { |
| - factory_->HandleBackingStoreFailure(backing_store_->origin()); |
| - } |
| -} |
| - |
| void IndexedDBDatabase::AppendRequest( |
| std::unique_ptr<ConnectionRequest> request) { |
| pending_requests_.push(std::move(request)); |
| @@ -2099,17 +2055,13 @@ void IndexedDBDatabase::Close(IndexedDBConnection* connection, bool forced) { |
| } |
| void IndexedDBDatabase::CreateObjectStoreAbortOperation( |
| - int64_t object_store_id, |
| - IndexedDBTransaction* transaction) { |
| - DCHECK(!transaction); |
| + int64_t object_store_id) { |
| IDB_TRACE("IndexedDBDatabase::CreateObjectStoreAbortOperation"); |
| RemoveObjectStore(object_store_id); |
| } |
| void IndexedDBDatabase::DeleteObjectStoreAbortOperation( |
| - const IndexedDBObjectStoreMetadata& object_store_metadata, |
| - IndexedDBTransaction* transaction) { |
| - DCHECK(!transaction); |
| + const IndexedDBObjectStoreMetadata& object_store_metadata) { |
| IDB_TRACE("IndexedDBDatabase::DeleteObjectStoreAbortOperation"); |
| AddObjectStore(object_store_metadata, |
| IndexedDBObjectStoreMetadata::kInvalidId); |
| @@ -2117,17 +2069,12 @@ void IndexedDBDatabase::DeleteObjectStoreAbortOperation( |
| void IndexedDBDatabase::RenameObjectStoreAbortOperation( |
| int64_t object_store_id, |
| - const base::string16& old_name, |
| - IndexedDBTransaction* transaction) { |
| - DCHECK(!transaction); |
| + const base::string16& old_name) { |
| IDB_TRACE("IndexedDBDatabase::RenameObjectStoreAbortOperation"); |
| SetObjectStoreName(object_store_id, old_name); |
| } |
| -void IndexedDBDatabase::VersionChangeAbortOperation( |
| - int64_t previous_version, |
| - IndexedDBTransaction* transaction) { |
| - DCHECK(!transaction); |
| +void IndexedDBDatabase::VersionChangeAbortOperation(int64_t previous_version) { |
| IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); |
| metadata_.version = previous_version; |
| } |