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

Side by Side Diff: content/common/indexed_db/indexed_db_dispatcher.cc

Issue 10197001: IndexedDB: chromium side of IDBCursor.advance(). (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Reuse the CallbacksSuccessCursorContinue message Created 8 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/common/indexed_db/indexed_db_dispatcher.h" 5 #include "content/common/indexed_db/indexed_db_dispatcher.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/threading/thread_local.h" 8 #include "base/threading/thread_local.h"
9 #include "content/common/child_thread.h" 9 #include "content/common/child_thread.h"
10 #include "content/common/indexed_db/indexed_db_messages.h" 10 #include "content/common/indexed_db/indexed_db_messages.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 void IndexedDBDispatcher::OnWorkerRunLoopStopped() { 74 void IndexedDBDispatcher::OnWorkerRunLoopStopped() {
75 delete this; 75 delete this;
76 } 76 }
77 77
78 void IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) { 78 void IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) {
79 bool handled = true; 79 bool handled = true;
80 IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcher, msg) 80 IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcher, msg)
81 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBCursor, 81 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBCursor,
82 OnSuccessOpenCursor) 82 OnSuccessOpenCursor)
83 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorAdvance,
84 OnSuccessCursorContinue)
83 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorContinue, 85 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorContinue,
84 OnSuccessCursorContinue) 86 OnSuccessCursorContinue)
85 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorPrefetch, 87 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorPrefetch,
86 OnSuccessCursorPrefetch) 88 OnSuccessCursorPrefetch)
87 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBDatabase, 89 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBDatabase,
88 OnSuccessIDBDatabase) 90 OnSuccessIDBDatabase)
89 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIndexedDBKey, 91 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIndexedDBKey,
90 OnSuccessIndexedDBKey) 92 OnSuccessIndexedDBKey)
91 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBTransaction, 93 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBTransaction,
92 OnSuccessIDBTransaction) 94 OnSuccessIDBTransaction)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 return; 131 return;
130 } 132 }
131 int32 response_id = pending_callbacks_.Add(callbacks.release()); 133 int32 response_id = pending_callbacks_.Add(callbacks.release());
132 Send( 134 Send(
133 new IndexedDBHostMsg_CursorUpdate(idb_cursor_id, CurrentWorkerId(), 135 new IndexedDBHostMsg_CursorUpdate(idb_cursor_id, CurrentWorkerId(),
134 response_id, value, ec)); 136 response_id, value, ec));
135 if (*ec) 137 if (*ec)
136 pending_callbacks_.Remove(response_id); 138 pending_callbacks_.Remove(response_id);
137 } 139 }
138 140
141 void IndexedDBDispatcher::RequestIDBCursorAdvance(
142 unsigned long count,
143 WebIDBCallbacks* callbacks_ptr,
144 int32 idb_cursor_id,
145 WebExceptionCode* ec) {
146 // Reset all cursor prefetch caches except for this cursor.
147 ResetCursorPrefetchCaches(idb_cursor_id);
148
149 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
150
151 int32 response_id = pending_callbacks_.Add(callbacks.release());
152 Send(new IndexedDBHostMsg_CursorAdvance(idb_cursor_id, CurrentWorkerId(),
153 response_id, count, ec));
154 if (*ec)
155 pending_callbacks_.Remove(response_id);
156 }
157
139 void IndexedDBDispatcher::RequestIDBCursorContinue( 158 void IndexedDBDispatcher::RequestIDBCursorContinue(
140 const IndexedDBKey& key, 159 const IndexedDBKey& key,
141 WebIDBCallbacks* callbacks_ptr, 160 WebIDBCallbacks* callbacks_ptr,
142 int32 idb_cursor_id, 161 int32 idb_cursor_id,
143 WebExceptionCode* ec) { 162 WebExceptionCode* ec) {
144 // Reset all cursor prefetch caches except for this cursor. 163 // Reset all cursor prefetch caches except for this cursor.
145 ResetCursorPrefetchCaches(idb_cursor_id); 164 ResetCursorPrefetchCaches(idb_cursor_id);
146 165
147 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 166 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
148 167
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 } 733 }
715 734
716 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { 735 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) {
717 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; 736 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator;
718 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { 737 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) {
719 if (i->first == exception_cursor_id) 738 if (i->first == exception_cursor_id)
720 continue; 739 continue;
721 i->second->ResetPrefetchCache(); 740 i->second->ResetPrefetchCache();
722 } 741 }
723 } 742 }
OLDNEW
« no previous file with comments | « content/common/indexed_db/indexed_db_dispatcher.h ('k') | content/common/indexed_db/indexed_db_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698