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

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: Additional key/value/primarykey for the current cursor 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 OnSuccessCursorAdvance)
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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 return; 636 return;
618 637
619 RendererWebIDBCursorImpl* cursor = new RendererWebIDBCursorImpl(object_id); 638 RendererWebIDBCursorImpl* cursor = new RendererWebIDBCursorImpl(object_id);
620 cursors_[object_id] = cursor; 639 cursors_[object_id] = cursor;
621 cursor->SetKeyAndValue(key, primary_key, value); 640 cursor->SetKeyAndValue(key, primary_key, value);
622 callbacks->onSuccess(cursor); 641 callbacks->onSuccess(cursor);
623 642
624 pending_callbacks_.Remove(response_id); 643 pending_callbacks_.Remove(response_id);
625 } 644 }
626 645
646 void IndexedDBDispatcher::OnSuccessCursorAdvance(
647 const IndexedDBMsg_CallbacksSuccessCursorAdvance_Params& p) {
648 DCHECK_EQ(p.thread_id, CurrentWorkerId());
649 int32 response_id = p.response_id;
jsbell 2012/04/24 15:41:08 This method is much simpler than OnSuccessCursorCo
alecflett 2012/04/24 16:34:22 Oops, I removed this as an experiment, and thought
650
651 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
652 if (!callbacks)
653 return;
654 callbacks->onSuccessWithContinuation();
655
656 pending_callbacks_.Remove(response_id);
657 }
658
627 void IndexedDBDispatcher::OnSuccessCursorContinue( 659 void IndexedDBDispatcher::OnSuccessCursorContinue(
628 const IndexedDBMsg_CallbacksSuccessCursorContinue_Params& p) { 660 const IndexedDBMsg_CallbacksSuccessCursorContinue_Params& p) {
629 DCHECK_EQ(p.thread_id, CurrentWorkerId()); 661 DCHECK_EQ(p.thread_id, CurrentWorkerId());
630 int32 response_id = p.response_id; 662 int32 response_id = p.response_id;
631 int32 cursor_id = p.cursor_id; 663 int32 cursor_id = p.cursor_id;
632 const IndexedDBKey& key = p.key; 664 const IndexedDBKey& key = p.key;
633 const IndexedDBKey& primary_key = p.primary_key; 665 const IndexedDBKey& primary_key = p.primary_key;
634 const content::SerializedScriptValue& value = p.serialized_value; 666 const content::SerializedScriptValue& value = p.serialized_value;
635 667
636 RendererWebIDBCursorImpl* cursor = cursors_[cursor_id]; 668 RendererWebIDBCursorImpl* cursor = cursors_[cursor_id];
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 } 746 }
715 747
716 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { 748 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) {
717 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; 749 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator;
718 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { 750 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) {
719 if (i->first == exception_cursor_id) 751 if (i->first == exception_cursor_id)
720 continue; 752 continue;
721 i->second->ResetPrefetchCache(); 753 i->second->ResetPrefetchCache();
722 } 754 }
723 } 755 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698