Index: content/browser/indexed_db/indexed_db_cursor.cc |
diff --git a/content/browser/indexed_db/indexed_db_cursor.cc b/content/browser/indexed_db/indexed_db_cursor.cc |
index b32c7c2a0f14d2e848ac66591bb6f7b0e45f0160..e741234e66dabe0ba14c35b960e5d992a4b1744c 100644 |
--- a/content/browser/indexed_db/indexed_db_cursor.cc |
+++ b/content/browser/indexed_db/indexed_db_cursor.cc |
@@ -60,12 +60,20 @@ void IndexedDBCursor::CursorAdvanceOperation( |
scoped_refptr<IndexedDBCallbacks> callbacks, |
IndexedDBTransaction* /*transaction*/) { |
IDB_TRACE("IndexedDBCursor::CursorAdvanceOperation"); |
- if (!cursor_ || !cursor_->Advance(count)) { |
+ leveldb::Status s; |
+ if (!cursor_ || !cursor_->Advance(count, s)) { |
cursor_.reset(); |
callbacks->OnSuccess(static_cast<IndexedDBValue*>(NULL)); |
return; |
} |
+ if (!s.ok()) { |
jsbell
2014/04/14 20:44:20
Won't Advance() return false if !s.ok() ?
cmumford
2014/04/14 23:39:23
Done.
|
+ // TODO(cmumford): Handle corruption |
+ if (s.IsCorruption()) { |
jsbell
2014/04/14 20:44:20
Remove this placeholder code, make the TODO more v
cmumford
2014/04/14 23:39:23
Yeah, I shouldn't have left this block in there. I
|
+ } |
+ return; |
jsbell
2014/04/14 20:44:20
Wouldn't this mean that the callbacks (i.e. reques
cmumford
2014/04/14 23:39:23
Done.
|
+ } |
+ |
callbacks->OnSuccess(key(), primary_key(), Value()); |
} |
@@ -75,9 +83,11 @@ void IndexedDBCursor::CursorIterationOperation( |
scoped_refptr<IndexedDBCallbacks> callbacks, |
IndexedDBTransaction* /*transaction*/) { |
IDB_TRACE("IndexedDBCursor::CursorIterationOperation"); |
- if (!cursor_ || |
- !cursor_->Continue( |
- key.get(), primary_key.get(), IndexedDBBackingStore::Cursor::SEEK)) { |
+ leveldb::Status s; |
+ if (!cursor_ || !cursor_->Continue(key.get(), |
+ primary_key.get(), |
+ IndexedDBBackingStore::Cursor::SEEK, |
+ s)) { |
jsbell
2014/04/14 20:44:20
Does this need a corresponding check for s.ok() ?
cmumford
2014/04/14 23:39:23
Done. Also added TODO for handling of corrupted db
|
cursor_.reset(); |
callbacks->OnSuccess(static_cast<IndexedDBValue*>(NULL)); |
return; |
@@ -112,9 +122,10 @@ void IndexedDBCursor::CursorPrefetchIterationOperation( |
saved_cursor_.reset(); |
const size_t max_size_estimate = 10 * 1024 * 1024; |
size_t size_estimate = 0; |
+ leveldb::Status s; |
for (int i = 0; i < number_to_fetch; ++i) { |
- if (!cursor_ || !cursor_->Continue()) { |
+ if (!cursor_ || !cursor_->Continue(s)) { |
cursor_.reset(); |
break; |
} |
@@ -149,6 +160,13 @@ void IndexedDBCursor::CursorPrefetchIterationOperation( |
break; |
} |
+ if (!s.ok()) { |
jsbell
2014/04/14 20:44:20
As above.
cmumford
2014/04/14 23:39:23
Done.
|
+ // TODO(cmumford): Handle corruption |
+ if (s.IsCorruption()) { |
+ } |
+ return; |
+ } |
+ |
if (!found_keys.size()) { |
callbacks->OnSuccess(static_cast<IndexedDBValue*>(NULL)); |
return; |
@@ -158,22 +176,25 @@ void IndexedDBCursor::CursorPrefetchIterationOperation( |
found_keys, found_primary_keys, found_values); |
} |
-void IndexedDBCursor::PrefetchReset(int used_prefetches, |
- int /* unused_prefetches */) { |
+leveldb::Status IndexedDBCursor::PrefetchReset(int used_prefetches, |
+ int /* unused_prefetches */) { |
IDB_TRACE("IndexedDBCursor::PrefetchReset"); |
cursor_.swap(saved_cursor_); |
saved_cursor_.reset(); |
+ leveldb::Status s; |
jsbell
2014/04/14 20:44:20
Initialized to the default here (i.e. OK), but els
cmumford
2014/04/14 23:39:23
Else where I've been setting to Status::OK() only
|
if (closed_) |
- return; |
+ return s; |
if (cursor_) { |
// First prefetched result is always used. |
DCHECK_GT(used_prefetches, 0); |
for (int i = 0; i < used_prefetches - 1; ++i) { |
- bool ok = cursor_->Continue(); |
+ bool ok = cursor_->Continue(s); |
DCHECK(ok); |
jsbell
2014/04/14 20:44:20
Is this DCHECK is invalid in the face of corruptio
cmumford
2014/04/14 23:39:23
Yes, but false is also returned on other errors. I
|
} |
} |
+ |
+ return s; |
} |
void IndexedDBCursor::Close() { |