| Index: content/renderer/indexed_db_dispatcher.cc
|
| diff --git a/content/renderer/indexed_db_dispatcher.cc b/content/renderer/indexed_db_dispatcher.cc
|
| index 915275f7652970871caf3e16b6c8c411ab62bc3b..6c63bbca58b59ffb166a23e48110d5cc73532c5b 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());
|
| @@ -472,6 +515,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();
|
| @@ -514,3 +572,12 @@ void IndexedDBDispatcher::OnVersionChange(int32 database_id,
|
| return;
|
| callbacks->onVersionChange(newVersion);
|
| }
|
| +
|
| +void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) {
|
| + 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();
|
| + }
|
| +}
|
|
|