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 "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" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksBlocked, OnBlocked) | 58 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksBlocked, OnBlocked) |
59 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksAbort, OnAbort) | 59 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksAbort, OnAbort) |
60 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksComplete, OnComplete) | 60 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksComplete, OnComplete) |
61 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksVersionChange, | 61 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksVersionChange, |
62 OnVersionChange) | 62 OnVersionChange) |
63 IPC_MESSAGE_UNHANDLED(handled = false) | 63 IPC_MESSAGE_UNHANDLED(handled = false) |
64 IPC_END_MESSAGE_MAP() | 64 IPC_END_MESSAGE_MAP() |
65 return handled; | 65 return handled; |
66 } | 66 } |
67 | 67 |
| 68 void IndexedDBDispatcher::Send(IPC::Message* msg) { |
| 69 ChildThread::current()->Send(msg); |
| 70 } |
| 71 |
68 void IndexedDBDispatcher::RequestIDBCursorUpdate( | 72 void IndexedDBDispatcher::RequestIDBCursorUpdate( |
69 const content::SerializedScriptValue& value, | 73 const content::SerializedScriptValue& value, |
70 WebIDBCallbacks* callbacks_ptr, | 74 WebIDBCallbacks* callbacks_ptr, |
71 int32 idb_cursor_id, | 75 int32 idb_cursor_id, |
72 WebExceptionCode* ec) { | 76 WebExceptionCode* ec) { |
73 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 77 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
74 | 78 |
75 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 79 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
76 RenderThreadImpl::current()->Send( | 80 Send( |
77 new IndexedDBHostMsg_CursorUpdate(idb_cursor_id, response_id, value, ec)); | 81 new IndexedDBHostMsg_CursorUpdate(idb_cursor_id, response_id, value, ec)); |
78 if (*ec) | 82 if (*ec) |
79 pending_callbacks_.Remove(response_id); | 83 pending_callbacks_.Remove(response_id); |
80 } | 84 } |
81 | 85 |
82 void IndexedDBDispatcher::RequestIDBCursorContinue( | 86 void IndexedDBDispatcher::RequestIDBCursorContinue( |
83 const IndexedDBKey& key, | 87 const IndexedDBKey& key, |
84 WebIDBCallbacks* callbacks_ptr, | 88 WebIDBCallbacks* callbacks_ptr, |
85 int32 idb_cursor_id, | 89 int32 idb_cursor_id, |
86 WebExceptionCode* ec) { | 90 WebExceptionCode* ec) { |
87 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 91 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
88 | 92 |
89 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 93 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
90 RenderThreadImpl::current()->Send( | 94 Send( |
91 new IndexedDBHostMsg_CursorContinue(idb_cursor_id, response_id, key, ec)); | 95 new IndexedDBHostMsg_CursorContinue(idb_cursor_id, response_id, key, ec)); |
92 if (*ec) | 96 if (*ec) |
93 pending_callbacks_.Remove(response_id); | 97 pending_callbacks_.Remove(response_id); |
94 } | 98 } |
95 | 99 |
96 void IndexedDBDispatcher::RequestIDBCursorDelete( | 100 void IndexedDBDispatcher::RequestIDBCursorDelete( |
97 WebIDBCallbacks* callbacks_ptr, | 101 WebIDBCallbacks* callbacks_ptr, |
98 int32 idb_cursor_id, | 102 int32 idb_cursor_id, |
99 WebExceptionCode* ec) { | 103 WebExceptionCode* ec) { |
100 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 104 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
101 | 105 |
102 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 106 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
103 RenderThreadImpl::current()->Send( | 107 Send(new IndexedDBHostMsg_CursorDelete(idb_cursor_id, response_id, ec)); |
104 new IndexedDBHostMsg_CursorDelete(idb_cursor_id, response_id, ec)); | |
105 if (*ec) | 108 if (*ec) |
106 pending_callbacks_.Remove(response_id); | 109 pending_callbacks_.Remove(response_id); |
107 } | 110 } |
108 | 111 |
109 void IndexedDBDispatcher::RequestIDBFactoryOpen( | 112 void IndexedDBDispatcher::RequestIDBFactoryOpen( |
110 const string16& name, | 113 const string16& name, |
111 WebIDBCallbacks* callbacks_ptr, | 114 WebIDBCallbacks* callbacks_ptr, |
112 const string16& origin, | 115 const string16& origin, |
113 WebFrame* web_frame) { | 116 WebFrame* web_frame) { |
114 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 117 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
115 | 118 |
116 if (!web_frame) | 119 if (!web_frame) |
117 return; // We must be shutting down. | 120 return; // We must be shutting down. |
118 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); | 121 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); |
119 if (!render_view) | 122 if (!render_view) |
120 return; // We must be shutting down. | 123 return; // We must be shutting down. |
121 | 124 |
122 IndexedDBHostMsg_FactoryOpen_Params params; | 125 IndexedDBHostMsg_FactoryOpen_Params params; |
123 params.response_id = pending_callbacks_.Add(callbacks.release()); | 126 params.response_id = pending_callbacks_.Add(callbacks.release()); |
124 params.origin = origin; | 127 params.origin = origin; |
125 params.name = name; | 128 params.name = name; |
126 RenderThreadImpl::current()->Send(new IndexedDBHostMsg_FactoryOpen(params)); | 129 Send(new IndexedDBHostMsg_FactoryOpen(params)); |
127 } | 130 } |
128 | 131 |
129 void IndexedDBDispatcher::RequestIDBFactoryGetDatabaseNames( | 132 void IndexedDBDispatcher::RequestIDBFactoryGetDatabaseNames( |
130 WebIDBCallbacks* callbacks_ptr, | 133 WebIDBCallbacks* callbacks_ptr, |
131 const string16& origin, | 134 const string16& origin, |
132 WebFrame* web_frame) { | 135 WebFrame* web_frame) { |
133 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 136 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
134 | 137 |
135 if (!web_frame) | 138 if (!web_frame) |
136 return; // We must be shutting down. | 139 return; // We must be shutting down. |
137 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); | 140 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); |
138 if (!render_view) | 141 if (!render_view) |
139 return; // We must be shutting down. | 142 return; // We must be shutting down. |
140 | 143 |
141 IndexedDBHostMsg_FactoryGetDatabaseNames_Params params; | 144 IndexedDBHostMsg_FactoryGetDatabaseNames_Params params; |
142 params.response_id = pending_callbacks_.Add(callbacks.release()); | 145 params.response_id = pending_callbacks_.Add(callbacks.release()); |
143 params.origin = origin; | 146 params.origin = origin; |
144 RenderThreadImpl::current()->Send( | 147 Send(new IndexedDBHostMsg_FactoryGetDatabaseNames(params)); |
145 new IndexedDBHostMsg_FactoryGetDatabaseNames(params)); | |
146 } | 148 } |
147 | 149 |
148 void IndexedDBDispatcher::RequestIDBFactoryDeleteDatabase( | 150 void IndexedDBDispatcher::RequestIDBFactoryDeleteDatabase( |
149 const string16& name, | 151 const string16& name, |
150 WebIDBCallbacks* callbacks_ptr, | 152 WebIDBCallbacks* callbacks_ptr, |
151 const string16& origin, | 153 const string16& origin, |
152 WebFrame* web_frame) { | 154 WebFrame* web_frame) { |
153 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 155 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
154 | 156 |
155 if (!web_frame) | 157 if (!web_frame) |
156 return; // We must be shutting down. | 158 return; // We must be shutting down. |
157 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); | 159 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); |
158 if (!render_view) | 160 if (!render_view) |
159 return; // We must be shutting down. | 161 return; // We must be shutting down. |
160 | 162 |
161 IndexedDBHostMsg_FactoryDeleteDatabase_Params params; | 163 IndexedDBHostMsg_FactoryDeleteDatabase_Params params; |
162 params.response_id = pending_callbacks_.Add(callbacks.release()); | 164 params.response_id = pending_callbacks_.Add(callbacks.release()); |
163 params.origin = origin; | 165 params.origin = origin; |
164 params.name = name; | 166 params.name = name; |
165 RenderThreadImpl::current()->Send( | 167 Send(new IndexedDBHostMsg_FactoryDeleteDatabase(params)); |
166 new IndexedDBHostMsg_FactoryDeleteDatabase(params)); | |
167 } | 168 } |
168 | 169 |
169 void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) { | 170 void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) { |
170 RenderThreadImpl::current()->Send( | 171 Send(new IndexedDBHostMsg_DatabaseClose(idb_database_id)); |
171 new IndexedDBHostMsg_DatabaseClose(idb_database_id)); | |
172 pending_database_callbacks_.Remove(idb_database_id); | 172 pending_database_callbacks_.Remove(idb_database_id); |
173 } | 173 } |
174 | 174 |
175 void IndexedDBDispatcher::RequestIDBDatabaseOpen( | 175 void IndexedDBDispatcher::RequestIDBDatabaseOpen( |
176 WebIDBDatabaseCallbacks* callbacks_ptr, | 176 WebIDBDatabaseCallbacks* callbacks_ptr, |
177 int32 idb_database_id) { | 177 int32 idb_database_id) { |
178 scoped_ptr<WebIDBDatabaseCallbacks> callbacks(callbacks_ptr); | 178 scoped_ptr<WebIDBDatabaseCallbacks> callbacks(callbacks_ptr); |
179 | 179 |
180 int32 response_id = pending_database_callbacks_.Add(callbacks.release()); | 180 int32 response_id = pending_database_callbacks_.Add(callbacks.release()); |
181 RenderThreadImpl::current()->Send(new IndexedDBHostMsg_DatabaseOpen( | 181 Send(new IndexedDBHostMsg_DatabaseOpen(response_id, idb_database_id)); |
182 response_id, idb_database_id)); | |
183 } | 182 } |
184 | 183 |
185 void IndexedDBDispatcher::RequestIDBDatabaseSetVersion( | 184 void IndexedDBDispatcher::RequestIDBDatabaseSetVersion( |
186 const string16& version, | 185 const string16& version, |
187 WebIDBCallbacks* callbacks_ptr, | 186 WebIDBCallbacks* callbacks_ptr, |
188 int32 idb_database_id, | 187 int32 idb_database_id, |
189 WebExceptionCode* ec) { | 188 WebExceptionCode* ec) { |
190 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 189 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
191 | 190 |
192 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 191 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
193 RenderThreadImpl::current()->Send( | 192 Send(new IndexedDBHostMsg_DatabaseSetVersion(idb_database_id, response_id, |
194 new IndexedDBHostMsg_DatabaseSetVersion(idb_database_id, response_id, | 193 version, ec)); |
195 version, ec)); | |
196 if (*ec) | 194 if (*ec) |
197 pending_callbacks_.Remove(response_id); | 195 pending_callbacks_.Remove(response_id); |
198 } | 196 } |
199 | 197 |
200 void IndexedDBDispatcher::RequestIDBIndexOpenObjectCursor( | 198 void IndexedDBDispatcher::RequestIDBIndexOpenObjectCursor( |
201 const WebIDBKeyRange& idb_key_range, | 199 const WebIDBKeyRange& idb_key_range, |
202 unsigned short direction, | 200 unsigned short direction, |
203 WebIDBCallbacks* callbacks_ptr, | 201 WebIDBCallbacks* callbacks_ptr, |
204 int32 idb_index_id, | 202 int32 idb_index_id, |
205 const WebIDBTransaction& transaction, | 203 const WebIDBTransaction& transaction, |
206 WebExceptionCode* ec) { | 204 WebExceptionCode* ec) { |
207 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 205 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
208 IndexedDBHostMsg_IndexOpenCursor_Params params; | 206 IndexedDBHostMsg_IndexOpenCursor_Params params; |
209 params.response_id = pending_callbacks_.Add(callbacks.release()); | 207 params.response_id = pending_callbacks_.Add(callbacks.release()); |
210 params.lower_key.Set(idb_key_range.lower()); | 208 params.lower_key.Set(idb_key_range.lower()); |
211 params.upper_key.Set(idb_key_range.upper()); | 209 params.upper_key.Set(idb_key_range.upper()); |
212 params.lower_open = idb_key_range.lowerOpen(); | 210 params.lower_open = idb_key_range.lowerOpen(); |
213 params.upper_open = idb_key_range.upperOpen(); | 211 params.upper_open = idb_key_range.upperOpen(); |
214 params.direction = direction; | 212 params.direction = direction; |
215 params.idb_index_id = idb_index_id; | 213 params.idb_index_id = idb_index_id; |
216 params.transaction_id = TransactionId(transaction); | 214 params.transaction_id = TransactionId(transaction); |
217 RenderThreadImpl::current()->Send( | 215 Send(new IndexedDBHostMsg_IndexOpenObjectCursor(params, ec)); |
218 new IndexedDBHostMsg_IndexOpenObjectCursor(params, ec)); | |
219 if (*ec) | 216 if (*ec) |
220 pending_callbacks_.Remove(params.response_id); | 217 pending_callbacks_.Remove(params.response_id); |
221 } | 218 } |
222 | 219 |
223 void IndexedDBDispatcher::RequestIDBIndexOpenKeyCursor( | 220 void IndexedDBDispatcher::RequestIDBIndexOpenKeyCursor( |
224 const WebIDBKeyRange& idb_key_range, | 221 const WebIDBKeyRange& idb_key_range, |
225 unsigned short direction, | 222 unsigned short direction, |
226 WebIDBCallbacks* callbacks_ptr, | 223 WebIDBCallbacks* callbacks_ptr, |
227 int32 idb_index_id, | 224 int32 idb_index_id, |
228 const WebIDBTransaction& transaction, | 225 const WebIDBTransaction& transaction, |
229 WebExceptionCode* ec) { | 226 WebExceptionCode* ec) { |
230 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 227 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
231 IndexedDBHostMsg_IndexOpenCursor_Params params; | 228 IndexedDBHostMsg_IndexOpenCursor_Params params; |
232 params.response_id = pending_callbacks_.Add(callbacks.release()); | 229 params.response_id = pending_callbacks_.Add(callbacks.release()); |
233 // TODO(jorlow): We really should just create a Chromium abstraction for | 230 // TODO(jorlow): We really should just create a Chromium abstraction for |
234 // KeyRange rather than doing it ad-hoc like this. | 231 // KeyRange rather than doing it ad-hoc like this. |
235 params.lower_key.Set(idb_key_range.lower()); | 232 params.lower_key.Set(idb_key_range.lower()); |
236 params.upper_key.Set(idb_key_range.upper()); | 233 params.upper_key.Set(idb_key_range.upper()); |
237 params.lower_open = idb_key_range.lowerOpen(); | 234 params.lower_open = idb_key_range.lowerOpen(); |
238 params.upper_open = idb_key_range.upperOpen(); | 235 params.upper_open = idb_key_range.upperOpen(); |
239 params.direction = direction; | 236 params.direction = direction; |
240 params.idb_index_id = idb_index_id; | 237 params.idb_index_id = idb_index_id; |
241 params.transaction_id = TransactionId(transaction); | 238 params.transaction_id = TransactionId(transaction); |
242 RenderThreadImpl::current()->Send( | 239 Send(new IndexedDBHostMsg_IndexOpenKeyCursor(params, ec)); |
243 new IndexedDBHostMsg_IndexOpenKeyCursor(params, ec)); | |
244 if (*ec) | 240 if (*ec) |
245 pending_callbacks_.Remove(params.response_id); | 241 pending_callbacks_.Remove(params.response_id); |
246 } | 242 } |
247 | 243 |
248 void IndexedDBDispatcher::RequestIDBIndexGetObject( | 244 void IndexedDBDispatcher::RequestIDBIndexGetObject( |
249 const IndexedDBKey& key, | 245 const IndexedDBKey& key, |
250 WebIDBCallbacks* callbacks_ptr, | 246 WebIDBCallbacks* callbacks_ptr, |
251 int32 idb_index_id, | 247 int32 idb_index_id, |
252 const WebIDBTransaction& transaction, | 248 const WebIDBTransaction& transaction, |
253 WebExceptionCode* ec) { | 249 WebExceptionCode* ec) { |
254 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 250 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
255 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 251 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
256 RenderThreadImpl::current()->Send( | 252 Send(new IndexedDBHostMsg_IndexGetObject(idb_index_id, response_id, key, |
257 new IndexedDBHostMsg_IndexGetObject( | 253 TransactionId(transaction), ec)); |
258 idb_index_id, response_id, key, | |
259 TransactionId(transaction), ec)); | |
260 if (*ec) | 254 if (*ec) |
261 pending_callbacks_.Remove(response_id); | 255 pending_callbacks_.Remove(response_id); |
262 } | 256 } |
263 | 257 |
264 void IndexedDBDispatcher::RequestIDBIndexGetKey( | 258 void IndexedDBDispatcher::RequestIDBIndexGetKey( |
265 const IndexedDBKey& key, | 259 const IndexedDBKey& key, |
266 WebIDBCallbacks* callbacks_ptr, | 260 WebIDBCallbacks* callbacks_ptr, |
267 int32 idb_index_id, | 261 int32 idb_index_id, |
268 const WebIDBTransaction& transaction, | 262 const WebIDBTransaction& transaction, |
269 WebExceptionCode* ec) { | 263 WebExceptionCode* ec) { |
270 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 264 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
271 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 265 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
272 RenderThreadImpl::current()->Send( | 266 Send(new IndexedDBHostMsg_IndexGetKey( |
273 new IndexedDBHostMsg_IndexGetKey( | 267 idb_index_id, response_id, key, |
274 idb_index_id, response_id, key, | 268 TransactionId(transaction), ec)); |
275 TransactionId(transaction), ec)); | |
276 if (*ec) | 269 if (*ec) |
277 pending_callbacks_.Remove(response_id); | 270 pending_callbacks_.Remove(response_id); |
278 } | 271 } |
279 | 272 |
280 void IndexedDBDispatcher::RequestIDBObjectStoreGet( | 273 void IndexedDBDispatcher::RequestIDBObjectStoreGet( |
281 const IndexedDBKey& key, | 274 const IndexedDBKey& key, |
282 WebIDBCallbacks* callbacks_ptr, | 275 WebIDBCallbacks* callbacks_ptr, |
283 int32 idb_object_store_id, | 276 int32 idb_object_store_id, |
284 const WebIDBTransaction& transaction, | 277 const WebIDBTransaction& transaction, |
285 WebExceptionCode* ec) { | 278 WebExceptionCode* ec) { |
286 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 279 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
287 | 280 |
288 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 281 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
289 RenderThreadImpl::current()->Send( | 282 Send(new IndexedDBHostMsg_ObjectStoreGet( |
290 new IndexedDBHostMsg_ObjectStoreGet( | 283 idb_object_store_id, response_id, |
291 idb_object_store_id, response_id, | 284 key, TransactionId(transaction), ec)); |
292 key, TransactionId(transaction), ec)); | |
293 if (*ec) | 285 if (*ec) |
294 pending_callbacks_.Remove(response_id); | 286 pending_callbacks_.Remove(response_id); |
295 } | 287 } |
296 | 288 |
297 void IndexedDBDispatcher::RequestIDBObjectStorePut( | 289 void IndexedDBDispatcher::RequestIDBObjectStorePut( |
298 const content::SerializedScriptValue& value, | 290 const content::SerializedScriptValue& value, |
299 const IndexedDBKey& key, | 291 const IndexedDBKey& key, |
300 WebKit::WebIDBObjectStore::PutMode put_mode, | 292 WebKit::WebIDBObjectStore::PutMode put_mode, |
301 WebIDBCallbacks* callbacks_ptr, | 293 WebIDBCallbacks* callbacks_ptr, |
302 int32 idb_object_store_id, | 294 int32 idb_object_store_id, |
303 const WebIDBTransaction& transaction, | 295 const WebIDBTransaction& transaction, |
304 WebExceptionCode* ec) { | 296 WebExceptionCode* ec) { |
305 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 297 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
306 IndexedDBHostMsg_ObjectStorePut_Params params; | 298 IndexedDBHostMsg_ObjectStorePut_Params params; |
307 params.idb_object_store_id = idb_object_store_id; | 299 params.idb_object_store_id = idb_object_store_id; |
308 params.response_id = pending_callbacks_.Add(callbacks.release()); | 300 params.response_id = pending_callbacks_.Add(callbacks.release()); |
309 params.serialized_value = value; | 301 params.serialized_value = value; |
310 params.key = key; | 302 params.key = key; |
311 params.put_mode = put_mode; | 303 params.put_mode = put_mode; |
312 params.transaction_id = TransactionId(transaction); | 304 params.transaction_id = TransactionId(transaction); |
313 RenderThreadImpl::current()->Send(new IndexedDBHostMsg_ObjectStorePut( | 305 Send(new IndexedDBHostMsg_ObjectStorePut(params, ec)); |
314 params, ec)); | |
315 if (*ec) | 306 if (*ec) |
316 pending_callbacks_.Remove(params.response_id); | 307 pending_callbacks_.Remove(params.response_id); |
317 } | 308 } |
318 | 309 |
319 void IndexedDBDispatcher::RequestIDBObjectStoreDelete( | 310 void IndexedDBDispatcher::RequestIDBObjectStoreDelete( |
320 const IndexedDBKey& key, | 311 const IndexedDBKey& key, |
321 WebIDBCallbacks* callbacks_ptr, | 312 WebIDBCallbacks* callbacks_ptr, |
322 int32 idb_object_store_id, | 313 int32 idb_object_store_id, |
323 const WebIDBTransaction& transaction, | 314 const WebIDBTransaction& transaction, |
324 WebExceptionCode* ec) { | 315 WebExceptionCode* ec) { |
325 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 316 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
326 | 317 |
327 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 318 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
328 RenderThreadImpl::current()->Send( | 319 Send(new IndexedDBHostMsg_ObjectStoreDelete( |
329 new IndexedDBHostMsg_ObjectStoreDelete( | 320 idb_object_store_id, response_id, key, TransactionId(transaction), ec)); |
330 idb_object_store_id, response_id, | |
331 key, TransactionId(transaction), ec)); | |
332 if (*ec) | 321 if (*ec) |
333 pending_callbacks_.Remove(response_id); | 322 pending_callbacks_.Remove(response_id); |
334 } | 323 } |
335 | 324 |
336 void IndexedDBDispatcher::RequestIDBObjectStoreClear( | 325 void IndexedDBDispatcher::RequestIDBObjectStoreClear( |
337 WebIDBCallbacks* callbacks_ptr, | 326 WebIDBCallbacks* callbacks_ptr, |
338 int32 idb_object_store_id, | 327 int32 idb_object_store_id, |
339 const WebIDBTransaction& transaction, | 328 const WebIDBTransaction& transaction, |
340 WebExceptionCode* ec) { | 329 WebExceptionCode* ec) { |
341 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 330 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
342 | 331 |
343 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 332 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
344 RenderThreadImpl::current()->Send( | 333 Send(new IndexedDBHostMsg_ObjectStoreClear( |
345 new IndexedDBHostMsg_ObjectStoreClear( | 334 idb_object_store_id, response_id, TransactionId(transaction), ec)); |
346 idb_object_store_id, response_id, | |
347 TransactionId(transaction), ec)); | |
348 if (*ec) | 335 if (*ec) |
349 pending_callbacks_.Remove(response_id); | 336 pending_callbacks_.Remove(response_id); |
350 } | 337 } |
351 | 338 |
352 void IndexedDBDispatcher::RequestIDBObjectStoreOpenCursor( | 339 void IndexedDBDispatcher::RequestIDBObjectStoreOpenCursor( |
353 const WebIDBKeyRange& idb_key_range, | 340 const WebIDBKeyRange& idb_key_range, |
354 unsigned short direction, | 341 unsigned short direction, |
355 WebIDBCallbacks* callbacks_ptr, | 342 WebIDBCallbacks* callbacks_ptr, |
356 int32 idb_object_store_id, | 343 int32 idb_object_store_id, |
357 const WebIDBTransaction& transaction, | 344 const WebIDBTransaction& transaction, |
358 WebExceptionCode* ec) { | 345 WebExceptionCode* ec) { |
359 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 346 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
360 IndexedDBHostMsg_ObjectStoreOpenCursor_Params params; | 347 IndexedDBHostMsg_ObjectStoreOpenCursor_Params params; |
361 params.response_id = pending_callbacks_.Add(callbacks.release()); | 348 params.response_id = pending_callbacks_.Add(callbacks.release()); |
362 params.lower_key.Set(idb_key_range.lower()); | 349 params.lower_key.Set(idb_key_range.lower()); |
363 params.upper_key.Set(idb_key_range.upper()); | 350 params.upper_key.Set(idb_key_range.upper()); |
364 params.lower_open = idb_key_range.lowerOpen(); | 351 params.lower_open = idb_key_range.lowerOpen(); |
365 params.upper_open = idb_key_range.upperOpen(); | 352 params.upper_open = idb_key_range.upperOpen(); |
366 params.direction = direction; | 353 params.direction = direction; |
367 params.idb_object_store_id = idb_object_store_id; | 354 params.idb_object_store_id = idb_object_store_id; |
368 params.transaction_id = TransactionId(transaction); | 355 params.transaction_id = TransactionId(transaction); |
369 RenderThreadImpl::current()->Send( | 356 Send(new IndexedDBHostMsg_ObjectStoreOpenCursor(params, ec)); |
370 new IndexedDBHostMsg_ObjectStoreOpenCursor(params, ec)); | |
371 if (*ec) | 357 if (*ec) |
372 pending_callbacks_.Remove(params.response_id); | 358 pending_callbacks_.Remove(params.response_id); |
373 } | 359 } |
374 | 360 |
375 void IndexedDBDispatcher::RegisterWebIDBTransactionCallbacks( | 361 void IndexedDBDispatcher::RegisterWebIDBTransactionCallbacks( |
376 WebIDBTransactionCallbacks* callbacks, | 362 WebIDBTransactionCallbacks* callbacks, |
377 int32 id) { | 363 int32 id) { |
378 pending_transaction_callbacks_.AddWithID(callbacks, id); | 364 pending_transaction_callbacks_.AddWithID(callbacks, id); |
379 } | 365 } |
380 | 366 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 void IndexedDBDispatcher::OnVersionChange(int32 database_id, | 493 void IndexedDBDispatcher::OnVersionChange(int32 database_id, |
508 const string16& newVersion) { | 494 const string16& newVersion) { |
509 WebIDBDatabaseCallbacks* callbacks = | 495 WebIDBDatabaseCallbacks* callbacks = |
510 pending_database_callbacks_.Lookup(database_id); | 496 pending_database_callbacks_.Lookup(database_id); |
511 // callbacks would be NULL if a versionchange event is received after close | 497 // callbacks would be NULL if a versionchange event is received after close |
512 // has been called. | 498 // has been called. |
513 if (!callbacks) | 499 if (!callbacks) |
514 return; | 500 return; |
515 callbacks->onVersionChange(newVersion); | 501 callbacks->onVersionChange(newVersion); |
516 } | 502 } |
OLD | NEW |