Chromium Code Reviews| Index: content/common/indexed_db/indexed_db_dispatcher.cc |
| diff --git a/content/common/indexed_db/indexed_db_dispatcher.cc b/content/common/indexed_db/indexed_db_dispatcher.cc |
| index e308357b062e96aeb710841797266c67e067bc07..bf29c336aa3832f3faeed762b1971c5a9674b66e 100644 |
| --- a/content/common/indexed_db/indexed_db_dispatcher.cc |
| +++ b/content/common/indexed_db/indexed_db_dispatcher.cc |
| @@ -101,15 +101,20 @@ void IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) { |
| OnSuccessSerializedScriptValue) |
| IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksError, OnError) |
| IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksBlocked, OnBlocked) |
| + IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksIntBlocked, OnIntBlocked) |
| IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksAbort, OnAbort) |
| IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksComplete, OnComplete) |
| + IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksIntVersionChange, |
| + OnIntVersionChange) |
| IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksVersionChange, |
| OnVersionChange) |
| + IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksUpgradeNeeded, OnUpgradeNeeded) |
|
jsbell
2012/07/25 22:12:16
Can you put this with the other _Callbacks message
dgrogan
2012/07/25 23:59:59
Done.
|
| IPC_MESSAGE_UNHANDLED(handled = false) |
| IPC_END_MESSAGE_MAP() |
| // If a message gets here, IndexedDBMessageFilter already determined that it |
| // is an IndexedDB message. |
| - DCHECK(handled); |
| + DCHECK(handled) << "Didn't handle a message defined at line " |
| + << IPC_MESSAGE_ID_LINE(msg.type()); |
| } |
| bool IndexedDBDispatcher::Send(IPC::Message* msg) { |
| @@ -213,6 +218,7 @@ void IndexedDBDispatcher::RequestIDBCursorDelete( |
| void IndexedDBDispatcher::RequestIDBFactoryOpen( |
| const string16& name, |
| + int64 version, |
| WebIDBCallbacks* callbacks_ptr, |
| const string16& origin, |
| WebFrame* web_frame) { |
| @@ -228,6 +234,7 @@ void IndexedDBDispatcher::RequestIDBFactoryOpen( |
| params.response_id = pending_callbacks_.Add(callbacks.release()); |
| params.origin = origin; |
| params.name = name; |
| + params.version = version; |
| Send(new IndexedDBHostMsg_FactoryOpen(params)); |
| } |
| @@ -272,7 +279,10 @@ void IndexedDBDispatcher::RequestIDBFactoryDeleteDatabase( |
| void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) { |
| ResetCursorPrefetchCaches(); |
| Send(new IndexedDBHostMsg_DatabaseClose(idb_database_id)); |
| - pending_database_callbacks_.Remove(idb_database_id); |
| + // There won't be pending database callbacks if the transaction was aborted in |
| + // the initial upgradeneeded event handler. |
| + if (pending_database_callbacks_.Lookup(idb_database_id)) |
| + pending_database_callbacks_.Remove(idb_database_id); |
| } |
| void IndexedDBDispatcher::RequestIDBDatabaseOpen( |
| @@ -539,6 +549,11 @@ void IndexedDBDispatcher::CursorDestroyed(int32 cursor_id) { |
| cursors_.erase(cursor_id); |
| } |
| +void IndexedDBDispatcher::DatabaseDestroyed(int32 database_id) { |
| + DCHECK_EQ(databases_.count(database_id), 1u); |
| + databases_.erase(database_id); |
| +} |
| + |
| int32 IndexedDBDispatcher::TransactionId( |
| const WebIDBTransaction& transaction) { |
| const RendererWebIDBTransactionImpl* impl = |
| @@ -553,7 +568,9 @@ void IndexedDBDispatcher::OnSuccessIDBDatabase(int32 thread_id, |
| WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
| if (!callbacks) |
| return; |
| - callbacks->onSuccess(new RendererWebIDBDatabaseImpl(object_id)); |
| + if (!databases_.count(object_id)) |
|
jsbell
2012/07/25 22:12:16
Add comment here that count will be non-zero if an
dgrogan
2012/07/25 23:59:59
Done.
|
| + databases_[object_id] = new RendererWebIDBDatabaseImpl(object_id); |
| + callbacks->onSuccess(databases_[object_id]); |
| pending_callbacks_.Remove(response_id); |
| } |
| @@ -666,6 +683,15 @@ void IndexedDBDispatcher::OnSuccessCursorPrefetch( |
| pending_callbacks_.Remove(response_id); |
| } |
| +void IndexedDBDispatcher::OnIntBlocked(int32 thread_id, |
| + int32 response_id, |
| + int64 existing_version) { |
| + DCHECK_EQ(thread_id, CurrentWorkerId()); |
| + WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
| + DCHECK(callbacks); |
| + callbacks->onBlocked(existing_version); |
|
jsbell
2012/07/25 22:12:16
Will the non-int OnBlocked plumbing be removed bef
dgrogan
2012/07/25 23:59:59
Probably both in parallel for a while.
(Wondering
|
| +} |
| + |
| void IndexedDBDispatcher::OnBlocked(int32 thread_id, int32 response_id) { |
| DCHECK_EQ(thread_id, CurrentWorkerId()); |
| WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
| @@ -703,6 +729,20 @@ void IndexedDBDispatcher::OnComplete(int32 thread_id, int32 transaction_id) { |
| pending_transaction_callbacks_.Remove(transaction_id); |
| } |
| +void IndexedDBDispatcher::OnIntVersionChange(int32 thread_id, |
| + int32 database_id, |
| + int64 old_version, |
| + int64 new_version) { |
| + DCHECK_EQ(thread_id, CurrentWorkerId()); |
| + WebIDBDatabaseCallbacks* callbacks = |
| + pending_database_callbacks_.Lookup(database_id); |
| + // callbacks would be NULL if a versionchange event is received after close |
| + // has been called. |
| + if (!callbacks) |
| + return; |
| + callbacks->onVersionChange(old_version, new_version); |
| +} |
| + |
| void IndexedDBDispatcher::OnVersionChange(int32 thread_id, |
| int32 database_id, |
| const string16& newVersion) { |
| @@ -716,6 +756,21 @@ void IndexedDBDispatcher::OnVersionChange(int32 thread_id, |
| callbacks->onVersionChange(newVersion); |
| } |
| +void IndexedDBDispatcher::OnUpgradeNeeded(int32 thread_id, |
| + int32 response_id, |
| + int32 transaction_id, |
| + int32 database_id, |
| + int64 old_version) { |
| + DCHECK_EQ(thread_id, CurrentWorkerId()); |
| + WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
| + DCHECK(callbacks); |
| + DCHECK(!databases_.count(database_id)); |
| + databases_[database_id] = new RendererWebIDBDatabaseImpl(database_id); |
| + callbacks->onUpgradeNeeded(old_version, |
| + new RendererWebIDBTransactionImpl(transaction_id), |
| + databases_[database_id]); |
| +} |
| + |
| void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { |
| typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; |
| for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |