| 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) | |
| 56 IPC_MESSAGE_UNHANDLED(handled = false) | 54 IPC_MESSAGE_UNHANDLED(handled = false) |
| 57 IPC_END_MESSAGE_MAP() | 55 IPC_END_MESSAGE_MAP() |
| 58 return handled; | 56 return handled; |
| 59 } | 57 } |
| 60 | 58 |
| 61 void IndexedDBDispatcher::RequestIDBFactoryOpen( | 59 void IndexedDBDispatcher::RequestIDBFactoryOpen( |
| 62 const string16& name, const string16& description, | 60 const string16& name, const string16& description, |
| 63 WebIDBCallbacks* callbacks_ptr, const string16& origin, | 61 WebIDBCallbacks* callbacks_ptr, const string16& origin, |
| 64 WebFrame* web_frame) { | 62 WebFrame* web_frame) { |
| 65 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 63 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 params.response_id_ = pending_callbacks_.Add(callbacks.release()); | 170 params.response_id_ = pending_callbacks_.Add(callbacks.release()); |
| 173 params.left_key_.Set(idb_key_range.left()); | 171 params.left_key_.Set(idb_key_range.left()); |
| 174 params.right_key_.Set(idb_key_range.right()); | 172 params.right_key_.Set(idb_key_range.right()); |
| 175 params.flags_ = idb_key_range.flags(); | 173 params.flags_ = idb_key_range.flags(); |
| 176 params.direction_ = direction; | 174 params.direction_ = direction; |
| 177 params.idb_object_store_id_ = idb_object_store_id; | 175 params.idb_object_store_id_ = idb_object_store_id; |
| 178 RenderThread::current()->Send( | 176 RenderThread::current()->Send( |
| 179 new ViewHostMsg_IDBObjectStoreOpenCursor(params)); | 177 new ViewHostMsg_IDBObjectStoreOpenCursor(params)); |
| 180 } | 178 } |
| 181 | 179 |
| 182 void IndexedDBDispatcher::RequestIDBTransactionSetCallbacks( | |
| 183 WebKit::WebIDBTransactionCallbacks* callbacks) { | |
| 184 pending_transaction_callbacks_.AddWithID(callbacks, callbacks->id()); | |
| 185 } | |
| 186 | |
| 187 void IndexedDBDispatcher::OnSuccessNull(int32 response_id) { | 180 void IndexedDBDispatcher::OnSuccessNull(int32 response_id) { |
| 188 WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); | 181 WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
| 189 callbacks->onSuccess(); | 182 callbacks->onSuccess(); |
| 190 pending_callbacks_.Remove(response_id); | 183 pending_callbacks_.Remove(response_id); |
| 191 } | 184 } |
| 192 | 185 |
| 193 void IndexedDBDispatcher::OnSuccessIDBDatabase(int32 response_id, | 186 void IndexedDBDispatcher::OnSuccessIDBDatabase(int32 response_id, |
| 194 int32 object_id) { | 187 int32 object_id) { |
| 195 WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); | 188 WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
| 196 callbacks->onSuccess(new RendererWebIDBDatabaseImpl(object_id)); | 189 callbacks->onSuccess(new RendererWebIDBDatabaseImpl(object_id)); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 callbacks->onSuccess(new RendererWebIDBCursorImpl(object_id)); | 225 callbacks->onSuccess(new RendererWebIDBCursorImpl(object_id)); |
| 233 pending_callbacks_.Remove(repsonse_id); | 226 pending_callbacks_.Remove(repsonse_id); |
| 234 } | 227 } |
| 235 | 228 |
| 236 void IndexedDBDispatcher::OnError(int32 response_id, int code, | 229 void IndexedDBDispatcher::OnError(int32 response_id, int code, |
| 237 const string16& message) { | 230 const string16& message) { |
| 238 WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); | 231 WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
| 239 callbacks->onError(WebIDBDatabaseError(code, message)); | 232 callbacks->onError(WebIDBDatabaseError(code, message)); |
| 240 pending_callbacks_.Remove(response_id); | 233 pending_callbacks_.Remove(response_id); |
| 241 } | 234 } |
| 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 |