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

Side by Side Diff: content/renderer/renderer_webidbcursor_impl.cc

Issue 8747002: Dispatch IndexedDB IPC messages to worker threads (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove some includes Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/renderer/renderer_webidbcursor_impl.h" 5 #include "content/renderer/renderer_webidbcursor_impl.h"
6 6
7 #include "content/common/indexed_db_messages.h" 7 #include "content/common/indexed_db_messages.h"
8 #include "content/renderer/indexed_db_dispatcher.h" 8 #include "content/renderer/indexed_db_dispatcher.h"
9 #include "content/renderer/render_thread_impl.h" 9 #include "content/renderer/render_thread_impl.h"
10 10
(...skipping 10 matching lines...) Expand all
21 prefetch_amount_(kMinPrefetchAmount) { 21 prefetch_amount_(kMinPrefetchAmount) {
22 } 22 }
23 23
24 RendererWebIDBCursorImpl::~RendererWebIDBCursorImpl() { 24 RendererWebIDBCursorImpl::~RendererWebIDBCursorImpl() {
25 // It's not possible for there to be pending callbacks that address this 25 // It's not possible for there to be pending callbacks that address this
26 // object since inside WebKit, they hold a reference to the object wich owns 26 // object since inside WebKit, they hold a reference to the object wich owns
27 // this object. But, if that ever changed, then we'd need to invalidate 27 // this object. But, if that ever changed, then we'd need to invalidate
28 // any such pointers. 28 // any such pointers.
29 ChildThread::current()->Send(new IndexedDBHostMsg_CursorDestroyed( 29 ChildThread::current()->Send(new IndexedDBHostMsg_CursorDestroyed(
30 idb_cursor_id_)); 30 idb_cursor_id_));
31 IndexedDBDispatcher* dispatcher = 31 IndexedDBDispatcher* dispatcher = IndexedDBDispatcher::Instance();
32 RenderThreadImpl::current()->indexed_db_dispatcher();
33 dispatcher->CursorDestroyed(idb_cursor_id_); 32 dispatcher->CursorDestroyed(idb_cursor_id_);
34 } 33 }
35 34
36 unsigned short RendererWebIDBCursorImpl::direction() const { 35 unsigned short RendererWebIDBCursorImpl::direction() const {
37 int direction; 36 int direction;
38 ChildThread::current()->Send( 37 ChildThread::current()->Send(
39 new IndexedDBHostMsg_CursorDirection(idb_cursor_id_, &direction)); 38 new IndexedDBHostMsg_CursorDirection(idb_cursor_id_, &direction));
40 return direction; 39 return direction;
41 } 40 }
42 41
43 WebIDBKey RendererWebIDBCursorImpl::key() const { 42 WebIDBKey RendererWebIDBCursorImpl::key() const {
44 return key_; 43 return key_;
45 } 44 }
46 45
47 WebIDBKey RendererWebIDBCursorImpl::primaryKey() const { 46 WebIDBKey RendererWebIDBCursorImpl::primaryKey() const {
48 return primary_key_; 47 return primary_key_;
49 } 48 }
50 49
51 WebSerializedScriptValue RendererWebIDBCursorImpl::value() const { 50 WebSerializedScriptValue RendererWebIDBCursorImpl::value() const {
52 return value_; 51 return value_;
53 } 52 }
54 53
55 void RendererWebIDBCursorImpl::update(const WebSerializedScriptValue& value, 54 void RendererWebIDBCursorImpl::update(const WebSerializedScriptValue& value,
56 WebIDBCallbacks* callbacks, 55 WebIDBCallbacks* callbacks,
57 WebExceptionCode& ec) { 56 WebExceptionCode& ec) {
58 IndexedDBDispatcher* dispatcher = 57 IndexedDBDispatcher* dispatcher = IndexedDBDispatcher::Instance();
59 RenderThreadImpl::current()->indexed_db_dispatcher();
60 dispatcher->RequestIDBCursorUpdate( 58 dispatcher->RequestIDBCursorUpdate(
61 content::SerializedScriptValue(value), callbacks, idb_cursor_id_, &ec); 59 content::SerializedScriptValue(value), callbacks, idb_cursor_id_, &ec);
62 } 60 }
63 61
64 void RendererWebIDBCursorImpl::continueFunction(const WebIDBKey& key, 62 void RendererWebIDBCursorImpl::continueFunction(const WebIDBKey& key,
65 WebIDBCallbacks* callbacks, 63 WebIDBCallbacks* callbacks,
66 WebExceptionCode& ec) { 64 WebExceptionCode& ec) {
67 IndexedDBDispatcher* dispatcher = 65 IndexedDBDispatcher* dispatcher = IndexedDBDispatcher::Instance();
68 RenderThreadImpl::current()->indexed_db_dispatcher();
69 66
70 if (key.type() == WebIDBKey::InvalidType) { 67 if (key.type() == WebIDBKey::InvalidType) {
71 // No key, so this would qualify for a prefetch. 68 // No key, so this would qualify for a prefetch.
72 ++continue_count_; 69 ++continue_count_;
73 70
74 if (!prefetch_keys_.empty()) { 71 if (!prefetch_keys_.empty()) {
75 // We have a prefetch cache, so serve the result from that. 72 // We have a prefetch cache, so serve the result from that.
76 CachedContinue(callbacks); 73 CachedContinue(callbacks);
77 return; 74 return;
78 } 75 }
(...skipping 14 matching lines...) Expand all
93 // Key argument supplied. We couldn't prefetch this. 90 // Key argument supplied. We couldn't prefetch this.
94 ResetPrefetchCache(); 91 ResetPrefetchCache();
95 } 92 }
96 93
97 dispatcher->RequestIDBCursorContinue(IndexedDBKey(key), callbacks, 94 dispatcher->RequestIDBCursorContinue(IndexedDBKey(key), callbacks,
98 idb_cursor_id_, &ec); 95 idb_cursor_id_, &ec);
99 } 96 }
100 97
101 void RendererWebIDBCursorImpl::deleteFunction(WebIDBCallbacks* callbacks, 98 void RendererWebIDBCursorImpl::deleteFunction(WebIDBCallbacks* callbacks,
102 WebExceptionCode& ec) { 99 WebExceptionCode& ec) {
103 IndexedDBDispatcher* dispatcher = 100 IndexedDBDispatcher* dispatcher = IndexedDBDispatcher::Instance();
104 RenderThreadImpl::current()->indexed_db_dispatcher();
105 dispatcher->RequestIDBCursorDelete(callbacks, idb_cursor_id_, &ec); 101 dispatcher->RequestIDBCursorDelete(callbacks, idb_cursor_id_, &ec);
106 } 102 }
107 103
108 void RendererWebIDBCursorImpl::postSuccessHandlerCallback() 104 void RendererWebIDBCursorImpl::postSuccessHandlerCallback()
109 { 105 {
110 pending_onsuccess_callbacks_--; 106 pending_onsuccess_callbacks_--;
111 107
112 // If the onsuccess callback called continue() on the cursor again, 108 // If the onsuccess callback called continue() on the cursor again,
113 // and that continue was served by the prefetch cache, then 109 // and that continue was served by the prefetch cache, then
114 // pending_onsuccess_callbacks_ would be incremented. 110 // pending_onsuccess_callbacks_ would be incremented.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 157
162 void RendererWebIDBCursorImpl::ResetPrefetchCache() { 158 void RendererWebIDBCursorImpl::ResetPrefetchCache() {
163 continue_count_ = 0; 159 continue_count_ = 0;
164 prefetch_amount_ = kMinPrefetchAmount; 160 prefetch_amount_ = kMinPrefetchAmount;
165 161
166 if (!prefetch_keys_.size()) { 162 if (!prefetch_keys_.size()) {
167 // No prefetch cache, so no need to reset the cursor in the back-end. 163 // No prefetch cache, so no need to reset the cursor in the back-end.
168 return; 164 return;
169 } 165 }
170 166
171 IndexedDBDispatcher* dispatcher = 167 IndexedDBDispatcher* dispatcher = IndexedDBDispatcher::Instance();
172 RenderThreadImpl::current()->indexed_db_dispatcher();
173 dispatcher->RequestIDBCursorPrefetchReset(used_prefetches_, 168 dispatcher->RequestIDBCursorPrefetchReset(used_prefetches_,
174 prefetch_keys_.size(), 169 prefetch_keys_.size(),
175 idb_cursor_id_); 170 idb_cursor_id_);
176 prefetch_keys_.clear(); 171 prefetch_keys_.clear();
177 prefetch_primary_keys_.clear(); 172 prefetch_primary_keys_.clear();
178 prefetch_values_.clear(); 173 prefetch_values_.clear();
179 174
180 pending_onsuccess_callbacks_ = 0; 175 pending_onsuccess_callbacks_ = 0;
181 } 176 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698