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

Side by Side Diff: content/renderer/indexed_db_dispatcher.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/indexed_db_dispatcher.h" 5 #include "content/renderer/indexed_db_dispatcher.h"
6 6
7 #include "content/common/indexed_db_messages.h" 7 #include "content/common/indexed_db_messages.h"
8 #include "content/renderer/render_thread_impl.h" 8 #include "content/renderer/render_thread_impl.h"
9 #include "content/renderer/render_view_impl.h" 9 #include "content/renderer/render_view_impl.h"
10 #include "content/renderer/renderer_webidbcursor_impl.h" 10 #include "content/renderer/renderer_webidbcursor_impl.h"
11 #include "content/renderer/renderer_webidbdatabase_impl.h" 11 #include "content/renderer/renderer_webidbdatabase_impl.h"
12 #include "content/renderer/renderer_webidbindex_impl.h" 12 #include "content/renderer/renderer_webidbindex_impl.h"
13 #include "content/renderer/renderer_webidbobjectstore_impl.h" 13 #include "content/renderer/renderer_webidbobjectstore_impl.h"
14 #include "content/renderer/renderer_webidbtransaction_impl.h" 14 #include "content/renderer/renderer_webidbtransaction_impl.h"
15 #include "ipc/ipc_channel.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseCallbac ks.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseCallbac ks.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseError.h " 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseError.h "
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyRange.h" 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyRange.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
20 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerialize dScriptValue.h"
21 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
22 20
23 using WebKit::WebDOMStringList; 21 using WebKit::WebDOMStringList;
24 using WebKit::WebExceptionCode; 22 using WebKit::WebExceptionCode;
25 using WebKit::WebFrame; 23 using WebKit::WebFrame;
26 using WebKit::WebIDBCallbacks; 24 using WebKit::WebIDBCallbacks;
27 using WebKit::WebIDBKeyRange; 25 using WebKit::WebIDBKeyRange;
28 using WebKit::WebIDBDatabase; 26 using WebKit::WebIDBDatabase;
29 using WebKit::WebIDBDatabaseCallbacks; 27 using WebKit::WebIDBDatabaseCallbacks;
30 using WebKit::WebIDBDatabaseError; 28 using WebKit::WebIDBDatabaseError;
31 using WebKit::WebIDBTransaction; 29 using WebKit::WebIDBTransaction;
32 using WebKit::WebIDBTransactionCallbacks; 30 using WebKit::WebIDBTransactionCallbacks;
31 using webkit_glue::WorkerTaskRunner;
32
33 base::ThreadLocalPointer<IndexedDBDispatcher>*
michaeln 2011/12/14 02:15:53 our convention is to use LazyInstance<> for things
dgrogan 2011/12/15 02:47:44 Done.
34 IndexedDBDispatcher::idb_dispatcher_tls_;
35
36 namespace {
37
38 int32 CurrentWorkerId() {
39 return WorkerTaskRunner::Instance()->CurrentWorkerId();
40 }
41
42 } // unnamed namespace
33 43
34 IndexedDBDispatcher::IndexedDBDispatcher() { 44 IndexedDBDispatcher::IndexedDBDispatcher() {
35 } 45 }
36 46
37 IndexedDBDispatcher::~IndexedDBDispatcher() { 47 IndexedDBDispatcher::~IndexedDBDispatcher() {
38 } 48 }
39 49
40 bool IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) { 50 void IndexedDBDispatcher::Init() {
51 idb_dispatcher_tls_ = new base::ThreadLocalPointer<IndexedDBDispatcher>;
52 }
53
54 IndexedDBDispatcher* IndexedDBDispatcher::Instance() {
55 DCHECK(idb_dispatcher_tls_) << "Call IndexedDBDispatcher::Init on the main "
56 << "thread before calling "
57 << "IndexedDBDispatcher::Instance";
58 if (idb_dispatcher_tls_->Get())
59 return idb_dispatcher_tls_->Get();
60
61 IndexedDBDispatcher* dispatcher = new IndexedDBDispatcher;
62 idb_dispatcher_tls_->Set(dispatcher);
63 if (WorkerTaskRunner::Instance()->CurrentWorkerId())
64 webkit_glue::WorkerTaskRunner::Instance()->AddStopObserver(dispatcher);
65 return dispatcher;
66 }
67
68 void IndexedDBDispatcher::OnWorkerRunLoopStopped() {
69 idb_dispatcher_tls_->Set(NULL);
70 delete this;
71 }
72
73 void IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) {
41 bool handled = true; 74 bool handled = true;
42 IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcher, msg) 75 IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcher, msg)
43 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBCursor, 76 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBCursor,
44 OnSuccessOpenCursor) 77 OnSuccessOpenCursor)
45 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorContinue, 78 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorContinue,
46 OnSuccessCursorContinue) 79 OnSuccessCursorContinue)
47 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorPrefetch, 80 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorPrefetch,
48 OnSuccessCursorPrefetch) 81 OnSuccessCursorPrefetch)
49 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBDatabase, 82 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBDatabase,
50 OnSuccessIDBDatabase) 83 OnSuccessIDBDatabase)
51 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIndexedDBKey, 84 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIndexedDBKey,
52 OnSuccessIndexedDBKey) 85 OnSuccessIndexedDBKey)
53 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBTransaction, 86 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBTransaction,
54 OnSuccessIDBTransaction) 87 OnSuccessIDBTransaction)
55 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessStringList, 88 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessStringList,
56 OnSuccessStringList) 89 OnSuccessStringList)
57 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessSerializedScriptValue, 90 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessSerializedScriptValue,
58 OnSuccessSerializedScriptValue) 91 OnSuccessSerializedScriptValue)
59 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksError, OnError) 92 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksError, OnError)
60 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksBlocked, OnBlocked) 93 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksBlocked, OnBlocked)
61 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksAbort, OnAbort) 94 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksAbort, OnAbort)
62 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksComplete, OnComplete) 95 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksComplete, OnComplete)
63 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksVersionChange, 96 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksVersionChange,
64 OnVersionChange) 97 OnVersionChange)
65 IPC_MESSAGE_UNHANDLED(handled = false) 98 IPC_MESSAGE_UNHANDLED(handled = false)
66 IPC_END_MESSAGE_MAP() 99 IPC_END_MESSAGE_MAP()
67 return handled; 100 // If a message gets here, IndexedDBMessageFilter already determined that it
101 // is an IndexedDB message.
102 DCHECK(handled);
68 } 103 }
69 104
70 void IndexedDBDispatcher::Send(IPC::Message* msg) { 105 void IndexedDBDispatcher::Send(IPC::Message* msg) {
71 ChildThread::current()->Send(msg); 106 ChildThread::current()->Send(msg);
72 } 107 }
73 108
74 void IndexedDBDispatcher::RequestIDBCursorUpdate( 109 void IndexedDBDispatcher::RequestIDBCursorUpdate(
75 const content::SerializedScriptValue& value, 110 const content::SerializedScriptValue& value,
76 WebIDBCallbacks* callbacks_ptr, 111 WebIDBCallbacks* callbacks_ptr,
77 int32 idb_cursor_id, 112 int32 idb_cursor_id,
78 WebExceptionCode* ec) { 113 WebExceptionCode* ec) {
79 ResetCursorPrefetchCaches(); 114 ResetCursorPrefetchCaches();
80 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 115 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
81 116
117 int32 thread_id = WorkerTaskRunner::Instance()->CurrentWorkerId();
82 int32 response_id = pending_callbacks_.Add(callbacks.release()); 118 int32 response_id = pending_callbacks_.Add(callbacks.release());
83 Send( 119 Send(
84 new IndexedDBHostMsg_CursorUpdate(idb_cursor_id, response_id, value, ec)); 120 new IndexedDBHostMsg_CursorUpdate(idb_cursor_id, thread_id, response_id,
michaeln 2011/12/14 02:15:53 maybe call your CurrentWorkerId() helper here as w
dgrogan 2011/12/15 02:47:44 Done.
121 value, ec));
85 if (*ec) 122 if (*ec)
86 pending_callbacks_.Remove(response_id); 123 pending_callbacks_.Remove(response_id);
87 } 124 }
88 125
89 void IndexedDBDispatcher::RequestIDBCursorContinue( 126 void IndexedDBDispatcher::RequestIDBCursorContinue(
90 const IndexedDBKey& key, 127 const IndexedDBKey& key,
91 WebIDBCallbacks* callbacks_ptr, 128 WebIDBCallbacks* callbacks_ptr,
92 int32 idb_cursor_id, 129 int32 idb_cursor_id,
93 WebExceptionCode* ec) { 130 WebExceptionCode* ec) {
94 // Reset all cursor prefetch caches except for this cursor. 131 // Reset all cursor prefetch caches except for this cursor.
95 ResetCursorPrefetchCaches(idb_cursor_id); 132 ResetCursorPrefetchCaches(idb_cursor_id);
96 133
97 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 134 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
98 135
99 int32 response_id = pending_callbacks_.Add(callbacks.release()); 136 int32 response_id = pending_callbacks_.Add(callbacks.release());
100 Send( 137 Send(
101 new IndexedDBHostMsg_CursorContinue(idb_cursor_id, response_id, key, ec)); 138 new IndexedDBHostMsg_CursorContinue(idb_cursor_id, CurrentWorkerId(),
139 response_id, key, ec));
102 if (*ec) 140 if (*ec)
103 pending_callbacks_.Remove(response_id); 141 pending_callbacks_.Remove(response_id);
104 } 142 }
105 143
106 void IndexedDBDispatcher::RequestIDBCursorPrefetch( 144 void IndexedDBDispatcher::RequestIDBCursorPrefetch(
107 int n, 145 int n,
108 WebIDBCallbacks* callbacks_ptr, 146 WebIDBCallbacks* callbacks_ptr,
109 int32 idb_cursor_id, 147 int32 idb_cursor_id,
110 WebExceptionCode* ec) { 148 WebExceptionCode* ec) {
111 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 149 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
112 150
113 int32 response_id = pending_callbacks_.Add(callbacks.release()); 151 int32 response_id = pending_callbacks_.Add(callbacks.release());
114 RenderThreadImpl::current()->Send( 152 Send(new IndexedDBHostMsg_CursorPrefetch(idb_cursor_id, CurrentWorkerId(),
115 new IndexedDBHostMsg_CursorPrefetch(idb_cursor_id, response_id, n, ec)); 153 response_id, n, ec));
116 if (*ec) 154 if (*ec)
117 pending_callbacks_.Remove(response_id); 155 pending_callbacks_.Remove(response_id);
118 } 156 }
119 157
120 void IndexedDBDispatcher::RequestIDBCursorPrefetchReset( 158 void IndexedDBDispatcher::RequestIDBCursorPrefetchReset(
121 int used_prefetches, int unused_prefetches, int32 idb_cursor_id) { 159 int used_prefetches, int unused_prefetches, int32 idb_cursor_id) {
122 RenderThreadImpl::current()->Send( 160 Send(new IndexedDBHostMsg_CursorPrefetchReset(idb_cursor_id,
123 new IndexedDBHostMsg_CursorPrefetchReset(idb_cursor_id, used_prefetches, 161 used_prefetches,
124 unused_prefetches)); 162 unused_prefetches));
125 } 163 }
126 164
127 void IndexedDBDispatcher::RequestIDBCursorDelete( 165 void IndexedDBDispatcher::RequestIDBCursorDelete(
128 WebIDBCallbacks* callbacks_ptr, 166 WebIDBCallbacks* callbacks_ptr,
129 int32 idb_cursor_id, 167 int32 idb_cursor_id,
130 WebExceptionCode* ec) { 168 WebExceptionCode* ec) {
131 ResetCursorPrefetchCaches(); 169 ResetCursorPrefetchCaches();
132 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 170 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
133 171
134 int32 response_id = pending_callbacks_.Add(callbacks.release()); 172 int32 response_id = pending_callbacks_.Add(callbacks.release());
135 Send(new IndexedDBHostMsg_CursorDelete(idb_cursor_id, response_id, ec)); 173 Send(new IndexedDBHostMsg_CursorDelete(idb_cursor_id, CurrentWorkerId(),
174 response_id, ec));
136 if (*ec) 175 if (*ec)
137 pending_callbacks_.Remove(response_id); 176 pending_callbacks_.Remove(response_id);
138 } 177 }
139 178
140 void IndexedDBDispatcher::RequestIDBFactoryOpen( 179 void IndexedDBDispatcher::RequestIDBFactoryOpen(
141 const string16& name, 180 const string16& name,
142 WebIDBCallbacks* callbacks_ptr, 181 WebIDBCallbacks* callbacks_ptr,
143 const string16& origin, 182 const string16& origin,
144 WebFrame* web_frame) { 183 WebFrame* web_frame) {
145 ResetCursorPrefetchCaches(); 184 ResetCursorPrefetchCaches();
146 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 185 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
147 186
148 if (!web_frame) 187 if (!web_frame)
149 return; // We must be shutting down. 188 return; // We must be shutting down.
150 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); 189 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view());
151 if (!render_view) 190 if (!render_view)
152 return; // We must be shutting down. 191 return; // We must be shutting down.
153 192
154 IndexedDBHostMsg_FactoryOpen_Params params; 193 IndexedDBHostMsg_FactoryOpen_Params params;
194 params.thread_id = CurrentWorkerId();
155 params.response_id = pending_callbacks_.Add(callbacks.release()); 195 params.response_id = pending_callbacks_.Add(callbacks.release());
156 params.origin = origin; 196 params.origin = origin;
157 params.name = name; 197 params.name = name;
158 Send(new IndexedDBHostMsg_FactoryOpen(params)); 198 Send(new IndexedDBHostMsg_FactoryOpen(params));
159 } 199 }
160 200
161 void IndexedDBDispatcher::RequestIDBFactoryGetDatabaseNames( 201 void IndexedDBDispatcher::RequestIDBFactoryGetDatabaseNames(
162 WebIDBCallbacks* callbacks_ptr, 202 WebIDBCallbacks* callbacks_ptr,
163 const string16& origin, 203 const string16& origin,
164 WebFrame* web_frame) { 204 WebFrame* web_frame) {
165 ResetCursorPrefetchCaches(); 205 ResetCursorPrefetchCaches();
166 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 206 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
167 207
168 if (!web_frame) 208 if (!web_frame)
169 return; // We must be shutting down. 209 return; // We must be shutting down.
170 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); 210 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view());
171 if (!render_view) 211 if (!render_view)
172 return; // We must be shutting down. 212 return; // We must be shutting down.
173 213
174 IndexedDBHostMsg_FactoryGetDatabaseNames_Params params; 214 IndexedDBHostMsg_FactoryGetDatabaseNames_Params params;
215 params.thread_id = CurrentWorkerId();
175 params.response_id = pending_callbacks_.Add(callbacks.release()); 216 params.response_id = pending_callbacks_.Add(callbacks.release());
176 params.origin = origin; 217 params.origin = origin;
177 Send(new IndexedDBHostMsg_FactoryGetDatabaseNames(params)); 218 Send(new IndexedDBHostMsg_FactoryGetDatabaseNames(params));
178 } 219 }
179 220
180 void IndexedDBDispatcher::RequestIDBFactoryDeleteDatabase( 221 void IndexedDBDispatcher::RequestIDBFactoryDeleteDatabase(
181 const string16& name, 222 const string16& name,
182 WebIDBCallbacks* callbacks_ptr, 223 WebIDBCallbacks* callbacks_ptr,
183 const string16& origin, 224 const string16& origin,
184 WebFrame* web_frame) { 225 WebFrame* web_frame) {
185 ResetCursorPrefetchCaches(); 226 ResetCursorPrefetchCaches();
186 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 227 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
187 228
188 if (!web_frame) 229 if (!web_frame)
189 return; // We must be shutting down. 230 return; // We must be shutting down.
190 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); 231 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view());
191 if (!render_view) 232 if (!render_view)
192 return; // We must be shutting down. 233 return; // We must be shutting down.
193 234
194 IndexedDBHostMsg_FactoryDeleteDatabase_Params params; 235 IndexedDBHostMsg_FactoryDeleteDatabase_Params params;
236 params.thread_id = CurrentWorkerId();
195 params.response_id = pending_callbacks_.Add(callbacks.release()); 237 params.response_id = pending_callbacks_.Add(callbacks.release());
196 params.origin = origin; 238 params.origin = origin;
197 params.name = name; 239 params.name = name;
198 Send(new IndexedDBHostMsg_FactoryDeleteDatabase(params)); 240 Send(new IndexedDBHostMsg_FactoryDeleteDatabase(params));
199 } 241 }
200 242
201 void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) { 243 void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) {
202 ResetCursorPrefetchCaches(); 244 ResetCursorPrefetchCaches();
203 Send(new IndexedDBHostMsg_DatabaseClose(idb_database_id)); 245 Send(new IndexedDBHostMsg_DatabaseClose(idb_database_id));
204 pending_database_callbacks_.Remove(idb_database_id); 246 pending_database_callbacks_.Remove(idb_database_id);
205 } 247 }
206 248
207 void IndexedDBDispatcher::RequestIDBDatabaseOpen( 249 void IndexedDBDispatcher::RequestIDBDatabaseOpen(
208 WebIDBDatabaseCallbacks* callbacks_ptr, 250 WebIDBDatabaseCallbacks* callbacks_ptr,
209 int32 idb_database_id) { 251 int32 idb_database_id) {
210 ResetCursorPrefetchCaches(); 252 ResetCursorPrefetchCaches();
211 scoped_ptr<WebIDBDatabaseCallbacks> callbacks(callbacks_ptr); 253 scoped_ptr<WebIDBDatabaseCallbacks> callbacks(callbacks_ptr);
212 254
213 int32 response_id = pending_database_callbacks_.Add(callbacks.release()); 255 DCHECK(!pending_database_callbacks_.Lookup(idb_database_id));
214 Send(new IndexedDBHostMsg_DatabaseOpen(response_id, idb_database_id)); 256 pending_database_callbacks_.AddWithID(callbacks.release(), idb_database_id);
257 Send(new IndexedDBHostMsg_DatabaseOpen(idb_database_id, CurrentWorkerId(),
258 idb_database_id));
215 } 259 }
216 260
217 void IndexedDBDispatcher::RequestIDBDatabaseSetVersion( 261 void IndexedDBDispatcher::RequestIDBDatabaseSetVersion(
218 const string16& version, 262 const string16& version,
219 WebIDBCallbacks* callbacks_ptr, 263 WebIDBCallbacks* callbacks_ptr,
220 int32 idb_database_id, 264 int32 idb_database_id,
221 WebExceptionCode* ec) { 265 WebExceptionCode* ec) {
222 ResetCursorPrefetchCaches(); 266 ResetCursorPrefetchCaches();
223 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 267 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
224 268
225 int32 response_id = pending_callbacks_.Add(callbacks.release()); 269 int32 response_id = pending_callbacks_.Add(callbacks.release());
226 Send(new IndexedDBHostMsg_DatabaseSetVersion(idb_database_id, response_id, 270 Send(new IndexedDBHostMsg_DatabaseSetVersion(idb_database_id,
227 version, ec)); 271 CurrentWorkerId(),
272 response_id, version, ec));
228 if (*ec) 273 if (*ec)
229 pending_callbacks_.Remove(response_id); 274 pending_callbacks_.Remove(response_id);
230 } 275 }
231 276
232 void IndexedDBDispatcher::RequestIDBIndexOpenObjectCursor( 277 void IndexedDBDispatcher::RequestIDBIndexOpenObjectCursor(
233 const WebIDBKeyRange& idb_key_range, 278 const WebIDBKeyRange& idb_key_range,
234 unsigned short direction, 279 unsigned short direction,
235 WebIDBCallbacks* callbacks_ptr, 280 WebIDBCallbacks* callbacks_ptr,
236 int32 idb_index_id, 281 int32 idb_index_id,
237 const WebIDBTransaction& transaction, 282 const WebIDBTransaction& transaction,
238 WebExceptionCode* ec) { 283 WebExceptionCode* ec) {
239 ResetCursorPrefetchCaches(); 284 ResetCursorPrefetchCaches();
240 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 285 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
241 IndexedDBHostMsg_IndexOpenCursor_Params params; 286 IndexedDBHostMsg_IndexOpenCursor_Params params;
287 params.thread_id = CurrentWorkerId();
242 params.response_id = pending_callbacks_.Add(callbacks.release()); 288 params.response_id = pending_callbacks_.Add(callbacks.release());
243 params.lower_key.Set(idb_key_range.lower()); 289 params.lower_key.Set(idb_key_range.lower());
244 params.upper_key.Set(idb_key_range.upper()); 290 params.upper_key.Set(idb_key_range.upper());
245 params.lower_open = idb_key_range.lowerOpen(); 291 params.lower_open = idb_key_range.lowerOpen();
246 params.upper_open = idb_key_range.upperOpen(); 292 params.upper_open = idb_key_range.upperOpen();
247 params.direction = direction; 293 params.direction = direction;
248 params.idb_index_id = idb_index_id; 294 params.idb_index_id = idb_index_id;
249 params.transaction_id = TransactionId(transaction); 295 params.transaction_id = TransactionId(transaction);
250 Send(new IndexedDBHostMsg_IndexOpenObjectCursor(params, ec)); 296 Send(new IndexedDBHostMsg_IndexOpenObjectCursor(params, ec));
251 if (*ec) 297 if (*ec)
252 pending_callbacks_.Remove(params.response_id); 298 pending_callbacks_.Remove(params.response_id);
253 } 299 }
254 300
255 void IndexedDBDispatcher::RequestIDBIndexOpenKeyCursor( 301 void IndexedDBDispatcher::RequestIDBIndexOpenKeyCursor(
256 const WebIDBKeyRange& idb_key_range, 302 const WebIDBKeyRange& idb_key_range,
257 unsigned short direction, 303 unsigned short direction,
258 WebIDBCallbacks* callbacks_ptr, 304 WebIDBCallbacks* callbacks_ptr,
259 int32 idb_index_id, 305 int32 idb_index_id,
260 const WebIDBTransaction& transaction, 306 const WebIDBTransaction& transaction,
261 WebExceptionCode* ec) { 307 WebExceptionCode* ec) {
262 ResetCursorPrefetchCaches(); 308 ResetCursorPrefetchCaches();
263 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 309 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
264 IndexedDBHostMsg_IndexOpenCursor_Params params; 310 IndexedDBHostMsg_IndexOpenCursor_Params params;
311 params.thread_id = CurrentWorkerId();
265 params.response_id = pending_callbacks_.Add(callbacks.release()); 312 params.response_id = pending_callbacks_.Add(callbacks.release());
266 // TODO(jorlow): We really should just create a Chromium abstraction for 313 // TODO(jorlow): We really should just create a Chromium abstraction for
267 // KeyRange rather than doing it ad-hoc like this. 314 // KeyRange rather than doing it ad-hoc like this.
268 params.lower_key.Set(idb_key_range.lower()); 315 params.lower_key.Set(idb_key_range.lower());
269 params.upper_key.Set(idb_key_range.upper()); 316 params.upper_key.Set(idb_key_range.upper());
270 params.lower_open = idb_key_range.lowerOpen(); 317 params.lower_open = idb_key_range.lowerOpen();
271 params.upper_open = idb_key_range.upperOpen(); 318 params.upper_open = idb_key_range.upperOpen();
272 params.direction = direction; 319 params.direction = direction;
273 params.idb_index_id = idb_index_id; 320 params.idb_index_id = idb_index_id;
274 params.transaction_id = TransactionId(transaction); 321 params.transaction_id = TransactionId(transaction);
275 Send(new IndexedDBHostMsg_IndexOpenKeyCursor(params, ec)); 322 Send(new IndexedDBHostMsg_IndexOpenKeyCursor(params, ec));
276 if (*ec) 323 if (*ec)
277 pending_callbacks_.Remove(params.response_id); 324 pending_callbacks_.Remove(params.response_id);
278 } 325 }
279 326
280 void IndexedDBDispatcher::RequestIDBIndexGetObject( 327 void IndexedDBDispatcher::RequestIDBIndexGetObject(
281 const IndexedDBKey& key, 328 const IndexedDBKey& key,
282 WebIDBCallbacks* callbacks_ptr, 329 WebIDBCallbacks* callbacks_ptr,
283 int32 idb_index_id, 330 int32 idb_index_id,
284 const WebIDBTransaction& transaction, 331 const WebIDBTransaction& transaction,
285 WebExceptionCode* ec) { 332 WebExceptionCode* ec) {
286 ResetCursorPrefetchCaches(); 333 ResetCursorPrefetchCaches();
287 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 334 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
288 int32 response_id = pending_callbacks_.Add(callbacks.release()); 335 int32 response_id = pending_callbacks_.Add(callbacks.release());
289 Send(new IndexedDBHostMsg_IndexGetObject(idb_index_id, response_id, key, 336 Send(new IndexedDBHostMsg_IndexGetObject(idb_index_id, CurrentWorkerId(),
337 response_id, key,
290 TransactionId(transaction), ec)); 338 TransactionId(transaction), ec));
291 if (*ec) 339 if (*ec)
292 pending_callbacks_.Remove(response_id); 340 pending_callbacks_.Remove(response_id);
293 } 341 }
294 342
295 void IndexedDBDispatcher::RequestIDBIndexGetKey( 343 void IndexedDBDispatcher::RequestIDBIndexGetKey(
296 const IndexedDBKey& key, 344 const IndexedDBKey& key,
297 WebIDBCallbacks* callbacks_ptr, 345 WebIDBCallbacks* callbacks_ptr,
298 int32 idb_index_id, 346 int32 idb_index_id,
299 const WebIDBTransaction& transaction, 347 const WebIDBTransaction& transaction,
300 WebExceptionCode* ec) { 348 WebExceptionCode* ec) {
301 ResetCursorPrefetchCaches(); 349 ResetCursorPrefetchCaches();
302 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 350 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
303 int32 response_id = pending_callbacks_.Add(callbacks.release()); 351 int32 response_id = pending_callbacks_.Add(callbacks.release());
304 Send(new IndexedDBHostMsg_IndexGetKey( 352 Send(new IndexedDBHostMsg_IndexGetKey(
305 idb_index_id, response_id, key, 353 idb_index_id, CurrentWorkerId(), response_id, key,
306 TransactionId(transaction), ec)); 354 TransactionId(transaction), ec));
307 if (*ec) 355 if (*ec)
308 pending_callbacks_.Remove(response_id); 356 pending_callbacks_.Remove(response_id);
309 } 357 }
310 358
311 void IndexedDBDispatcher::RequestIDBObjectStoreGet( 359 void IndexedDBDispatcher::RequestIDBObjectStoreGet(
312 const IndexedDBKey& key, 360 const IndexedDBKey& key,
313 WebIDBCallbacks* callbacks_ptr, 361 WebIDBCallbacks* callbacks_ptr,
314 int32 idb_object_store_id, 362 int32 idb_object_store_id,
315 const WebIDBTransaction& transaction, 363 const WebIDBTransaction& transaction,
316 WebExceptionCode* ec) { 364 WebExceptionCode* ec) {
317 ResetCursorPrefetchCaches(); 365 ResetCursorPrefetchCaches();
318 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 366 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
319 367
320 int32 response_id = pending_callbacks_.Add(callbacks.release()); 368 int32 response_id = pending_callbacks_.Add(callbacks.release());
321 Send(new IndexedDBHostMsg_ObjectStoreGet( 369 Send(new IndexedDBHostMsg_ObjectStoreGet(
322 idb_object_store_id, response_id, 370 idb_object_store_id, CurrentWorkerId(), response_id,
323 key, TransactionId(transaction), ec)); 371 key, TransactionId(transaction), ec));
324 if (*ec) 372 if (*ec)
325 pending_callbacks_.Remove(response_id); 373 pending_callbacks_.Remove(response_id);
326 } 374 }
327 375
328 void IndexedDBDispatcher::RequestIDBObjectStorePut( 376 void IndexedDBDispatcher::RequestIDBObjectStorePut(
329 const content::SerializedScriptValue& value, 377 const content::SerializedScriptValue& value,
330 const IndexedDBKey& key, 378 const IndexedDBKey& key,
331 WebKit::WebIDBObjectStore::PutMode put_mode, 379 WebKit::WebIDBObjectStore::PutMode put_mode,
332 WebIDBCallbacks* callbacks_ptr, 380 WebIDBCallbacks* callbacks_ptr,
333 int32 idb_object_store_id, 381 int32 idb_object_store_id,
334 const WebIDBTransaction& transaction, 382 const WebIDBTransaction& transaction,
335 WebExceptionCode* ec) { 383 WebExceptionCode* ec) {
336 ResetCursorPrefetchCaches(); 384 ResetCursorPrefetchCaches();
337 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 385 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
338 IndexedDBHostMsg_ObjectStorePut_Params params; 386 IndexedDBHostMsg_ObjectStorePut_Params params;
387 params.thread_id = CurrentWorkerId();
339 params.idb_object_store_id = idb_object_store_id; 388 params.idb_object_store_id = idb_object_store_id;
340 params.response_id = pending_callbacks_.Add(callbacks.release()); 389 params.response_id = pending_callbacks_.Add(callbacks.release());
341 params.serialized_value = value; 390 params.serialized_value = value;
342 params.key = key; 391 params.key = key;
343 params.put_mode = put_mode; 392 params.put_mode = put_mode;
344 params.transaction_id = TransactionId(transaction); 393 params.transaction_id = TransactionId(transaction);
345 Send(new IndexedDBHostMsg_ObjectStorePut(params, ec)); 394 Send(new IndexedDBHostMsg_ObjectStorePut(params, ec));
346 if (*ec) 395 if (*ec)
347 pending_callbacks_.Remove(params.response_id); 396 pending_callbacks_.Remove(params.response_id);
348 } 397 }
349 398
350 void IndexedDBDispatcher::RequestIDBObjectStoreDelete( 399 void IndexedDBDispatcher::RequestIDBObjectStoreDelete(
351 const IndexedDBKey& key, 400 const IndexedDBKey& key,
352 WebIDBCallbacks* callbacks_ptr, 401 WebIDBCallbacks* callbacks_ptr,
353 int32 idb_object_store_id, 402 int32 idb_object_store_id,
354 const WebIDBTransaction& transaction, 403 const WebIDBTransaction& transaction,
355 WebExceptionCode* ec) { 404 WebExceptionCode* ec) {
356 ResetCursorPrefetchCaches(); 405 ResetCursorPrefetchCaches();
357 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 406 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
358 407
359 int32 response_id = pending_callbacks_.Add(callbacks.release()); 408 int32 response_id = pending_callbacks_.Add(callbacks.release());
360 Send(new IndexedDBHostMsg_ObjectStoreDelete( 409 Send(new IndexedDBHostMsg_ObjectStoreDelete(
361 idb_object_store_id, response_id, key, TransactionId(transaction), ec)); 410 idb_object_store_id, CurrentWorkerId(), response_id, key,
411 TransactionId(transaction), ec));
362 if (*ec) 412 if (*ec)
363 pending_callbacks_.Remove(response_id); 413 pending_callbacks_.Remove(response_id);
364 } 414 }
365 415
366 void IndexedDBDispatcher::RequestIDBObjectStoreClear( 416 void IndexedDBDispatcher::RequestIDBObjectStoreClear(
367 WebIDBCallbacks* callbacks_ptr, 417 WebIDBCallbacks* callbacks_ptr,
368 int32 idb_object_store_id, 418 int32 idb_object_store_id,
369 const WebIDBTransaction& transaction, 419 const WebIDBTransaction& transaction,
370 WebExceptionCode* ec) { 420 WebExceptionCode* ec) {
371 ResetCursorPrefetchCaches(); 421 ResetCursorPrefetchCaches();
372 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 422 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
373 423
374 int32 response_id = pending_callbacks_.Add(callbacks.release()); 424 int32 response_id = pending_callbacks_.Add(callbacks.release());
375 Send(new IndexedDBHostMsg_ObjectStoreClear( 425 Send(new IndexedDBHostMsg_ObjectStoreClear(
376 idb_object_store_id, response_id, TransactionId(transaction), ec)); 426 idb_object_store_id, CurrentWorkerId(), response_id,
427 TransactionId(transaction), ec));
377 if (*ec) 428 if (*ec)
378 pending_callbacks_.Remove(response_id); 429 pending_callbacks_.Remove(response_id);
379 } 430 }
380 431
381 void IndexedDBDispatcher::RequestIDBObjectStoreOpenCursor( 432 void IndexedDBDispatcher::RequestIDBObjectStoreOpenCursor(
382 const WebIDBKeyRange& idb_key_range, 433 const WebIDBKeyRange& idb_key_range,
383 unsigned short direction, 434 unsigned short direction,
384 WebIDBCallbacks* callbacks_ptr, 435 WebIDBCallbacks* callbacks_ptr,
385 int32 idb_object_store_id, 436 int32 idb_object_store_id,
386 const WebIDBTransaction& transaction, 437 const WebIDBTransaction& transaction,
387 WebExceptionCode* ec) { 438 WebExceptionCode* ec) {
388 ResetCursorPrefetchCaches(); 439 ResetCursorPrefetchCaches();
389 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 440 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
390 IndexedDBHostMsg_ObjectStoreOpenCursor_Params params; 441 IndexedDBHostMsg_ObjectStoreOpenCursor_Params params;
442 params.thread_id = CurrentWorkerId();
391 params.response_id = pending_callbacks_.Add(callbacks.release()); 443 params.response_id = pending_callbacks_.Add(callbacks.release());
392 params.lower_key.Set(idb_key_range.lower()); 444 params.lower_key.Set(idb_key_range.lower());
393 params.upper_key.Set(idb_key_range.upper()); 445 params.upper_key.Set(idb_key_range.upper());
394 params.lower_open = idb_key_range.lowerOpen(); 446 params.lower_open = idb_key_range.lowerOpen();
395 params.upper_open = idb_key_range.upperOpen(); 447 params.upper_open = idb_key_range.upperOpen();
396 params.direction = direction; 448 params.direction = direction;
397 params.idb_object_store_id = idb_object_store_id; 449 params.idb_object_store_id = idb_object_store_id;
398 params.transaction_id = TransactionId(transaction); 450 params.transaction_id = TransactionId(transaction);
399 Send(new IndexedDBHostMsg_ObjectStoreOpenCursor(params, ec)); 451 Send(new IndexedDBHostMsg_ObjectStoreOpenCursor(params, ec));
400 if (*ec) 452 if (*ec)
(...skipping 10 matching lines...) Expand all
411 cursors_.erase(cursor_id); 463 cursors_.erase(cursor_id);
412 } 464 }
413 465
414 int32 IndexedDBDispatcher::TransactionId( 466 int32 IndexedDBDispatcher::TransactionId(
415 const WebIDBTransaction& transaction) { 467 const WebIDBTransaction& transaction) {
416 const RendererWebIDBTransactionImpl* impl = 468 const RendererWebIDBTransactionImpl* impl =
417 static_cast<const RendererWebIDBTransactionImpl*>(&transaction); 469 static_cast<const RendererWebIDBTransactionImpl*>(&transaction);
418 return impl->id(); 470 return impl->id();
419 } 471 }
420 472
421 void IndexedDBDispatcher::OnSuccessIDBDatabase(int32 response_id, 473 void IndexedDBDispatcher::OnSuccessIDBDatabase(int32 thread_id,
michaeln 2011/12/14 02:15:53 maybe DCHECK_EQ(thread_id, CurrentWorkerId()) here
dgrogan 2011/12/15 02:47:44 Done.
474 int32 response_id,
422 int32 object_id) { 475 int32 object_id) {
423 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); 476 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
424 if (!callbacks) 477 if (!callbacks)
425 return; 478 return;
426 callbacks->onSuccess(new RendererWebIDBDatabaseImpl(object_id)); 479 callbacks->onSuccess(new RendererWebIDBDatabaseImpl(object_id));
427 pending_callbacks_.Remove(response_id); 480 pending_callbacks_.Remove(response_id);
428 } 481 }
429 482
430 void IndexedDBDispatcher::OnSuccessIndexedDBKey(int32 response_id, 483 void IndexedDBDispatcher::OnSuccessIndexedDBKey(int32 thread_id,
484 int32 response_id,
431 const IndexedDBKey& key) { 485 const IndexedDBKey& key) {
432 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); 486 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
433 if (!callbacks) 487 if (!callbacks)
434 return; 488 return;
435 callbacks->onSuccess(key); 489 callbacks->onSuccess(key);
436 pending_callbacks_.Remove(response_id); 490 pending_callbacks_.Remove(response_id);
437 } 491 }
438 492
439 void IndexedDBDispatcher::OnSuccessIDBTransaction(int32 response_id, 493 void IndexedDBDispatcher::OnSuccessIDBTransaction(int32 thread_id,
494 int32 response_id,
440 int32 object_id) { 495 int32 object_id) {
441 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); 496 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
442 if (!callbacks) 497 if (!callbacks)
443 return; 498 return;
444 callbacks->onSuccess(new RendererWebIDBTransactionImpl(object_id)); 499 callbacks->onSuccess(new RendererWebIDBTransactionImpl(object_id));
445 pending_callbacks_.Remove(response_id); 500 pending_callbacks_.Remove(response_id);
446 } 501 }
447 502
448 void IndexedDBDispatcher::OnSuccessStringList( 503 void IndexedDBDispatcher::OnSuccessStringList(
449 int32 response_id, const std::vector<string16>& value) { 504 int32 thread_id, int32 response_id, const std::vector<string16>& value) {
450 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); 505 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
451 if (!callbacks) 506 if (!callbacks)
452 return; 507 return;
453 WebDOMStringList string_list; 508 WebDOMStringList string_list;
454 for (std::vector<string16>::const_iterator it = value.begin(); 509 for (std::vector<string16>::const_iterator it = value.begin();
455 it != value.end(); ++it) 510 it != value.end(); ++it)
456 string_list.append(*it); 511 string_list.append(*it);
457 callbacks->onSuccess(string_list); 512 callbacks->onSuccess(string_list);
458 pending_callbacks_.Remove(response_id); 513 pending_callbacks_.Remove(response_id);
459 } 514 }
460 515
461 void IndexedDBDispatcher::OnSuccessSerializedScriptValue( 516 void IndexedDBDispatcher::OnSuccessSerializedScriptValue(
462 int32 response_id, const content::SerializedScriptValue& value) { 517 int32 thread_id, int32 response_id,
518 const content::SerializedScriptValue& value) {
463 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); 519 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
464 if (!callbacks) 520 if (!callbacks)
465 return; 521 return;
466 callbacks->onSuccess(value); 522 callbacks->onSuccess(value);
467 pending_callbacks_.Remove(response_id); 523 pending_callbacks_.Remove(response_id);
468 } 524 }
469 525
470 void IndexedDBDispatcher::OnSuccessOpenCursor(int32 repsonse_id, 526 void IndexedDBDispatcher::OnSuccessOpenCursor(
471 int32 object_id, const IndexedDBKey& key, const IndexedDBKey& primary_key, 527 const IndexedDBMsg_CallbacksSuccessIDBCursor_Params& p) {
472 const content::SerializedScriptValue& value) { 528 int32 repsonse_id = p.response_id;
529 int32 object_id = p.cursor_id;
530 const IndexedDBKey& key = p.key;
531 const IndexedDBKey& primary_key = p.primary_key;
532 const content::SerializedScriptValue& value = p.serialized_value;
473 WebIDBCallbacks* callbacks = 533 WebIDBCallbacks* callbacks =
474 pending_callbacks_.Lookup(repsonse_id); 534 pending_callbacks_.Lookup(repsonse_id);
475 if (!callbacks) 535 if (!callbacks)
476 return; 536 return;
477 537
478 RendererWebIDBCursorImpl* cursor = new RendererWebIDBCursorImpl(object_id); 538 RendererWebIDBCursorImpl* cursor = new RendererWebIDBCursorImpl(object_id);
479 cursors_[object_id] = cursor; 539 cursors_[object_id] = cursor;
480 cursor->SetKeyAndValue(key, primary_key, value); 540 cursor->SetKeyAndValue(key, primary_key, value);
481 callbacks->onSuccess(cursor); 541 callbacks->onSuccess(cursor);
482 542
483 pending_callbacks_.Remove(repsonse_id); 543 pending_callbacks_.Remove(repsonse_id);
484 } 544 }
485 545
486 void IndexedDBDispatcher::OnSuccessCursorContinue( 546 void IndexedDBDispatcher::OnSuccessCursorContinue(
487 int32 response_id, 547 const IndexedDBMsg_CallbacksSuccessCursorContinue_Params& p) {
488 int32 cursor_id, 548 int32 response_id = p.response_id;
489 const IndexedDBKey& key, 549 int32 cursor_id = p.cursor_id;
490 const IndexedDBKey& primary_key, 550 const IndexedDBKey& key = p.key;
491 const content::SerializedScriptValue& value) { 551 const IndexedDBKey& primary_key = p.primary_key;
552 const content::SerializedScriptValue& value = p.serialized_value;
492 RendererWebIDBCursorImpl* cursor = cursors_[cursor_id]; 553 RendererWebIDBCursorImpl* cursor = cursors_[cursor_id];
493 DCHECK(cursor); 554 DCHECK(cursor);
494 cursor->SetKeyAndValue(key, primary_key, value); 555 cursor->SetKeyAndValue(key, primary_key, value);
495 556
496 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); 557 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
497 if (!callbacks) 558 if (!callbacks)
498 return; 559 return;
499 callbacks->onSuccessWithContinuation(); 560 callbacks->onSuccessWithContinuation();
500 561
501 pending_callbacks_.Remove(response_id); 562 pending_callbacks_.Remove(response_id);
502 } 563 }
503 564
504 void IndexedDBDispatcher::OnSuccessCursorPrefetch( 565 void IndexedDBDispatcher::OnSuccessCursorPrefetch(
505 int32 response_id, 566 const IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params& p) {
506 int32 cursor_id, 567 int32 response_id = p.response_id;
507 const std::vector<IndexedDBKey>& keys, 568 int32 cursor_id = p.cursor_id;
508 const std::vector<IndexedDBKey>& primary_keys, 569 const std::vector<IndexedDBKey>& keys = p.keys;
509 const std::vector<content::SerializedScriptValue>& values) { 570 const std::vector<IndexedDBKey>& primary_keys = p.primary_keys;
571 const std::vector<content::SerializedScriptValue>& values = p.values;
510 RendererWebIDBCursorImpl* cursor = cursors_[cursor_id]; 572 RendererWebIDBCursorImpl* cursor = cursors_[cursor_id];
511 DCHECK(cursor); 573 DCHECK(cursor);
512 cursor->SetPrefetchData(keys, primary_keys, values); 574 cursor->SetPrefetchData(keys, primary_keys, values);
513 575
514 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); 576 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
515 cursor->CachedContinue(callbacks); 577 cursor->CachedContinue(callbacks);
516 pending_callbacks_.Remove(response_id); 578 pending_callbacks_.Remove(response_id);
517 } 579 }
518 580
519 void IndexedDBDispatcher::OnBlocked(int32 response_id) { 581 void IndexedDBDispatcher::OnBlocked(int32 thread_id, int32 response_id) {
520 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); 582 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
521 callbacks->onBlocked(); 583 callbacks->onBlocked();
522 } 584 }
523 585
524 void IndexedDBDispatcher::OnError(int32 response_id, int code, 586 void IndexedDBDispatcher::OnError(int32 thread_id, int32 response_id, int code,
525 const string16& message) { 587 const string16& message) {
526 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); 588 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
527 if (!callbacks) 589 if (!callbacks)
528 return; 590 return;
529 callbacks->onError(WebIDBDatabaseError(code, message)); 591 callbacks->onError(WebIDBDatabaseError(code, message));
530 pending_callbacks_.Remove(response_id); 592 pending_callbacks_.Remove(response_id);
531 } 593 }
532 594
533 void IndexedDBDispatcher::OnAbort(int32 transaction_id) { 595 void IndexedDBDispatcher::OnAbort(int32 thread_id, int32 transaction_id) {
534 WebIDBTransactionCallbacks* callbacks = 596 WebIDBTransactionCallbacks* callbacks =
535 pending_transaction_callbacks_.Lookup(transaction_id); 597 pending_transaction_callbacks_.Lookup(transaction_id);
536 if (!callbacks) 598 if (!callbacks)
537 return; 599 return;
538 callbacks->onAbort(); 600 callbacks->onAbort();
539 pending_transaction_callbacks_.Remove(transaction_id); 601 pending_transaction_callbacks_.Remove(transaction_id);
540 } 602 }
541 603
542 void IndexedDBDispatcher::OnComplete(int32 transaction_id) { 604 void IndexedDBDispatcher::OnComplete(int32 thread_id, int32 transaction_id) {
543 WebIDBTransactionCallbacks* callbacks = 605 WebIDBTransactionCallbacks* callbacks =
544 pending_transaction_callbacks_.Lookup(transaction_id); 606 pending_transaction_callbacks_.Lookup(transaction_id);
545 if (!callbacks) 607 if (!callbacks)
546 return; 608 return;
547 callbacks->onComplete(); 609 callbacks->onComplete();
548 pending_transaction_callbacks_.Remove(transaction_id); 610 pending_transaction_callbacks_.Remove(transaction_id);
549 } 611 }
550 612
551 void IndexedDBDispatcher::OnVersionChange(int32 database_id, 613 void IndexedDBDispatcher::OnVersionChange(int32 thread_id,
614 int32 database_id,
552 const string16& newVersion) { 615 const string16& newVersion) {
553 WebIDBDatabaseCallbacks* callbacks = 616 WebIDBDatabaseCallbacks* callbacks =
554 pending_database_callbacks_.Lookup(database_id); 617 pending_database_callbacks_.Lookup(database_id);
555 // callbacks would be NULL if a versionchange event is received after close 618 // callbacks would be NULL if a versionchange event is received after close
556 // has been called. 619 // has been called.
557 if (!callbacks) 620 if (!callbacks)
558 return; 621 return;
559 callbacks->onVersionChange(newVersion); 622 callbacks->onVersionChange(newVersion);
560 } 623 }
561 624
562 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { 625 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) {
563 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; 626 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator;
564 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { 627 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) {
565 if (i->first == exception_cursor_id) 628 if (i->first == exception_cursor_id)
566 continue; 629 continue;
567 i->second->ResetPrefetchCache(); 630 i->second->ResetPrefetchCache();
568 } 631 }
569 } 632 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698