OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/renderer/indexed_db_dispatcher.h" | 5 #include "chrome/renderer/indexed_db_dispatcher.h" |
6 | 6 |
7 #include "chrome/common/indexed_db_key.h" | 7 #include "chrome/common/indexed_db_key.h" |
8 #include "chrome/common/render_messages.h" | 8 #include "chrome/common/render_messages.h" |
9 #include "chrome/common/serialized_script_value.h" | 9 #include "chrome/common/serialized_script_value.h" |
10 #include "chrome/renderer/render_thread.h" | 10 #include "chrome/renderer/render_thread.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksSuccessIDBObjectStore, | 44 IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksSuccessIDBObjectStore, |
45 OnSuccessIDBObjectStore) | 45 OnSuccessIDBObjectStore) |
46 IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksSuccessIDBIndex, | 46 IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksSuccessIDBIndex, |
47 OnSuccessIDBIndex) | 47 OnSuccessIDBIndex) |
48 IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbackSuccessOpenCursor, | 48 IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbackSuccessOpenCursor, |
49 OnSuccessOpenCursor) | 49 OnSuccessOpenCursor) |
50 IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksSuccessSerializedScriptValue, | 50 IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksSuccessSerializedScriptValue, |
51 OnSuccessSerializedScriptValue) | 51 OnSuccessSerializedScriptValue) |
52 IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksError, | 52 IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksError, |
53 OnError) | 53 OnError) |
| 54 IPC_MESSAGE_HANDLER(ViewMsg_IDBTransactionCallbacksAbort, |
| 55 OnAbort) |
54 IPC_MESSAGE_UNHANDLED(handled = false) | 56 IPC_MESSAGE_UNHANDLED(handled = false) |
55 IPC_END_MESSAGE_MAP() | 57 IPC_END_MESSAGE_MAP() |
56 return handled; | 58 return handled; |
57 } | 59 } |
58 | 60 |
59 void IndexedDBDispatcher::RequestIDBFactoryOpen( | 61 void IndexedDBDispatcher::RequestIDBFactoryOpen( |
60 const string16& name, const string16& description, | 62 const string16& name, const string16& description, |
61 WebIDBCallbacks* callbacks_ptr, const string16& origin, | 63 WebIDBCallbacks* callbacks_ptr, const string16& origin, |
62 WebFrame* web_frame) { | 64 WebFrame* web_frame) { |
63 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 65 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 params.response_id_ = pending_callbacks_.Add(callbacks.release()); | 172 params.response_id_ = pending_callbacks_.Add(callbacks.release()); |
171 params.left_key_.Set(idb_key_range.left()); | 173 params.left_key_.Set(idb_key_range.left()); |
172 params.right_key_.Set(idb_key_range.right()); | 174 params.right_key_.Set(idb_key_range.right()); |
173 params.flags_ = idb_key_range.flags(); | 175 params.flags_ = idb_key_range.flags(); |
174 params.direction_ = direction; | 176 params.direction_ = direction; |
175 params.idb_object_store_id_ = idb_object_store_id; | 177 params.idb_object_store_id_ = idb_object_store_id; |
176 RenderThread::current()->Send( | 178 RenderThread::current()->Send( |
177 new ViewHostMsg_IDBObjectStoreOpenCursor(params)); | 179 new ViewHostMsg_IDBObjectStoreOpenCursor(params)); |
178 } | 180 } |
179 | 181 |
| 182 void IndexedDBDispatcher::RequestIDBTransactionSetCallbacks( |
| 183 WebKit::WebIDBTransactionCallbacks* callbacks) { |
| 184 pending_transaction_callbacks_.AddWithID(callbacks, callbacks->id()); |
| 185 } |
| 186 |
180 void IndexedDBDispatcher::OnSuccessNull(int32 response_id) { | 187 void IndexedDBDispatcher::OnSuccessNull(int32 response_id) { |
181 WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); | 188 WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
182 callbacks->onSuccess(); | 189 callbacks->onSuccess(); |
183 pending_callbacks_.Remove(response_id); | 190 pending_callbacks_.Remove(response_id); |
184 } | 191 } |
185 | 192 |
186 void IndexedDBDispatcher::OnSuccessIDBDatabase(int32 response_id, | 193 void IndexedDBDispatcher::OnSuccessIDBDatabase(int32 response_id, |
187 int32 object_id) { | 194 int32 object_id) { |
188 WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); | 195 WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
189 callbacks->onSuccess(new RendererWebIDBDatabaseImpl(object_id)); | 196 callbacks->onSuccess(new RendererWebIDBDatabaseImpl(object_id)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 callbacks->onSuccess(new RendererWebIDBCursorImpl(object_id)); | 232 callbacks->onSuccess(new RendererWebIDBCursorImpl(object_id)); |
226 pending_callbacks_.Remove(repsonse_id); | 233 pending_callbacks_.Remove(repsonse_id); |
227 } | 234 } |
228 | 235 |
229 void IndexedDBDispatcher::OnError(int32 response_id, int code, | 236 void IndexedDBDispatcher::OnError(int32 response_id, int code, |
230 const string16& message) { | 237 const string16& message) { |
231 WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); | 238 WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
232 callbacks->onError(WebIDBDatabaseError(code, message)); | 239 callbacks->onError(WebIDBDatabaseError(code, message)); |
233 pending_callbacks_.Remove(response_id); | 240 pending_callbacks_.Remove(response_id); |
234 } | 241 } |
| 242 |
| 243 void IndexedDBDispatcher::OnAbort(int transaction_id) { |
| 244 WebKit::WebIDBTransactionCallbacks* callbacks = |
| 245 pending_transaction_callbacks_.Lookup(transaction_id); |
| 246 DCHECK(callbacks); |
| 247 callbacks->onAbort(); |
| 248 pending_transaction_callbacks_.Remove(transaction_id); |
| 249 } |
OLD | NEW |