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

Unified Diff: content/renderer/indexed_db_dispatcher.cc

Issue 8400061: IndexedDB: Recycle cursor objects when calling continue(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: New version Created 9 years, 2 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/renderer/indexed_db_dispatcher.cc
diff --git a/content/renderer/indexed_db_dispatcher.cc b/content/renderer/indexed_db_dispatcher.cc
index c3eea0e949e87aa64a1326f261f215cdc2ec8a60..8eb209922712c2c6982e7138a117a38791ae2468 100644
--- a/content/renderer/indexed_db_dispatcher.cc
+++ b/content/renderer/indexed_db_dispatcher.cc
@@ -42,6 +42,8 @@ bool IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) {
IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcher, msg)
IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBCursor,
OnSuccessOpenCursor)
+ IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorContinue,
+ OnSuccessCursorContinue)
IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBDatabase,
OnSuccessIDBDatabase)
IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIndexedDBKey,
@@ -426,15 +428,35 @@ void IndexedDBDispatcher::OnSuccessSerializedScriptValue(
}
void IndexedDBDispatcher::OnSuccessOpenCursor(int32 repsonse_id,
- int32 object_id, const IndexedDBKey& key, const IndexedDBKey& primaryKey,
+ int32 object_id, const IndexedDBKey& key, const IndexedDBKey& primary_key,
const content::SerializedScriptValue& value) {
WebIDBCallbacks* callbacks =
pending_callbacks_.Lookup(repsonse_id);
- callbacks->onSuccess(new RendererWebIDBCursorImpl(object_id, key,
- primaryKey, value));
+
+ RendererWebIDBCursorImpl* cursor = new RendererWebIDBCursorImpl(object_id);
+ cursors_[object_id] = cursor;
+ cursor->setKeyAndValue(key, primary_key, value);
+ callbacks->onSuccess(cursor);
+
pending_callbacks_.Remove(repsonse_id);
}
+void IndexedDBDispatcher::OnSuccessCursorContinue(
+ int32 response_id,
+ int32 cursor_id,
+ const IndexedDBKey& key,
+ const IndexedDBKey& primary_key,
+ const content::SerializedScriptValue& value) {
+
+ RendererWebIDBCursorImpl* cursor = cursors_[cursor_id];
michaeln 2011/10/31 18:58:25 DCHECK(cursor)
hans 2011/11/01 14:57:45 Done.
+ cursor->setKeyAndValue(key, primary_key, value);
+
+ WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
+ callbacks->onSuccessCursorContinue();
+
+ pending_callbacks_.Remove(response_id);
+}
+
void IndexedDBDispatcher::OnBlocked(int32 response_id) {
WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
callbacks->onBlocked();
@@ -470,3 +492,7 @@ void IndexedDBDispatcher::OnVersionChange(int32 database_id,
if (callbacks)
callbacks->onVersionChange(newVersion);
}
+
+void IndexedDBDispatcher::CursorDestroyed(int32 cursor_id) {
+ cursors_.erase(cursor_id);
+}

Powered by Google App Engine
This is Rietveld 408576698