Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Unified Diff: content/renderer/indexed_db_dispatcher.cc

Issue 8747002: Dispatch IndexedDB IPC messages to worker threads (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/indexed_db_dispatcher.cc
diff --git a/content/renderer/indexed_db_dispatcher.cc b/content/renderer/indexed_db_dispatcher.cc
index 915275f7652970871caf3e16b6c8c411ab62bc3b..0de9a60c8371a4e4b5895ffab27bbd7d8957b84d 100644
--- a/content/renderer/indexed_db_dispatcher.cc
+++ b/content/renderer/indexed_db_dispatcher.cc
@@ -31,13 +31,16 @@ using WebKit::WebIDBDatabaseError;
using WebKit::WebIDBTransaction;
using WebKit::WebIDBTransactionCallbacks;
-IndexedDBDispatcher::IndexedDBDispatcher() {
+IndexedDBDispatcher::IndexedDBDispatcher(IndexedDBMessageFilter* filter) :
+ pending_callbacks_(filter),
+ pending_transaction_callbacks_(filter),
+ pending_database_callbacks_(filter) {
}
IndexedDBDispatcher::~IndexedDBDispatcher() {
}
-bool IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) {
+void IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcher, msg)
IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBCursor,
@@ -62,7 +65,13 @@ bool IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) {
OnVersionChange)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
- return handled;
+ // If a message gets here, IndexedDBMessageFilter already determined that it
+ // is an IndexedDB message.
+ DCHECK(handled);
+}
+
+void IndexedDBDispatcher::Send(IPC::Message* msg) {
+ ChildThread::current()->Send(msg);
}
void IndexedDBDispatcher::RequestIDBCursorUpdate(
@@ -73,7 +82,7 @@ void IndexedDBDispatcher::RequestIDBCursorUpdate(
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
int32 response_id = pending_callbacks_.Add(callbacks.release());
- RenderThreadImpl::current()->Send(
+ Send(
new IndexedDBHostMsg_CursorUpdate(idb_cursor_id, response_id, value, ec));
if (*ec)
pending_callbacks_.Remove(response_id);
@@ -87,7 +96,7 @@ void IndexedDBDispatcher::RequestIDBCursorContinue(
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
int32 response_id = pending_callbacks_.Add(callbacks.release());
- RenderThreadImpl::current()->Send(
+ Send(
new IndexedDBHostMsg_CursorContinue(idb_cursor_id, response_id, key, ec));
if (*ec)
pending_callbacks_.Remove(response_id);
@@ -100,8 +109,7 @@ void IndexedDBDispatcher::RequestIDBCursorDelete(
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
int32 response_id = pending_callbacks_.Add(callbacks.release());
- RenderThreadImpl::current()->Send(
- new IndexedDBHostMsg_CursorDelete(idb_cursor_id, response_id, ec));
+ Send(new IndexedDBHostMsg_CursorDelete(idb_cursor_id, response_id, ec));
if (*ec)
pending_callbacks_.Remove(response_id);
}
@@ -113,17 +121,11 @@ void IndexedDBDispatcher::RequestIDBFactoryOpen(
WebFrame* web_frame) {
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
- if (!web_frame)
- return; // We must be shutting down.
- RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view());
- if (!render_view)
- return; // We must be shutting down.
-
IndexedDBHostMsg_FactoryOpen_Params params;
params.response_id = pending_callbacks_.Add(callbacks.release());
params.origin = origin;
params.name = name;
- RenderThreadImpl::current()->Send(new IndexedDBHostMsg_FactoryOpen(params));
+ Send(new IndexedDBHostMsg_FactoryOpen(params));
}
void IndexedDBDispatcher::RequestIDBFactoryGetDatabaseNames(
@@ -141,8 +143,7 @@ void IndexedDBDispatcher::RequestIDBFactoryGetDatabaseNames(
IndexedDBHostMsg_FactoryGetDatabaseNames_Params params;
params.response_id = pending_callbacks_.Add(callbacks.release());
params.origin = origin;
- RenderThreadImpl::current()->Send(
- new IndexedDBHostMsg_FactoryGetDatabaseNames(params));
+ Send(new IndexedDBHostMsg_FactoryGetDatabaseNames(params));
}
void IndexedDBDispatcher::RequestIDBFactoryDeleteDatabase(
@@ -162,24 +163,21 @@ void IndexedDBDispatcher::RequestIDBFactoryDeleteDatabase(
params.response_id = pending_callbacks_.Add(callbacks.release());
params.origin = origin;
params.name = name;
- RenderThreadImpl::current()->Send(
- new IndexedDBHostMsg_FactoryDeleteDatabase(params));
+ Send(new IndexedDBHostMsg_FactoryDeleteDatabase(params));
}
void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) {
- RenderThreadImpl::current()->Send(
- new IndexedDBHostMsg_DatabaseClose(idb_database_id));
+ Send(new IndexedDBHostMsg_DatabaseClose(idb_database_id));
pending_database_callbacks_.Remove(idb_database_id);
}
- void IndexedDBDispatcher::RequestIDBDatabaseOpen(
+void IndexedDBDispatcher::RequestIDBDatabaseOpen(
WebIDBDatabaseCallbacks* callbacks_ptr,
int32 idb_database_id) {
scoped_ptr<WebIDBDatabaseCallbacks> callbacks(callbacks_ptr);
- int32 response_id = pending_database_callbacks_.Add(callbacks.release());
- RenderThreadImpl::current()->Send(new IndexedDBHostMsg_DatabaseOpen(
- response_id, idb_database_id));
+ pending_database_callbacks_.AddWithID(callbacks.release(), idb_database_id);
+ Send(new IndexedDBHostMsg_DatabaseOpen(idb_database_id, idb_database_id));
}
void IndexedDBDispatcher::RequestIDBDatabaseSetVersion(
@@ -190,9 +188,8 @@ void IndexedDBDispatcher::RequestIDBDatabaseSetVersion(
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
int32 response_id = pending_callbacks_.Add(callbacks.release());
- RenderThreadImpl::current()->Send(
- new IndexedDBHostMsg_DatabaseSetVersion(idb_database_id, response_id,
- version, ec));
+ Send(new IndexedDBHostMsg_DatabaseSetVersion(idb_database_id, response_id,
+ version, ec));
if (*ec)
pending_callbacks_.Remove(response_id);
}
@@ -214,8 +211,7 @@ void IndexedDBDispatcher::RequestIDBIndexOpenObjectCursor(
params.direction = direction;
params.idb_index_id = idb_index_id;
params.transaction_id = TransactionId(transaction);
- RenderThreadImpl::current()->Send(
- new IndexedDBHostMsg_IndexOpenObjectCursor(params, ec));
+ Send(new IndexedDBHostMsg_IndexOpenObjectCursor(params, ec));
if (*ec)
pending_callbacks_.Remove(params.response_id);
}
@@ -239,8 +235,7 @@ void IndexedDBDispatcher::RequestIDBIndexOpenKeyCursor(
params.direction = direction;
params.idb_index_id = idb_index_id;
params.transaction_id = TransactionId(transaction);
- RenderThreadImpl::current()->Send(
- new IndexedDBHostMsg_IndexOpenKeyCursor(params, ec));
+ Send(new IndexedDBHostMsg_IndexOpenKeyCursor(params, ec));
if (*ec)
pending_callbacks_.Remove(params.response_id);
}
@@ -253,10 +248,8 @@ void IndexedDBDispatcher::RequestIDBIndexGetObject(
WebExceptionCode* ec) {
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
int32 response_id = pending_callbacks_.Add(callbacks.release());
- RenderThreadImpl::current()->Send(
- new IndexedDBHostMsg_IndexGetObject(
- idb_index_id, response_id, key,
- TransactionId(transaction), ec));
+ Send(new IndexedDBHostMsg_IndexGetObject(idb_index_id, response_id, key,
+ TransactionId(transaction), ec));
if (*ec)
pending_callbacks_.Remove(response_id);
}
@@ -269,10 +262,9 @@ void IndexedDBDispatcher::RequestIDBIndexGetKey(
WebExceptionCode* ec) {
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
int32 response_id = pending_callbacks_.Add(callbacks.release());
- RenderThreadImpl::current()->Send(
- new IndexedDBHostMsg_IndexGetKey(
- idb_index_id, response_id, key,
- TransactionId(transaction), ec));
+ Send(new IndexedDBHostMsg_IndexGetKey(
+ idb_index_id, response_id, key,
+ TransactionId(transaction), ec));
if (*ec)
pending_callbacks_.Remove(response_id);
}
@@ -286,10 +278,9 @@ void IndexedDBDispatcher::RequestIDBObjectStoreGet(
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
int32 response_id = pending_callbacks_.Add(callbacks.release());
- RenderThreadImpl::current()->Send(
- new IndexedDBHostMsg_ObjectStoreGet(
- idb_object_store_id, response_id,
- key, TransactionId(transaction), ec));
+ Send(new IndexedDBHostMsg_ObjectStoreGet(
+ idb_object_store_id, response_id,
+ key, TransactionId(transaction), ec));
if (*ec)
pending_callbacks_.Remove(response_id);
}
@@ -310,8 +301,7 @@ void IndexedDBDispatcher::RequestIDBObjectStorePut(
params.key = key;
params.put_mode = put_mode;
params.transaction_id = TransactionId(transaction);
- RenderThreadImpl::current()->Send(new IndexedDBHostMsg_ObjectStorePut(
- params, ec));
+ Send(new IndexedDBHostMsg_ObjectStorePut(params, ec));
if (*ec)
pending_callbacks_.Remove(params.response_id);
}
@@ -325,10 +315,9 @@ void IndexedDBDispatcher::RequestIDBObjectStoreDelete(
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
int32 response_id = pending_callbacks_.Add(callbacks.release());
- RenderThreadImpl::current()->Send(
- new IndexedDBHostMsg_ObjectStoreDelete(
- idb_object_store_id, response_id,
- key, TransactionId(transaction), ec));
+ Send(new IndexedDBHostMsg_ObjectStoreDelete(
+ idb_object_store_id, response_id,
+ key, TransactionId(transaction), ec));
if (*ec)
pending_callbacks_.Remove(response_id);
}
@@ -341,10 +330,9 @@ void IndexedDBDispatcher::RequestIDBObjectStoreClear(
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
int32 response_id = pending_callbacks_.Add(callbacks.release());
- RenderThreadImpl::current()->Send(
- new IndexedDBHostMsg_ObjectStoreClear(
- idb_object_store_id, response_id,
- TransactionId(transaction), ec));
+ Send(new IndexedDBHostMsg_ObjectStoreClear(
+ idb_object_store_id, response_id,
+ TransactionId(transaction), ec));
if (*ec)
pending_callbacks_.Remove(response_id);
}
@@ -366,8 +354,7 @@ void IndexedDBDispatcher::RequestIDBObjectStoreOpenCursor(
params.direction = direction;
params.idb_object_store_id = idb_object_store_id;
params.transaction_id = TransactionId(transaction);
- RenderThreadImpl::current()->Send(
- new IndexedDBHostMsg_ObjectStoreOpenCursor(params, ec));
+ Send(new IndexedDBHostMsg_ObjectStoreOpenCursor(params, ec));
if (*ec)
pending_callbacks_.Remove(params.response_id);
}

Powered by Google App Engine
This is Rietveld 408576698