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

Unified Diff: content/renderer/indexed_db_dispatcher.cc

Issue 8662017: IndexedDB: Cursor pre-fetching. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tighten the browser test a little Created 9 years, 1 month 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/renderer/indexed_db_dispatcher.cc
diff --git a/content/renderer/indexed_db_dispatcher.cc b/content/renderer/indexed_db_dispatcher.cc
index 7fd09548c8df58bc5ba6dc7346cb46e653b47cac..fea473761da04644ed83404d241109dd729eb959 100644
--- a/content/renderer/indexed_db_dispatcher.cc
+++ b/content/renderer/indexed_db_dispatcher.cc
@@ -44,6 +44,8 @@ bool IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) {
OnSuccessOpenCursor)
IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorContinue,
OnSuccessCursorContinue)
+ IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorPrefetch,
+ OnSuccessCursorPrefetch)
IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBDatabase,
OnSuccessIDBDatabase)
IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIndexedDBKey,
@@ -70,6 +72,7 @@ void IndexedDBDispatcher::RequestIDBCursorUpdate(
WebIDBCallbacks* callbacks_ptr,
int32 idb_cursor_id,
WebExceptionCode* ec) {
+ ResetCursorPrefetchCaches();
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
int32 response_id = pending_callbacks_.Add(callbacks.release());
@@ -84,6 +87,9 @@ void IndexedDBDispatcher::RequestIDBCursorContinue(
WebIDBCallbacks* callbacks_ptr,
int32 idb_cursor_id,
WebExceptionCode* ec) {
+ // Reset all cursor prefetch caches except for this cursor.
+ ResetCursorPrefetchCaches(idb_cursor_id);
+
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
int32 response_id = pending_callbacks_.Add(callbacks.release());
@@ -93,10 +99,32 @@ void IndexedDBDispatcher::RequestIDBCursorContinue(
pending_callbacks_.Remove(response_id);
}
+void IndexedDBDispatcher::RequestIDBCursorPrefetch(
+ int n,
+ WebIDBCallbacks* callbacks_ptr,
+ int32 idb_cursor_id,
+ WebExceptionCode* ec) {
+ scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
+
+ int32 response_id = pending_callbacks_.Add(callbacks.release());
+ RenderThreadImpl::current()->Send(
+ new IndexedDBHostMsg_CursorPrefetch(idb_cursor_id, response_id, n, ec));
+ if (*ec)
+ pending_callbacks_.Remove(response_id);
+}
+
+void IndexedDBDispatcher::RequestIDBCursorPrefetchReset(
+ int used_prefetches, int unused_prefetches, int32 idb_cursor_id) {
+ RenderThreadImpl::current()->Send(
+ new IndexedDBHostMsg_CursorPrefetchReset(idb_cursor_id, used_prefetches,
+ unused_prefetches));
+}
+
void IndexedDBDispatcher::RequestIDBCursorDelete(
WebIDBCallbacks* callbacks_ptr,
int32 idb_cursor_id,
WebExceptionCode* ec) {
+ ResetCursorPrefetchCaches();
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
int32 response_id = pending_callbacks_.Add(callbacks.release());
@@ -111,6 +139,7 @@ void IndexedDBDispatcher::RequestIDBFactoryOpen(
WebIDBCallbacks* callbacks_ptr,
const string16& origin,
WebFrame* web_frame) {
+ ResetCursorPrefetchCaches();
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
if (!web_frame)
@@ -130,6 +159,7 @@ void IndexedDBDispatcher::RequestIDBFactoryGetDatabaseNames(
WebIDBCallbacks* callbacks_ptr,
const string16& origin,
WebFrame* web_frame) {
+ ResetCursorPrefetchCaches();
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
if (!web_frame)
@@ -150,6 +180,7 @@ void IndexedDBDispatcher::RequestIDBFactoryDeleteDatabase(
WebIDBCallbacks* callbacks_ptr,
const string16& origin,
WebFrame* web_frame) {
+ ResetCursorPrefetchCaches();
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
if (!web_frame)
@@ -167,6 +198,7 @@ void IndexedDBDispatcher::RequestIDBFactoryDeleteDatabase(
}
void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) {
+ ResetCursorPrefetchCaches();
RenderThreadImpl::current()->Send(
new IndexedDBHostMsg_DatabaseClose(idb_database_id));
pending_database_callbacks_.Remove(idb_database_id);
@@ -175,6 +207,7 @@ void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) {
void IndexedDBDispatcher::RequestIDBDatabaseOpen(
WebIDBDatabaseCallbacks* callbacks_ptr,
int32 idb_database_id) {
+ ResetCursorPrefetchCaches();
scoped_ptr<WebIDBDatabaseCallbacks> callbacks(callbacks_ptr);
int32 response_id = pending_database_callbacks_.Add(callbacks.release());
@@ -187,6 +220,7 @@ void IndexedDBDispatcher::RequestIDBDatabaseSetVersion(
WebIDBCallbacks* callbacks_ptr,
int32 idb_database_id,
WebExceptionCode* ec) {
+ ResetCursorPrefetchCaches();
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
int32 response_id = pending_callbacks_.Add(callbacks.release());
@@ -204,6 +238,7 @@ void IndexedDBDispatcher::RequestIDBIndexOpenObjectCursor(
int32 idb_index_id,
const WebIDBTransaction& transaction,
WebExceptionCode* ec) {
+ ResetCursorPrefetchCaches();
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
IndexedDBHostMsg_IndexOpenCursor_Params params;
params.response_id = pending_callbacks_.Add(callbacks.release());
@@ -227,6 +262,7 @@ void IndexedDBDispatcher::RequestIDBIndexOpenKeyCursor(
int32 idb_index_id,
const WebIDBTransaction& transaction,
WebExceptionCode* ec) {
+ ResetCursorPrefetchCaches();
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
IndexedDBHostMsg_IndexOpenCursor_Params params;
params.response_id = pending_callbacks_.Add(callbacks.release());
@@ -251,6 +287,7 @@ void IndexedDBDispatcher::RequestIDBIndexGetObject(
int32 idb_index_id,
const WebIDBTransaction& transaction,
WebExceptionCode* ec) {
+ ResetCursorPrefetchCaches();
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
int32 response_id = pending_callbacks_.Add(callbacks.release());
RenderThreadImpl::current()->Send(
@@ -267,6 +304,7 @@ void IndexedDBDispatcher::RequestIDBIndexGetKey(
int32 idb_index_id,
const WebIDBTransaction& transaction,
WebExceptionCode* ec) {
+ ResetCursorPrefetchCaches();
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
int32 response_id = pending_callbacks_.Add(callbacks.release());
RenderThreadImpl::current()->Send(
@@ -283,6 +321,7 @@ void IndexedDBDispatcher::RequestIDBObjectStoreGet(
int32 idb_object_store_id,
const WebIDBTransaction& transaction,
WebExceptionCode* ec) {
+ ResetCursorPrefetchCaches();
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
int32 response_id = pending_callbacks_.Add(callbacks.release());
@@ -302,6 +341,7 @@ void IndexedDBDispatcher::RequestIDBObjectStorePut(
int32 idb_object_store_id,
const WebIDBTransaction& transaction,
WebExceptionCode* ec) {
+ ResetCursorPrefetchCaches();
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
IndexedDBHostMsg_ObjectStorePut_Params params;
params.idb_object_store_id = idb_object_store_id;
@@ -322,6 +362,7 @@ void IndexedDBDispatcher::RequestIDBObjectStoreDelete(
int32 idb_object_store_id,
const WebIDBTransaction& transaction,
WebExceptionCode* ec) {
+ ResetCursorPrefetchCaches();
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
int32 response_id = pending_callbacks_.Add(callbacks.release());
@@ -338,6 +379,7 @@ void IndexedDBDispatcher::RequestIDBObjectStoreClear(
int32 idb_object_store_id,
const WebIDBTransaction& transaction,
WebExceptionCode* ec) {
+ ResetCursorPrefetchCaches();
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
int32 response_id = pending_callbacks_.Add(callbacks.release());
@@ -356,6 +398,7 @@ void IndexedDBDispatcher::RequestIDBObjectStoreOpenCursor(
int32 idb_object_store_id,
const WebIDBTransaction& transaction,
WebExceptionCode* ec) {
+ ResetCursorPrefetchCaches();
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
IndexedDBHostMsg_ObjectStoreOpenCursor_Params params;
params.response_id = pending_callbacks_.Add(callbacks.release());
@@ -458,6 +501,21 @@ void IndexedDBDispatcher::OnSuccessCursorContinue(
pending_callbacks_.Remove(response_id);
}
+void IndexedDBDispatcher::OnSuccessCursorPrefetch(
+ int32 response_id,
+ int32 cursor_id,
+ const std::vector<IndexedDBKey>& keys,
+ const std::vector<IndexedDBKey>& primary_keys,
+ const std::vector<content::SerializedScriptValue>& values) {
+ RendererWebIDBCursorImpl* cursor = cursors_[cursor_id];
+ DCHECK(cursor);
+ cursor->SetPrefetchData(keys, primary_keys, values);
+
+ WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
+ cursor->CachedContinue(callbacks);
+ pending_callbacks_.Remove(response_id);
+}
+
void IndexedDBDispatcher::OnBlocked(int32 response_id) {
WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
callbacks->onBlocked();
@@ -493,3 +551,12 @@ void IndexedDBDispatcher::OnVersionChange(int32 database_id,
if (callbacks)
callbacks->onVersionChange(newVersion);
}
+
+void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) {
jsbell 2011/11/28 20:29:16 Should this at least be scoped to database_id? Is
hans 2011/11/29 14:44:34 That would make sense, but it doesn't make any dif
+ typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator;
+ for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) {
+ if (i->first == exception_cursor_id)
+ continue;
+ i->second->ResetPrefetchCache();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698