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

Unified Diff: content/common/indexed_db/proxy_webidbcursor_impl.cc

Issue 9691021: IndexedDB: Fix prefetching; cache was always being bypassed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added unit tests to verify prefetch cache is used Created 8 years, 9 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/common/indexed_db/proxy_webidbcursor_impl.cc
diff --git a/content/common/indexed_db/proxy_webidbcursor_impl.cc b/content/common/indexed_db/proxy_webidbcursor_impl.cc
index f043356171fdbe58f43eac00908d79113b030043..5fa1c8703a60fbd1bab2eb1870728fa4d1b1e9be 100644
--- a/content/common/indexed_db/proxy_webidbcursor_impl.cc
+++ b/content/common/indexed_db/proxy_webidbcursor_impl.cc
@@ -26,6 +26,8 @@ RendererWebIDBCursorImpl::~RendererWebIDBCursorImpl() {
// object since inside WebKit, they hold a reference to the object wich owns
// this object. But, if that ever changed, then we'd need to invalidate
// any such pointers.
+ if (idb_cursor_id_ == kInvalidIDBCursorId)
+ return;
IndexedDBDispatcher::Send(new IndexedDBHostMsg_CursorDestroyed(
idb_cursor_id_));
IndexedDBDispatcher* dispatcher =
@@ -34,6 +36,8 @@ RendererWebIDBCursorImpl::~RendererWebIDBCursorImpl() {
}
unsigned short RendererWebIDBCursorImpl::direction() const {
+ if (idb_cursor_id_ == kInvalidIDBCursorId)
+ return 0;
int direction;
IndexedDBDispatcher::Send(
new IndexedDBHostMsg_CursorDirection(idb_cursor_id_, &direction));
@@ -55,6 +59,8 @@ WebSerializedScriptValue RendererWebIDBCursorImpl::value() const {
void RendererWebIDBCursorImpl::update(const WebSerializedScriptValue& value,
WebIDBCallbacks* callbacks,
WebExceptionCode& ec) {
+ if (idb_cursor_id_ == kInvalidIDBCursorId)
+ return;
IndexedDBDispatcher* dispatcher =
IndexedDBDispatcher::ThreadSpecificInstance();
dispatcher->RequestIDBCursorUpdate(
@@ -67,7 +73,7 @@ void RendererWebIDBCursorImpl::continueFunction(const WebIDBKey& key,
IndexedDBDispatcher* dispatcher =
IndexedDBDispatcher::ThreadSpecificInstance();
- if (key.type() == WebIDBKey::InvalidType) {
+ if (key.type() == WebIDBKey::NullType) {
// No key, so this would qualify for a prefetch.
++continue_count_;
@@ -77,6 +83,9 @@ void RendererWebIDBCursorImpl::continueFunction(const WebIDBKey& key,
return;
}
+ if (idb_cursor_id_ == kInvalidIDBCursorId)
+ return;
+
if (continue_count_ > kPrefetchContinueThreshold) {
// Request pre-fetch.
dispatcher->RequestIDBCursorPrefetch(prefetch_amount_, callbacks,
@@ -94,12 +103,17 @@ void RendererWebIDBCursorImpl::continueFunction(const WebIDBKey& key,
ResetPrefetchCache();
}
+ if (idb_cursor_id_ == kInvalidIDBCursorId)
+ return;
+
dispatcher->RequestIDBCursorContinue(IndexedDBKey(key), callbacks,
idb_cursor_id_, &ec);
}
void RendererWebIDBCursorImpl::deleteFunction(WebIDBCallbacks* callbacks,
WebExceptionCode& ec) {
+ if (idb_cursor_id_ == kInvalidIDBCursorId)
+ return;
IndexedDBDispatcher* dispatcher =
IndexedDBDispatcher::ThreadSpecificInstance();
dispatcher->RequestIDBCursorDelete(callbacks, idb_cursor_id_, &ec);
@@ -168,11 +182,14 @@ void RendererWebIDBCursorImpl::ResetPrefetchCache() {
return;
}
- IndexedDBDispatcher* dispatcher =
- IndexedDBDispatcher::ThreadSpecificInstance();
- dispatcher->RequestIDBCursorPrefetchReset(used_prefetches_,
- prefetch_keys_.size(),
- idb_cursor_id_);
+ if (idb_cursor_id_ != kInvalidIDBCursorId) {
+ IndexedDBDispatcher* dispatcher =
+ IndexedDBDispatcher::ThreadSpecificInstance();
+ dispatcher->RequestIDBCursorPrefetchReset(used_prefetches_,
+ prefetch_keys_.size(),
+ idb_cursor_id_);
+ }
+
prefetch_keys_.clear();
prefetch_primary_keys_.clear();
prefetch_values_.clear();

Powered by Google App Engine
This is Rietveld 408576698