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

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

Issue 124323002: IndexedDB: Fix cursor prefetching edge cases (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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
« no previous file with comments | « content/browser/indexed_db/indexed_db_cursor.h ('k') | content/child/indexed_db/webidbcursor_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6d7bc1c2d5914df345f3d0b1f652f12e57f0b036..fe4d32e9ffa5ea3fd9063129fbad4a1689fe8f82 100644
--- a/content/browser/indexed_db/indexed_db_cursor.cc
+++ b/content/browser/indexed_db/indexed_db_cursor.cc
@@ -108,8 +108,7 @@ void IndexedDBCursor::CursorPrefetchIterationOperation(
std::vector<IndexedDBKey> found_primary_keys;
std::vector<std::string> found_values;
- if (cursor_)
- saved_cursor_.reset(cursor_->Clone());
+ saved_cursor_.reset();
const size_t max_size_estimate = 10 * 1024 * 1024;
size_t size_estimate = 0;
@@ -119,6 +118,11 @@ void IndexedDBCursor::CursorPrefetchIterationOperation(
break;
}
+ if (i == 0) {
+ // First prefetched result is always used and can't be reset.
+ saved_cursor_.reset(cursor_->Clone());
+ }
+
found_keys.push_back(cursor_->key());
found_primary_keys.push_back(cursor_->primary_key());
@@ -152,15 +156,29 @@ void IndexedDBCursor::CursorPrefetchIterationOperation(
found_keys, found_primary_keys, found_values);
}
-void IndexedDBCursor::PrefetchReset(int used_prefetches, int) {
+void IndexedDBCursor::PrefetchReset(int used_prefetches,
+ int /* unused_prefetches */) {
IDB_TRACE("IndexedDBCursor::PrefetchReset");
+ transaction_->ScheduleTask(
jsbell 2014/01/03 23:05:11 I haven't convinced myself one way or another whet
jsbell 2014/01/06 17:51:55 After further reflection, this shouldn't be necess
+ task_type_,
+ base::Bind(&IndexedDBCursor::CursorPrefetchResetOperation,
+ this,
+ used_prefetches));
+}
+
+void IndexedDBCursor::CursorPrefetchResetOperation(
+ int used_prefetches,
+ IndexedDBTransaction* /*transaction*/) {
+ IDB_TRACE("IndexedDBCursor::CursorPrefetchIterationOperation");
+
cursor_.swap(saved_cursor_);
saved_cursor_.reset();
if (closed_)
return;
if (cursor_) {
- for (int i = 0; i < used_prefetches; ++i) {
+ DCHECK_GT(used_prefetches, 0);
+ for (int i = 0; i < used_prefetches - 1; ++i) {
bool ok = cursor_->Continue();
DCHECK(ok);
}
« no previous file with comments | « content/browser/indexed_db/indexed_db_cursor.h ('k') | content/child/indexed_db/webidbcursor_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698