summaryrefslogtreecommitdiffstats
path: root/content/common/indexed_db
diff options
context:
space:
mode:
authordgrogan@chromium.org <dgrogan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-24 17:36:19 +0000
committerdgrogan@chromium.org <dgrogan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-24 17:36:19 +0000
commit5d9d42783a607ce7bcb995060c222224280fe081 (patch)
treea0b71a58a29e7364a89fe4c210415b530eaeaca1 /content/common/indexed_db
parenta26bfe4e6bd26704e8255808efcc346919964fbf (diff)
downloadchromium_src-5d9d42783a607ce7bcb995060c222224280fe081.zip
chromium_src-5d9d42783a607ce7bcb995060c222224280fe081.tar.gz
chromium_src-5d9d42783a607ce7bcb995060c222224280fe081.tar.bz2
Use SyncMessageFilter when sending IDB ipc messages from a worker.
Currently ChildThread::current()->Send is used, which isn't thread safe. BUG=113717 TEST= Review URL: http://codereview.chromium.org/9430019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123498 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common/indexed_db')
-rw-r--r--content/common/indexed_db/indexed_db_dispatcher.cc9
-rw-r--r--content/common/indexed_db/indexed_db_dispatcher.h3
-rw-r--r--content/common/indexed_db/proxy_webidbcursor_impl.cc4
-rw-r--r--content/common/indexed_db/proxy_webidbdatabase_impl.cc14
-rw-r--r--content/common/indexed_db/proxy_webidbindex_impl.cc12
-rw-r--r--content/common/indexed_db/proxy_webidbobjectstore_impl.cc14
-rw-r--r--content/common/indexed_db/proxy_webidbtransaction_impl.cc10
7 files changed, 36 insertions, 30 deletions
diff --git a/content/common/indexed_db/indexed_db_dispatcher.cc b/content/common/indexed_db/indexed_db_dispatcher.cc
index 86ac318b..827fd94 100644
--- a/content/common/indexed_db/indexed_db_dispatcher.cc
+++ b/content/common/indexed_db/indexed_db_dispatcher.cc
@@ -97,8 +97,13 @@ void IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) {
DCHECK(handled);
}
-void IndexedDBDispatcher::Send(IPC::Message* msg) {
- ChildThread::current()->Send(msg);
+bool IndexedDBDispatcher::Send(IPC::Message* msg) {
+ if (CurrentWorkerId()) {
+ scoped_refptr<IPC::SyncMessageFilter> filter(
+ ChildThread::current()->sync_message_filter());
+ return filter->Send(msg);
+ }
+ return ChildThread::current()->Send(msg);
}
void IndexedDBDispatcher::RequestIDBCursorUpdate(
diff --git a/content/common/indexed_db/indexed_db_dispatcher.h b/content/common/indexed_db/indexed_db_dispatcher.h
index 8d80047..f4b0b4b 100644
--- a/content/common/indexed_db/indexed_db_dispatcher.h
+++ b/content/common/indexed_db/indexed_db_dispatcher.h
@@ -11,6 +11,7 @@
#include "base/id_map.h"
#include "base/nullable_string16.h"
+#include "ipc/ipc_sync_message_filter.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebExceptionCode.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h"
@@ -51,7 +52,7 @@ class IndexedDBDispatcher : public webkit_glue::WorkerTaskRunner::Observer {
virtual void OnWorkerRunLoopStopped() OVERRIDE;
void OnMessageReceived(const IPC::Message& msg);
- void Send(IPC::Message* msg);
+ static bool Send(IPC::Message* msg);
void RequestIDBFactoryGetDatabaseNames(
WebKit::WebIDBCallbacks* callbacks,
diff --git a/content/common/indexed_db/proxy_webidbcursor_impl.cc b/content/common/indexed_db/proxy_webidbcursor_impl.cc
index a76878c..f043356 100644
--- a/content/common/indexed_db/proxy_webidbcursor_impl.cc
+++ b/content/common/indexed_db/proxy_webidbcursor_impl.cc
@@ -26,7 +26,7 @@ RendererWebIDBCursorImpl::~RendererWebIDBCursorImpl() {
// object since inside WebKit, they hold a reference to the object wich owns
// this object. But, if that ever changed, then we'd need to invalidate
// any such pointers.
- ChildThread::current()->Send(new IndexedDBHostMsg_CursorDestroyed(
+ IndexedDBDispatcher::Send(new IndexedDBHostMsg_CursorDestroyed(
idb_cursor_id_));
IndexedDBDispatcher* dispatcher =
IndexedDBDispatcher::ThreadSpecificInstance();
@@ -35,7 +35,7 @@ RendererWebIDBCursorImpl::~RendererWebIDBCursorImpl() {
unsigned short RendererWebIDBCursorImpl::direction() const {
int direction;
- ChildThread::current()->Send(
+ IndexedDBDispatcher::Send(
new IndexedDBHostMsg_CursorDirection(idb_cursor_id_, &direction));
return direction;
}
diff --git a/content/common/indexed_db/proxy_webidbdatabase_impl.cc b/content/common/indexed_db/proxy_webidbdatabase_impl.cc
index 42df7671..c1e4078 100644
--- a/content/common/indexed_db/proxy_webidbdatabase_impl.cc
+++ b/content/common/indexed_db/proxy_webidbdatabase_impl.cc
@@ -32,27 +32,27 @@ RendererWebIDBDatabaseImpl::~RendererWebIDBDatabaseImpl() {
// object since inside WebKit, they hold a reference to the object which owns
// this object. But, if that ever changed, then we'd need to invalidate
// any such pointers.
- ChildThread::current()->Send(new IndexedDBHostMsg_DatabaseDestroyed(
+ IndexedDBDispatcher::Send(new IndexedDBHostMsg_DatabaseDestroyed(
idb_database_id_));
}
WebString RendererWebIDBDatabaseImpl::name() const {
string16 result;
- ChildThread::current()->Send(
+ IndexedDBDispatcher::Send(
new IndexedDBHostMsg_DatabaseName(idb_database_id_, &result));
return result;
}
WebString RendererWebIDBDatabaseImpl::version() const {
string16 result;
- ChildThread::current()->Send(
+ IndexedDBDispatcher::Send(
new IndexedDBHostMsg_DatabaseVersion(idb_database_id_, &result));
return result;
}
WebDOMStringList RendererWebIDBDatabaseImpl::objectStoreNames() const {
std::vector<string16> result;
- ChildThread::current()->Send(
+ IndexedDBDispatcher::Send(
new IndexedDBHostMsg_DatabaseObjectStoreNames(idb_database_id_, &result));
WebDOMStringList webResult;
for (std::vector<string16>::const_iterator it = result.begin();
@@ -76,7 +76,7 @@ WebKit::WebIDBObjectStore* RendererWebIDBDatabaseImpl::createObjectStore(
params.idb_database_id = idb_database_id_;
int object_store;
- ChildThread::current()->Send(
+ IndexedDBDispatcher::Send(
new IndexedDBHostMsg_DatabaseCreateObjectStore(
params, &object_store, &ec));
if (!object_store)
@@ -88,7 +88,7 @@ void RendererWebIDBDatabaseImpl::deleteObjectStore(
const WebString& name,
const WebIDBTransaction& transaction,
WebExceptionCode& ec) {
- ChildThread::current()->Send(
+ IndexedDBDispatcher::Send(
new IndexedDBHostMsg_DatabaseDeleteObjectStore(
idb_database_id_, name,
IndexedDBDispatcher::TransactionId(transaction), &ec));
@@ -114,7 +114,7 @@ WebKit::WebIDBTransaction* RendererWebIDBDatabaseImpl::transaction(
object_stores.push_back(names.item(i));
int transaction_id;
- ChildThread::current()->Send(new IndexedDBHostMsg_DatabaseTransaction(
+ IndexedDBDispatcher::Send(new IndexedDBHostMsg_DatabaseTransaction(
WorkerTaskRunner::Instance()->CurrentWorkerId(),
idb_database_id_, object_stores, mode, &transaction_id, &ec));
if (!transaction_id)
diff --git a/content/common/indexed_db/proxy_webidbindex_impl.cc b/content/common/indexed_db/proxy_webidbindex_impl.cc
index 91bf66a..af9034d 100644
--- a/content/common/indexed_db/proxy_webidbindex_impl.cc
+++ b/content/common/indexed_db/proxy_webidbindex_impl.cc
@@ -25,41 +25,41 @@ RendererWebIDBIndexImpl::~RendererWebIDBIndexImpl() {
// object since inside WebKit, they hold a reference to the object wich owns
// this object. But, if that ever changed, then we'd need to invalidate
// any such pointers.
- ChildThread::current()->Send(new IndexedDBHostMsg_IndexDestroyed(
+ IndexedDBDispatcher::Send(new IndexedDBHostMsg_IndexDestroyed(
idb_index_id_));
}
WebString RendererWebIDBIndexImpl::name() const {
string16 result;
- ChildThread::current()->Send(
+ IndexedDBDispatcher::Send(
new IndexedDBHostMsg_IndexName(idb_index_id_, &result));
return result;
}
WebString RendererWebIDBIndexImpl::storeName() const {
string16 result;
- ChildThread::current()->Send(
+ IndexedDBDispatcher::Send(
new IndexedDBHostMsg_IndexStoreName(idb_index_id_, &result));
return result;
}
WebString RendererWebIDBIndexImpl::keyPath() const {
NullableString16 result;
- ChildThread::current()->Send(
+ IndexedDBDispatcher::Send(
new IndexedDBHostMsg_IndexKeyPath(idb_index_id_, &result));
return result;
}
bool RendererWebIDBIndexImpl::unique() const {
bool result;
- ChildThread::current()->Send(
+ IndexedDBDispatcher::Send(
new IndexedDBHostMsg_IndexUnique(idb_index_id_, &result));
return result;
}
bool RendererWebIDBIndexImpl::multiEntry() const {
bool result;
- ChildThread::current()->Send(
+ IndexedDBDispatcher::Send(
new IndexedDBHostMsg_IndexMultiEntry(idb_index_id_, &result));
return result;
}
diff --git a/content/common/indexed_db/proxy_webidbobjectstore_impl.cc b/content/common/indexed_db/proxy_webidbobjectstore_impl.cc
index 5340db6..1259bbc6 100644
--- a/content/common/indexed_db/proxy_webidbobjectstore_impl.cc
+++ b/content/common/indexed_db/proxy_webidbobjectstore_impl.cc
@@ -38,27 +38,27 @@ RendererWebIDBObjectStoreImpl::~RendererWebIDBObjectStoreImpl() {
// object since inside WebKit, they hold a reference to the object wich owns
// this object. But, if that ever changed, then we'd need to invalidate
// any such pointers.
- ChildThread::current()->Send(
+ IndexedDBDispatcher::Send(
new IndexedDBHostMsg_ObjectStoreDestroyed(idb_object_store_id_));
}
WebString RendererWebIDBObjectStoreImpl::name() const {
string16 result;
- ChildThread::current()->Send(
+ IndexedDBDispatcher::Send(
new IndexedDBHostMsg_ObjectStoreName(idb_object_store_id_, &result));
return result;
}
WebString RendererWebIDBObjectStoreImpl::keyPath() const {
NullableString16 result;
- ChildThread::current()->Send(
+ IndexedDBDispatcher::Send(
new IndexedDBHostMsg_ObjectStoreKeyPath(idb_object_store_id_, &result));
return result;
}
WebDOMStringList RendererWebIDBObjectStoreImpl::indexNames() const {
std::vector<string16> result;
- ChildThread::current()->Send(
+ IndexedDBDispatcher::Send(
new IndexedDBHostMsg_ObjectStoreIndexNames(
idb_object_store_id_, &result));
WebDOMStringList web_result;
@@ -143,7 +143,7 @@ WebIDBIndex* RendererWebIDBObjectStoreImpl::createIndex(
params.idb_object_store_id = idb_object_store_id_;
int32 index_id;
- ChildThread::current()->Send(
+ IndexedDBDispatcher::Send(
new IndexedDBHostMsg_ObjectStoreCreateIndex(params, &index_id, &ec));
if (!index_id)
return NULL;
@@ -154,7 +154,7 @@ WebIDBIndex* RendererWebIDBObjectStoreImpl::index(
const WebString& name,
WebExceptionCode& ec) {
int32 idb_index_id;
- ChildThread::current()->Send(
+ IndexedDBDispatcher::Send(
new IndexedDBHostMsg_ObjectStoreIndex(idb_object_store_id_, name,
&idb_index_id, &ec));
if (!idb_index_id)
@@ -166,7 +166,7 @@ void RendererWebIDBObjectStoreImpl::deleteIndex(
const WebString& name,
const WebIDBTransaction& transaction,
WebExceptionCode& ec) {
- ChildThread::current()->Send(
+ IndexedDBDispatcher::Send(
new IndexedDBHostMsg_ObjectStoreDeleteIndex(
idb_object_store_id_, name,
IndexedDBDispatcher::TransactionId(transaction), &ec));
diff --git a/content/common/indexed_db/proxy_webidbtransaction_impl.cc b/content/common/indexed_db/proxy_webidbtransaction_impl.cc
index 9e23fa5..2a08b02 100644
--- a/content/common/indexed_db/proxy_webidbtransaction_impl.cc
+++ b/content/common/indexed_db/proxy_webidbtransaction_impl.cc
@@ -26,14 +26,14 @@ RendererWebIDBTransactionImpl::~RendererWebIDBTransactionImpl() {
// object since inside WebKit, they hold a reference to the object wich owns
// this object. But, if that ever changed, then we'd need to invalidate
// any such pointers.
- ChildThread::current()->Send(new IndexedDBHostMsg_TransactionDestroyed(
+ IndexedDBDispatcher::Send(new IndexedDBHostMsg_TransactionDestroyed(
idb_transaction_id_));
}
int RendererWebIDBTransactionImpl::mode() const
{
int mode;
- ChildThread::current()->Send(new IndexedDBHostMsg_TransactionMode(
+ IndexedDBDispatcher::Send(new IndexedDBHostMsg_TransactionMode(
idb_transaction_id_, &mode));
return mode;
}
@@ -43,7 +43,7 @@ WebIDBObjectStore* RendererWebIDBTransactionImpl::objectStore(
WebKit::WebExceptionCode& ec)
{
int object_store_id;
- ChildThread::current()->Send(
+ IndexedDBDispatcher::Send(
new IndexedDBHostMsg_TransactionObjectStore(
idb_transaction_id_, name, &object_store_id, &ec));
if (!object_store_id)
@@ -53,13 +53,13 @@ WebIDBObjectStore* RendererWebIDBTransactionImpl::objectStore(
void RendererWebIDBTransactionImpl::abort()
{
- ChildThread::current()->Send(new IndexedDBHostMsg_TransactionAbort(
+ IndexedDBDispatcher::Send(new IndexedDBHostMsg_TransactionAbort(
idb_transaction_id_));
}
void RendererWebIDBTransactionImpl::didCompleteTaskEvents()
{
- ChildThread::current()->Send(
+ IndexedDBDispatcher::Send(
new IndexedDBHostMsg_TransactionDidCompleteTaskEvents(
idb_transaction_id_));
}