| Index: content/browser/indexed_db/indexed_db_backing_store.cc
|
| diff --git a/content/browser/indexed_db/indexed_db_backing_store.cc b/content/browser/indexed_db/indexed_db_backing_store.cc
|
| index 1f7d36672e73d2e6d6ed1aa78c4fc3fb8b7cdc11..4f80b83e53290b2d9824b6624aaf72c7af51679b 100644
|
| --- a/content/browser/indexed_db/indexed_db_backing_store.cc
|
| +++ b/content/browser/indexed_db/indexed_db_backing_store.cc
|
| @@ -1339,7 +1339,7 @@ leveldb::Status IndexedDBBackingStore::CreateIDBDatabaseMetaData(
|
| return s;
|
| }
|
|
|
| -bool IndexedDBBackingStore::UpdateIDBDatabaseIntVersion(
|
| +void IndexedDBBackingStore::UpdateIDBDatabaseIntVersion(
|
| IndexedDBBackingStore::Transaction* transaction,
|
| int64_t row_id,
|
| int64_t version) {
|
| @@ -1350,7 +1350,6 @@ bool IndexedDBBackingStore::UpdateIDBDatabaseIntVersion(
|
| transaction->transaction(),
|
| DatabaseMetaDataKey::Encode(row_id, DatabaseMetaDataKey::USER_VERSION),
|
| version);
|
| - return true;
|
| }
|
|
|
| // If you're deleting a range that contains user keys that have blob info, this
|
| @@ -3201,16 +3200,18 @@ bool IndexedDBBackingStore::Cursor::Continue(const IndexedDBKey* key,
|
| DCHECK(!key || next_state == SEEK);
|
|
|
| if (cursor_options_.forward)
|
| - return ContinueNext(key, primary_key, next_state, s);
|
| + return ContinueNext(key, primary_key, next_state, s) ==
|
| + ContinueResult::DONE;
|
| else
|
| - return ContinuePrevious(key, primary_key, next_state, s);
|
| + return ContinuePrevious(key, primary_key, next_state, s) ==
|
| + ContinueResult::DONE;
|
| }
|
|
|
| -bool IndexedDBBackingStore::Cursor::ContinueNext(
|
| - const IndexedDBKey* key,
|
| - const IndexedDBKey* primary_key,
|
| - IteratorState next_state,
|
| - leveldb::Status* s) {
|
| +IndexedDBBackingStore::Cursor::ContinueResult
|
| +IndexedDBBackingStore::Cursor::ContinueNext(const IndexedDBKey* key,
|
| + const IndexedDBKey* primary_key,
|
| + IteratorState next_state,
|
| + leveldb::Status* s) {
|
| DCHECK(cursor_options_.forward);
|
| DCHECK(!key || key->IsValid());
|
| DCHECK(!primary_key || primary_key->IsValid());
|
| @@ -3226,7 +3227,7 @@ bool IndexedDBBackingStore::Cursor::ContinueNext(
|
| primary_key ? EncodeKey(*key, *primary_key) : EncodeKey(*key);
|
| *s = iterator_->Seek(leveldb_key);
|
| if (!s->ok())
|
| - return false;
|
| + return ContinueResult::LEVELDB_ERROR;
|
| // Cursor is at the next value already; don't advance it again below.
|
| next_state = READY;
|
| }
|
| @@ -3238,14 +3239,14 @@ bool IndexedDBBackingStore::Cursor::ContinueNext(
|
| if (next_state == SEEK) {
|
| *s = iterator_->Next();
|
| if (!s->ok())
|
| - return false;
|
| + return ContinueResult::LEVELDB_ERROR;
|
| } else {
|
| next_state = SEEK;
|
| }
|
|
|
| // Fail if we've run out of data or gone past the cursor's bounds.
|
| if (!iterator_->IsValid() || IsPastBounds())
|
| - return false;
|
| + return ContinueResult::OUT_OF_BOUNDS;
|
|
|
| // TODO(jsbell): Document why this might be false. When do we ever not
|
| // seek into the range before starting cursor iteration?
|
| @@ -3256,7 +3257,7 @@ bool IndexedDBBackingStore::Cursor::ContinueNext(
|
| // error then not fatal.
|
| if (!LoadCurrentRow(s)) {
|
| if (!s->ok())
|
| - return false;
|
| + return ContinueResult::LEVELDB_ERROR;
|
| continue;
|
| }
|
|
|
| @@ -3271,14 +3272,14 @@ bool IndexedDBBackingStore::Cursor::ContinueNext(
|
| break;
|
| }
|
|
|
| - return true;
|
| + return ContinueResult::DONE;
|
| }
|
|
|
| -bool IndexedDBBackingStore::Cursor::ContinuePrevious(
|
| - const IndexedDBKey* key,
|
| - const IndexedDBKey* primary_key,
|
| - IteratorState next_state,
|
| - leveldb::Status* s) {
|
| +IndexedDBBackingStore::Cursor::ContinueResult
|
| +IndexedDBBackingStore::Cursor::ContinuePrevious(const IndexedDBKey* key,
|
| + const IndexedDBKey* primary_key,
|
| + IteratorState next_state,
|
| + leveldb::Status* s) {
|
| DCHECK(!cursor_options_.forward);
|
| DCHECK(!key || key->IsValid());
|
| DCHECK(!primary_key || primary_key->IsValid());
|
| @@ -3304,7 +3305,7 @@ bool IndexedDBBackingStore::Cursor::ContinuePrevious(
|
| if (next_state == SEEK) {
|
| *s = iterator_->Prev();
|
| if (!s->ok())
|
| - return false;
|
| + return ContinueResult::LEVELDB_ERROR;
|
| } else {
|
| next_state = SEEK; // for subsequent iterations
|
| }
|
| @@ -3313,7 +3314,7 @@ bool IndexedDBBackingStore::Cursor::ContinuePrevious(
|
| if (!iterator_->IsValid() || IsPastBounds()) {
|
| if (duplicate_key.IsValid())
|
| break;
|
| - return false;
|
| + return ContinueResult::OUT_OF_BOUNDS;
|
| }
|
|
|
| // TODO(jsbell): Document why this might be false. When do we ever not
|
| @@ -3325,7 +3326,7 @@ bool IndexedDBBackingStore::Cursor::ContinuePrevious(
|
| // error then not fatal.
|
| if (!LoadCurrentRow(s)) {
|
| if (!s->ok())
|
| - return false;
|
| + return ContinueResult::LEVELDB_ERROR;
|
| continue;
|
| }
|
|
|
| @@ -3372,14 +3373,14 @@ bool IndexedDBBackingStore::Cursor::ContinuePrevious(
|
|
|
| *s = iterator_->Seek(earliest_duplicate);
|
| if (!s->ok())
|
| - return false;
|
| + return ContinueResult::LEVELDB_ERROR;
|
| if (!LoadCurrentRow(s)) {
|
| DCHECK(!s->ok());
|
| - return false;
|
| + return ContinueResult::LEVELDB_ERROR;
|
| }
|
| }
|
|
|
| - return true;
|
| + return ContinueResult::DONE;
|
| }
|
|
|
| bool IndexedDBBackingStore::Cursor::HaveEnteredRange() const {
|
| @@ -3809,7 +3810,8 @@ bool ObjectStoreCursorOptions(
|
| int64_t object_store_id,
|
| const IndexedDBKeyRange& range,
|
| blink::WebIDBCursorDirection direction,
|
| - IndexedDBBackingStore::Cursor::CursorOptions* cursor_options) {
|
| + IndexedDBBackingStore::Cursor::CursorOptions* cursor_options,
|
| + leveldb::Status* status) {
|
| cursor_options->database_id = database_id;
|
| cursor_options->object_store_id = object_store_id;
|
|
|
| @@ -3832,8 +3834,6 @@ bool ObjectStoreCursorOptions(
|
| cursor_options->low_open = range.lower_open();
|
| }
|
|
|
| - leveldb::Status s;
|
| -
|
| if (!upper_bound) {
|
| cursor_options->high_key =
|
| ObjectStoreDataKey::Encode(database_id, object_store_id, MaxIDBKey());
|
| @@ -3842,11 +3842,8 @@ bool ObjectStoreCursorOptions(
|
| cursor_options->high_open = true; // Not included.
|
| } else {
|
| // We need a key that exists.
|
| - // TODO(cmumford): Handle this error (crbug.com/363397)
|
| - if (!FindGreatestKeyLessThanOrEqual(transaction,
|
| - cursor_options->high_key,
|
| - &cursor_options->high_key,
|
| - &s))
|
| + if (!FindGreatestKeyLessThanOrEqual(transaction, cursor_options->high_key,
|
| + &cursor_options->high_key, status))
|
| return false;
|
| cursor_options->high_open = false;
|
| }
|
| @@ -3858,9 +3855,8 @@ bool ObjectStoreCursorOptions(
|
| if (!cursor_options->forward) {
|
| // For reverse cursors, we need a key that exists.
|
| std::string found_high_key;
|
| - // TODO(cmumford): Handle this error (crbug.com/363397)
|
| - if (!FindGreatestKeyLessThanOrEqual(
|
| - transaction, cursor_options->high_key, &found_high_key, &s))
|
| + if (!FindGreatestKeyLessThanOrEqual(transaction, cursor_options->high_key,
|
| + &found_high_key, status))
|
| return false;
|
|
|
| // If the target key should not be included, but we end up with a smaller
|
| @@ -3883,7 +3879,8 @@ bool IndexCursorOptions(
|
| int64_t index_id,
|
| const IndexedDBKeyRange& range,
|
| blink::WebIDBCursorDirection direction,
|
| - IndexedDBBackingStore::Cursor::CursorOptions* cursor_options) {
|
| + IndexedDBBackingStore::Cursor::CursorOptions* cursor_options,
|
| + leveldb::Status* status) {
|
| DCHECK(transaction);
|
| if (!KeyPrefix::ValidIds(database_id, object_store_id, index_id))
|
| return false;
|
| @@ -3911,18 +3908,15 @@ bool IndexCursorOptions(
|
| cursor_options->low_open = range.lower_open();
|
| }
|
|
|
| - leveldb::Status s;
|
| -
|
| if (!upper_bound) {
|
| cursor_options->high_key =
|
| IndexDataKey::EncodeMaxKey(database_id, object_store_id, index_id);
|
| cursor_options->high_open = false; // Included.
|
|
|
| - if (!cursor_options->forward) { // We need a key that exists.
|
| - if (!FindGreatestKeyLessThanOrEqual(transaction,
|
| - cursor_options->high_key,
|
| - &cursor_options->high_key,
|
| - &s))
|
| + if (!cursor_options->forward) {
|
| + // We need a key that exists.
|
| + if (!FindGreatestKeyLessThanOrEqual(transaction, cursor_options->high_key,
|
| + &cursor_options->high_key, status))
|
| return false;
|
| cursor_options->high_open = false;
|
| }
|
| @@ -3933,9 +3927,8 @@ bool IndexCursorOptions(
|
|
|
| std::string found_high_key;
|
| // Seek to the *last* key in the set of non-unique keys
|
| - // TODO(cmumford): Handle this error (crbug.com/363397)
|
| - if (!FindGreatestKeyLessThanOrEqual(
|
| - transaction, cursor_options->high_key, &found_high_key, &s))
|
| + if (!FindGreatestKeyLessThanOrEqual(transaction, cursor_options->high_key,
|
| + &found_high_key, status))
|
| return false;
|
|
|
| // If the target key should not be included, but we end up with a smaller
|
| @@ -3959,16 +3952,14 @@ IndexedDBBackingStore::OpenObjectStoreCursor(
|
| blink::WebIDBCursorDirection direction,
|
| leveldb::Status* s) {
|
| IDB_TRACE("IndexedDBBackingStore::OpenObjectStoreCursor");
|
| - *s = leveldb::Status::OK();
|
| LevelDBTransaction* leveldb_transaction = transaction->transaction();
|
| IndexedDBBackingStore::Cursor::CursorOptions cursor_options;
|
| - if (!ObjectStoreCursorOptions(leveldb_transaction,
|
| - database_id,
|
| - object_store_id,
|
| - range,
|
| - direction,
|
| - &cursor_options))
|
| + // TODO(cmumford): Handle this error (crbug.com/363397)
|
| + if (!ObjectStoreCursorOptions(leveldb_transaction, database_id,
|
| + object_store_id, range, direction,
|
| + &cursor_options, s)) {
|
| return std::unique_ptr<IndexedDBBackingStore::Cursor>();
|
| + }
|
| std::unique_ptr<ObjectStoreCursorImpl> cursor(
|
| base::MakeUnique<ObjectStoreCursorImpl>(this, transaction, database_id,
|
| cursor_options));
|
| @@ -3987,16 +3978,14 @@ IndexedDBBackingStore::OpenObjectStoreKeyCursor(
|
| blink::WebIDBCursorDirection direction,
|
| leveldb::Status* s) {
|
| IDB_TRACE("IndexedDBBackingStore::OpenObjectStoreKeyCursor");
|
| - *s = leveldb::Status::OK();
|
| LevelDBTransaction* leveldb_transaction = transaction->transaction();
|
| IndexedDBBackingStore::Cursor::CursorOptions cursor_options;
|
| - if (!ObjectStoreCursorOptions(leveldb_transaction,
|
| - database_id,
|
| - object_store_id,
|
| - range,
|
| - direction,
|
| - &cursor_options))
|
| + // TODO(cmumford): Handle this error (crbug.com/363397)
|
| + if (!ObjectStoreCursorOptions(leveldb_transaction, database_id,
|
| + object_store_id, range, direction,
|
| + &cursor_options, s)) {
|
| return std::unique_ptr<IndexedDBBackingStore::Cursor>();
|
| + }
|
| std::unique_ptr<ObjectStoreKeyCursorImpl> cursor(
|
| base::MakeUnique<ObjectStoreKeyCursorImpl>(this, transaction, database_id,
|
| cursor_options));
|
| @@ -4019,13 +4008,8 @@ IndexedDBBackingStore::OpenIndexKeyCursor(
|
| *s = leveldb::Status::OK();
|
| LevelDBTransaction* leveldb_transaction = transaction->transaction();
|
| IndexedDBBackingStore::Cursor::CursorOptions cursor_options;
|
| - if (!IndexCursorOptions(leveldb_transaction,
|
| - database_id,
|
| - object_store_id,
|
| - index_id,
|
| - range,
|
| - direction,
|
| - &cursor_options))
|
| + if (!IndexCursorOptions(leveldb_transaction, database_id, object_store_id,
|
| + index_id, range, direction, &cursor_options, s))
|
| return std::unique_ptr<IndexedDBBackingStore::Cursor>();
|
| std::unique_ptr<IndexKeyCursorImpl> cursor(
|
| base::MakeUnique<IndexKeyCursorImpl>(this, transaction, database_id,
|
| @@ -4048,13 +4032,8 @@ IndexedDBBackingStore::OpenIndexCursor(
|
| IDB_TRACE("IndexedDBBackingStore::OpenIndexCursor");
|
| LevelDBTransaction* leveldb_transaction = transaction->transaction();
|
| IndexedDBBackingStore::Cursor::CursorOptions cursor_options;
|
| - if (!IndexCursorOptions(leveldb_transaction,
|
| - database_id,
|
| - object_store_id,
|
| - index_id,
|
| - range,
|
| - direction,
|
| - &cursor_options))
|
| + if (!IndexCursorOptions(leveldb_transaction, database_id, object_store_id,
|
| + index_id, range, direction, &cursor_options, s))
|
| return std::unique_ptr<IndexedDBBackingStore::Cursor>();
|
| std::unique_ptr<IndexCursorImpl> cursor(
|
| new IndexCursorImpl(this, transaction, database_id, cursor_options));
|
|
|