Chromium Code Reviews| Index: content/browser/in_process_webkit/indexed_db_dispatcher_host.cc |
| diff --git a/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc b/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc |
| index 3f46966c2b36c15e7d7d16f288e364a65a3cba00..891a7179d78837a5ffcef8107705803e6e7f08b7 100644 |
| --- a/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc |
| +++ b/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc |
| @@ -361,6 +361,16 @@ bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived( |
| OnCreateTransaction) |
| IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) |
| IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) |
| + IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGet, OnGet) |
| + IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePut, OnPut) |
| + IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexKeys, |
| + OnSetIndexKeys) |
| + IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexesReady, |
| + OnSetIndexesReady) |
| + IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseOpenCursor, OnOpenCursor) |
| + IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCount, OnCount) |
| + IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteRange, OnDelete) |
| + IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClear, OnClear) |
| IPC_MESSAGE_UNHANDLED(handled = false) |
| IPC_END_MESSAGE_MAP() |
| return handled; |
| @@ -491,6 +501,147 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed( |
| parent_->DestroyObject(&map_, ipc_object_id); |
| } |
| +// XXX alecf |
|
jsbell
2012/12/14 23:04:34
Don't forget to remove this.
|
| +void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnGet( |
| + const IndexedDBHostMsg_DatabaseGet_Params& params) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| + WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
| + &map_, params.ipc_database_id); |
| + if (!database) |
| + return; |
| + |
| + scoped_ptr<WebIDBCallbacks> callbacks( |
| + new IndexedDBCallbacks<WebSerializedScriptValue>( |
| + parent_, params.ipc_thread_id, |
| + params.ipc_response_id)); |
| + database->get(params.transaction_id, params.object_store_id, |
| + params.index_id, |
| + params.key_range, params.key_only, callbacks.release()); |
| +} |
| + |
| +void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPut( |
| + const IndexedDBHostMsg_DatabasePut_Params& params) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| + |
| + WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
| + &map_, params.ipc_database_id); |
| + if (!database) |
| + return; |
| + scoped_ptr<WebIDBCallbacks> callbacks( |
| + new IndexedDBCallbacks<WebIDBKey>(parent_, params.ipc_thread_id, |
| + params.ipc_response_id)); |
| + |
| + database->put(params.transaction_id, params.object_store_id, |
| + params.value, params.key, |
| + params.put_mode, callbacks.release(), |
| + params.index_ids, |
| + params.index_keys); |
| + WebIDBTransactionIDToSizeMap* map = |
| + &parent_->database_dispatcher_host_->transaction_size_map_; |
| + // Size can't be big enough to overflow because it represents the |
| + // actual bytes passed through IPC. |
| + (*map)[params.transaction_id] += params.value.size(); |
| +} |
| + |
| +void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexKeys( |
| + const IndexedDBHostMsg_DatabaseSetIndexKeys_Params& params) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| + WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
| + &map_, params.ipc_database_id); |
| + if (!database) |
| + return; |
| + |
| + database->setIndexKeys(params.transaction_id, params.object_store_id, |
| + params.primary_key, params.index_ids, |
| + params.index_keys); |
| +} |
| + |
| +void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexesReady( |
| + int32 ipc_database_id, |
| + int64 transaction_id, |
| + int64 object_store_id, |
| + const std::vector<int64>& index_ids) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| + WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
| + &map_, ipc_database_id); |
| + if (!database) |
| + return; |
| + |
| + database->setIndexesReady(transaction_id, object_store_id, |
| + WebVector<long long>(index_ids)); |
| +} |
| + |
| +void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnOpenCursor( |
| + const IndexedDBHostMsg_DatabaseOpenCursor_Params& params) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| + WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
| + &map_, params.ipc_database_id); |
| + if (!database) |
| + return; |
| + |
| + scoped_ptr<WebIDBCallbacks> callbacks( |
| + new IndexedDBCallbacks<WebIDBCursor>(parent_, params.ipc_thread_id, |
| + params.ipc_response_id, -1)); |
| + database->openCursor( |
| + params.transaction_id, params.object_store_id, params.index_id, |
| + params.key_range, params.direction, params.key_only, params.task_type, |
| + callbacks.release()); |
| +} |
| + |
| +void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCount( |
| + const IndexedDBHostMsg_DatabaseCount_Params& params) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| + WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
| + &map_, params.ipc_database_id); |
| + if (!database) |
| + return; |
| + |
| + scoped_ptr<WebIDBCallbacks> callbacks( |
| + new IndexedDBCallbacks<WebSerializedScriptValue>( |
| + parent_, params.ipc_thread_id, |
| + params.ipc_response_id)); |
| + database->count( |
| + params.transaction_id, params.object_store_id, params.index_id, |
| + params.key_range, callbacks.release()); |
| +} |
| + |
| +void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDelete( |
| + const IndexedDBHostMsg_DatabaseDeleteRange_Params& params) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| + WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
| + &map_, params.ipc_database_id); |
| + if (!database) |
| + return; |
| + |
| + scoped_ptr<WebIDBCallbacks> callbacks( |
| + new IndexedDBCallbacks<WebSerializedScriptValue>( |
| + parent_, params.ipc_thread_id, |
| + params.ipc_response_id)); |
| + database->deleteRange(params.transaction_id, params.object_store_id, |
| + params.key_range, callbacks.release()); |
| +} |
| + |
| +void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClear( |
| + int32 ipc_thread_id, |
| + int32 ipc_response_id, |
| + int32 ipc_database_id, |
| + int64 transaction_id, |
| + int64 object_store_id) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| + WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
| + &map_, ipc_database_id); |
| + if (!database) |
| + return; |
| + |
| + scoped_ptr<WebIDBCallbacks> callbacks( |
| + new IndexedDBCallbacks<WebSerializedScriptValue>( |
| + parent_, ipc_thread_id, |
| + ipc_response_id)); |
| + |
| + database->clear(transaction_id, object_store_id, callbacks.release()); |
| +} |
| + |
| +// xxx end alecf |
|
jsbell
2012/12/14 23:04:34
Don't forget to remove.
|
| ////////////////////////////////////////////////////////////////////// |
| // IndexedDBDispatcherHost::IndexDispatcherHost |
| @@ -719,8 +870,8 @@ void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnPut( |
| *idb_transaction, params.index_ids, |
| params.index_keys); |
| int64 size = UTF16ToUTF8(params.serialized_value.data()).size(); |
| - WebIDBTransactionIDToSizeMap* map = |
| - &parent_->transaction_dispatcher_host_->transaction_size_map_; |
| + WebIDBTransactionIPCIDToSizeMap* map = |
| + &parent_->transaction_dispatcher_host_->transaction_ipc_size_map_; |
| (*map)[params.ipc_transaction_id] += size; |
| } |
| @@ -1083,7 +1234,7 @@ void IndexedDBDispatcherHost::TransactionDispatcherHost::OnCommit( |
| // http://crbug.com/113118 |
| if (parent_->Context()->WouldBeOverQuota( |
| transaction_url_map_[ipc_transaction_id], |
| - transaction_size_map_[ipc_transaction_id])) { |
| + transaction_ipc_size_map_[ipc_transaction_id])) { |
| idb_transaction->abort(); |
| return; |
| } |
| @@ -1129,7 +1280,7 @@ void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( |
| int32 ipc_object_id) { |
| // TODO(dgrogan): This doesn't seem to be happening with some version change |
| // transactions. Possibly introduced with integer version support. |
| - transaction_size_map_.erase(ipc_object_id); |
| + transaction_ipc_size_map_.erase(ipc_object_id); |
| transaction_url_map_.erase(ipc_object_id); |
| parent_->DestroyObject(&map_, ipc_object_id); |
| } |