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