summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-06 21:27:17 +0000
committerjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-06 21:27:17 +0000
commit6450c6e0b529029790ca3ae00aeae89f4340ff51 (patch)
treec2405188e7bb6aeb7fc014a6661a751db1f72086
parent5a90bd13b08d53364929beacafcfa8640ba167b1 (diff)
downloadchromium_src-6450c6e0b529029790ca3ae00aeae89f4340ff51.zip
chromium_src-6450c6e0b529029790ca3ae00aeae89f4340ff51.tar.gz
chromium_src-6450c6e0b529029790ca3ae00aeae89f4340ff51.tar.bz2
Fix up the IndexedDB plumbing layers to match the latest WebKit code.
Landing http://codereview.chromium.org/3550015/show TEST=none BUG=none Review URL: http://codereview.chromium.org/3575019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61709 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/in_process_webkit/indexed_db_callbacks.h29
-rw-r--r--chrome/browser/in_process_webkit/indexed_db_dispatcher_host.cc165
-rw-r--r--chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h36
-rw-r--r--chrome/common/render_messages_internal.h63
-rw-r--r--chrome/common/render_messages_params.cc24
-rw-r--r--chrome/common/render_messages_params.h12
-rw-r--r--chrome/renderer/indexed_db_dispatcher.cc172
-rw-r--r--chrome/renderer/indexed_db_dispatcher.h53
-rw-r--r--chrome/renderer/renderer_webidbdatabase_impl.cc38
-rw-r--r--chrome/renderer/renderer_webidbdatabase_impl.h11
-rw-r--r--chrome/renderer/renderer_webidbindex_impl.cc12
-rw-r--r--chrome/renderer/renderer_webidbindex_impl.h14
-rw-r--r--chrome/renderer/renderer_webidbobjectstore_impl.cc53
-rw-r--r--chrome/renderer/renderer_webidbobjectstore_impl.h11
-rw-r--r--chrome/renderer/renderer_webidbtransaction_impl.cc15
-rw-r--r--chrome/renderer/renderer_webidbtransaction_impl.h3
-rw-r--r--webkit/glue/idb_bindings.cc26
17 files changed, 406 insertions, 331 deletions
diff --git a/chrome/browser/in_process_webkit/indexed_db_callbacks.h b/chrome/browser/in_process_webkit/indexed_db_callbacks.h
index cc90dd8..1c6ed37 100644
--- a/chrome/browser/in_process_webkit/indexed_db_callbacks.h
+++ b/chrome/browser/in_process_webkit/indexed_db_callbacks.h
@@ -14,8 +14,9 @@
#include "chrome/common/serialized_script_value.h"
#include "third_party/WebKit/WebKit/chromium/public/WebIDBCallbacks.h"
#include "third_party/WebKit/WebKit/chromium/public/WebIDBCursor.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebIDBTransactionCallbacks.h"
#include "third_party/WebKit/WebKit/chromium/public/WebIDBDatabaseError.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebIDBTransaction.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebIDBTransactionCallbacks.h"
// Template magic to figure out what message to send to the renderer based on
// which (overloaded) onSuccess method we expect to be called.
@@ -29,6 +30,9 @@ template <> struct WebIDBToMsgHelper<WebKit::WebIDBIndex> {
template <> struct WebIDBToMsgHelper<WebKit::WebIDBObjectStore> {
typedef ViewMsg_IDBCallbacksSuccessIDBObjectStore MsgType;
};
+template <> struct WebIDBToMsgHelper<WebKit::WebIDBTransaction> {
+ typedef ViewMsg_IDBCallbacksSuccessIDBTransaction MsgType;
+};
// The code the following two classes share.
class IndexedDBCallbacksBase : public WebKit::WebIDBCallbacks {
@@ -88,7 +92,7 @@ class IndexedDBCallbacks<WebKit::WebIDBCursor>
virtual void onSuccess(WebKit::WebIDBCursor* idb_object) {
int32 object_id = dispatcher_host()->Add(idb_object);
dispatcher_host()->Send(
- new ViewMsg_IDBCallbackSuccessOpenCursor(response_id(), object_id));
+ new ViewMsg_IDBCallbacksSuccessIDBCursor(response_id(), object_id));
}
virtual void onSuccess() {
@@ -161,18 +165,25 @@ class IndexedDBCallbacks<void> : public IndexedDBCallbacksBase {
class IndexedDBTransactionCallbacks
: public WebKit::WebIDBTransactionCallbacks {
public:
- IndexedDBTransactionCallbacks(
- IndexedDBDispatcherHost* dispatcher_host, int transaction_id)
- : dispatcher_host_(dispatcher_host), transaction_id_(transaction_id) {
+ IndexedDBTransactionCallbacks(IndexedDBDispatcherHost* dispatcher_host,
+ int transaction_id)
+ : dispatcher_host_(dispatcher_host),
+ transaction_id_(transaction_id) {
}
virtual void onAbort() {
- dispatcher_host_->Send(new ViewMsg_IDBTransactionCallbacksAbort(
- transaction_id_));
+ dispatcher_host_->Send(
+ new ViewMsg_IDBTransactionCallbacksAbort(transaction_id_));
+ }
+
+ virtual void onComplete() {
+ dispatcher_host_->Send(
+ new ViewMsg_IDBTransactionCallbacksComplete(transaction_id_));
}
- virtual int id() const {
- return transaction_id_;
+ virtual void onTimeout() {
+ dispatcher_host_->Send(
+ new ViewMsg_IDBTransactionCallbacksTimeout(transaction_id_));
}
private:
diff --git a/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.cc b/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.cc
index 626416c..a015032a 100644
--- a/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.cc
+++ b/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.cc
@@ -46,6 +46,16 @@ using WebKit::WebSecurityOrigin;
using WebKit::WebSerializedScriptValue;
using WebKit::WebVector;
+namespace {
+
+template <class T>
+void DeleteOnWebKitThread(T* obj) {
+ if (!ChromeThread::DeleteSoon(ChromeThread::WEBKIT, FROM_HERE, obj))
+ delete obj;
+}
+
+}
+
IndexedDBDispatcherHost::IndexedDBDispatcherHost(
IPC::Message::Sender* sender, Profile* profile)
: sender_(sender),
@@ -67,6 +77,11 @@ IndexedDBDispatcherHost::IndexedDBDispatcherHost(
}
IndexedDBDispatcherHost::~IndexedDBDispatcherHost() {
+ DeleteOnWebKitThread(database_dispatcher_host_.release());
+ DeleteOnWebKitThread(index_dispatcher_host_.release());
+ DeleteOnWebKitThread(object_store_dispatcher_host_.release());
+ DeleteOnWebKitThread(cursor_dispatcher_host_.release());
+ DeleteOnWebKitThread(transaction_dispatcher_host_.release());
}
void IndexedDBDispatcherHost::Init(int process_id,
@@ -127,9 +142,9 @@ bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message) {
case ViewHostMsg_IDBIndexUnique::ID:
case ViewHostMsg_IDBIndexDestroyed::ID:
case ViewHostMsg_IDBIndexOpenObjectCursor::ID:
- case ViewHostMsg_IDBIndexOpenCursor::ID:
+ case ViewHostMsg_IDBIndexOpenKeyCursor::ID:
case ViewHostMsg_IDBIndexGetObject::ID:
- case ViewHostMsg_IDBIndexGet::ID:
+ case ViewHostMsg_IDBIndexGetKey::ID:
case ViewHostMsg_IDBObjectStoreName::ID:
case ViewHostMsg_IDBObjectStoreKeyPath::ID:
case ViewHostMsg_IDBObjectStoreIndexNames::ID:
@@ -142,6 +157,7 @@ bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message) {
case ViewHostMsg_IDBObjectStoreOpenCursor::ID:
case ViewHostMsg_IDBObjectStoreDestroyed::ID:
case ViewHostMsg_IDBTransactionAbort::ID:
+ case ViewHostMsg_IDBTransactionMode::ID:
case ViewHostMsg_IDBTransactionDestroyed::ID:
case ViewHostMsg_IDBTransactionDidCompleteTaskEvents::ID:
case ViewHostMsg_IDBTransactionObjectStore::ID:
@@ -218,16 +234,21 @@ int32 IndexedDBDispatcherHost::Add(WebIDBDatabase* idb_database) {
}
int32 IndexedDBDispatcherHost::Add(WebIDBIndex* idb_index) {
+ if (!idb_index)
+ return 0;
return index_dispatcher_host_->map_.Add(idb_index);
}
int32 IndexedDBDispatcherHost::Add(WebIDBObjectStore* idb_object_store) {
+ if (!idb_object_store)
+ return 0;
return object_store_dispatcher_host_->map_.Add(idb_object_store);
}
-void IndexedDBDispatcherHost::Add(WebIDBTransaction* idb_transaction) {
- transaction_dispatcher_host_->map_.AddWithID(
- idb_transaction, idb_transaction->id());
+int32 IndexedDBDispatcherHost::Add(WebIDBTransaction* idb_transaction) {
+ int32 id = transaction_dispatcher_host_->map_.Add(idb_transaction);
+ idb_transaction->setCallbacks(new IndexedDBTransactionCallbacks(this, id));
+ return id;
}
void IndexedDBDispatcherHost::OnIDBFactoryOpen(
@@ -320,6 +341,7 @@ void IndexedDBDispatcherHost::DestroyObject(
IndexedDBDispatcherHost::DatabaseDispatcherHost::DatabaseDispatcherHost(
IndexedDBDispatcherHost* parent)
: parent_(parent) {
+ map_.set_check_on_null_data(true);
}
IndexedDBDispatcherHost::DatabaseDispatcherHost::~DatabaseDispatcherHost() {
@@ -336,8 +358,8 @@ bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived(
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBDatabaseVersion, OnVersion)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBDatabaseObjectStores,
OnObjectStores)
- IPC_MESSAGE_HANDLER(ViewHostMsg_IDBDatabaseCreateObjectStore,
- OnCreateObjectStore)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBDatabaseCreateObjectStore,
+ OnCreateObjectStore)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBDatabaseObjectStore,
OnObjectStore)
IPC_MESSAGE_HANDLER(ViewHostMsg_IDBDatabaseRemoveObjectStore,
@@ -397,16 +419,24 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnObjectStores(
}
void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStore(
- const ViewHostMsg_IDBDatabaseCreateObjectStore_Params& params) {
+ const ViewHostMsg_IDBDatabaseCreateObjectStore_Params& params,
+ IPC::Message* reply_msg) {
+
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess(
&map_, params.idb_database_id_, NULL,
ViewHostMsg_IDBDatabaseCreateObjectStore::ID);
- if (!idb_database)
+ WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
+ &parent_->transaction_dispatcher_host_->map_, params.transaction_id_,
+ NULL, ViewHostMsg_IDBDatabaseCreateObjectStore::ID);
+ if (!idb_database || !idb_transaction)
return;
- idb_database->createObjectStore(
- params.name_, params.key_path_, params.auto_increment_,
- new IndexedDBCallbacks<WebIDBObjectStore>(parent_, params.response_id_));
+
+ WebIDBObjectStore* object_store = idb_database->createObjectStore(
+ params.name_, params.key_path_, params.auto_increment_, *idb_transaction);
+ ViewHostMsg_IDBDatabaseCreateObjectStore::WriteReplyParams(
+ reply_msg, parent_->Add(object_store));
+ parent_->Send(reply_msg);
}
void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnObjectStore(
@@ -426,15 +456,21 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnObjectStore(
}
void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnRemoveObjectStore(
- int32 idb_database_id, int32 response_id, const string16& name) {
+ int32 idb_database_id,
+ const string16& name,
+ int32 transaction_id) {
+
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess(
&map_, idb_database_id, NULL,
ViewHostMsg_IDBDatabaseRemoveObjectStore::ID);
- if (!idb_database)
+ WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
+ &parent_->transaction_dispatcher_host_->map_, transaction_id, NULL,
+ ViewHostMsg_IDBDatabaseRemoveObjectStore::ID);
+ if (!idb_database || !idb_transaction)
return;
- idb_database->removeObjectStore(
- name, new IndexedDBCallbacks<void>(parent_, response_id));
+
+ idb_database->removeObjectStore(name, *idb_transaction);
}
void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetVersion(
@@ -445,8 +481,10 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetVersion(
ViewHostMsg_IDBDatabaseSetVersion::ID);
if (!idb_database)
return;
+
idb_database->setVersion(
- version, new IndexedDBCallbacks<void>(parent_, response_id));
+ version,
+ new IndexedDBCallbacks<WebIDBTransaction>(parent_, response_id));
}
void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnTransaction(
@@ -466,11 +504,8 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnTransaction(
WebIDBTransaction* transaction = database->transaction(
object_stores, mode, timeout);
- transaction->setCallbacks(
- new IndexedDBTransactionCallbacks(parent_, transaction->id()));
- parent_->Add(transaction);
- ViewHostMsg_IDBDatabaseTransaction::WriteReplyParams(
- reply_msg, transaction->id());
+ int32 id = parent_->Add(transaction);
+ ViewHostMsg_IDBDatabaseTransaction::WriteReplyParams(reply_msg, id);
parent_->Send(reply_msg);
}
@@ -488,6 +523,7 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed(
IndexedDBDispatcherHost::IndexDispatcherHost::IndexDispatcherHost(
IndexedDBDispatcherHost* parent)
: parent_(parent) {
+ map_.set_check_on_null_data(true);
}
IndexedDBDispatcherHost::IndexDispatcherHost::~IndexDispatcherHost() {
@@ -504,9 +540,9 @@ bool IndexedDBDispatcherHost::IndexDispatcherHost::OnMessageReceived(
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBIndexUnique, OnUnique)
IPC_MESSAGE_HANDLER(ViewHostMsg_IDBIndexOpenObjectCursor,
OnOpenObjectCursor)
- IPC_MESSAGE_HANDLER(ViewHostMsg_IDBIndexOpenCursor, OnOpenCursor)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_IDBIndexOpenKeyCursor, OnOpenKeyCursor)
IPC_MESSAGE_HANDLER(ViewHostMsg_IDBIndexGetObject, OnGetObject)
- IPC_MESSAGE_HANDLER(ViewHostMsg_IDBIndexGet, OnGet)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_IDBIndexGetKey, OnGetKey)
IPC_MESSAGE_HANDLER(ViewHostMsg_IDBIndexDestroyed, OnDestroyed)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -564,20 +600,20 @@ void IndexedDBDispatcherHost::IndexDispatcherHost::OnOpenObjectCursor(
params.direction_, callbacks.release(), *idb_transaction);
}
-void IndexedDBDispatcherHost::IndexDispatcherHost::OnOpenCursor(
+void IndexedDBDispatcherHost::IndexDispatcherHost::OnOpenKeyCursor(
const ViewHostMsg_IDBIndexOpenCursor_Params& params) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
WebIDBIndex* idb_index = parent_->GetOrTerminateProcess(
- &map_, params.idb_index_id_, NULL, ViewHostMsg_IDBIndexOpenCursor::ID);
+ &map_, params.idb_index_id_, NULL, ViewHostMsg_IDBIndexOpenKeyCursor::ID);
WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
&parent_->transaction_dispatcher_host_->map_, params.transaction_id_,
- NULL, ViewHostMsg_IDBIndexOpenCursor::ID);
+ NULL, ViewHostMsg_IDBIndexOpenKeyCursor::ID);
if (!idb_transaction || !idb_index)
return;
scoped_ptr<WebIDBCallbacks> callbacks(
new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id_));
- idb_index->openCursor(
+ idb_index->openKeyCursor(
WebIDBKeyRange(params.left_key_, params.right_key_, params.key_flags_),
params.direction_, callbacks.release(), *idb_transaction);
}
@@ -586,7 +622,7 @@ void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetObject(
int idb_index_id,
int32 response_id,
const IndexedDBKey& key,
- int transaction_id) {
+ int32 transaction_id) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
WebIDBIndex* idb_index = parent_->GetOrTerminateProcess(
&map_, idb_index_id, NULL, ViewHostMsg_IDBIndexGetObject::ID);
@@ -601,23 +637,23 @@ void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetObject(
idb_index->getObject(key, callbacks.release(), *idb_transaction);
}
-void IndexedDBDispatcherHost::IndexDispatcherHost::OnGet(
+void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetKey(
int idb_index_id,
int32 response_id,
const IndexedDBKey& key,
- int transaction_id) {
+ int32 transaction_id) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
WebIDBIndex* idb_index = parent_->GetOrTerminateProcess(
- &map_, idb_index_id, NULL, ViewHostMsg_IDBIndexGet::ID);
+ &map_, idb_index_id, NULL, ViewHostMsg_IDBIndexGetKey::ID);
WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
&parent_->transaction_dispatcher_host_->map_, transaction_id, NULL,
- ViewHostMsg_IDBIndexGet::ID);
+ ViewHostMsg_IDBIndexGetKey::ID);
if (!idb_transaction || !idb_index)
return;
scoped_ptr<WebIDBCallbacks> callbacks(
- new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, response_id));
- idb_index->get(key, callbacks.release(), *idb_transaction);
+ new IndexedDBCallbacks<WebIDBKey>(parent_, response_id));
+ idb_index->getKey(key, callbacks.release(), *idb_transaction);
}
void IndexedDBDispatcherHost::IndexDispatcherHost::OnDestroyed(
@@ -632,6 +668,7 @@ void IndexedDBDispatcherHost::IndexDispatcherHost::OnDestroyed(
IndexedDBDispatcherHost::ObjectStoreDispatcherHost::ObjectStoreDispatcherHost(
IndexedDBDispatcherHost* parent)
: parent_(parent) {
+ map_.set_check_on_null_data(true);
}
IndexedDBDispatcherHost::
@@ -651,7 +688,8 @@ bool IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnMessageReceived(
IPC_MESSAGE_HANDLER(ViewHostMsg_IDBObjectStoreGet, OnGet);
IPC_MESSAGE_HANDLER(ViewHostMsg_IDBObjectStorePut, OnPut);
IPC_MESSAGE_HANDLER(ViewHostMsg_IDBObjectStoreRemove, OnRemove);
- IPC_MESSAGE_HANDLER(ViewHostMsg_IDBObjectStoreCreateIndex, OnCreateIndex);
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBObjectStoreCreateIndex,
+ OnCreateIndex);
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBObjectStoreIndex, OnIndex);
IPC_MESSAGE_HANDLER(ViewHostMsg_IDBObjectStoreRemoveIndex, OnRemoveIndex);
IPC_MESSAGE_HANDLER(ViewHostMsg_IDBObjectStoreOpenCursor, OnOpenCursor)
@@ -703,7 +741,7 @@ void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnGet(
int idb_object_store_id,
int32 response_id,
const IndexedDBKey& key,
- int transaction_id) {
+ int32 transaction_id) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess(
&map_, idb_object_store_id, NULL, ViewHostMsg_IDBObjectStoreGet::ID);
@@ -740,7 +778,7 @@ void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnRemove(
int idb_object_store_id,
int32 response_id,
const IndexedDBKey& key,
- int transaction_id) {
+ int32 transaction_id) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess(
&map_, idb_object_store_id, NULL, ViewHostMsg_IDBObjectStoreRemove::ID);
@@ -756,16 +794,23 @@ void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnRemove(
}
void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnCreateIndex(
- const ViewHostMsg_IDBObjectStoreCreateIndex_Params& params) {
+ const ViewHostMsg_IDBObjectStoreCreateIndex_Params& params,
+ IPC::Message* reply_msg) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess(
&map_, params.idb_object_store_id_, NULL,
ViewHostMsg_IDBObjectStoreCreateIndex::ID);
- if (!idb_object_store)
+ WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
+ &parent_->transaction_dispatcher_host_->map_, params.transaction_id_,
+ NULL, ViewHostMsg_IDBObjectStoreCreateIndex::ID);
+ if (!idb_object_store || !idb_transaction)
return;
- idb_object_store->createIndex(
- params.name_, params.key_path_, params.unique_,
- new IndexedDBCallbacks<WebIDBIndex>(parent_, params.response_id_));
+
+ WebIDBIndex* index = idb_object_store->createIndex(
+ params.name_, params.key_path_, params.unique_, *idb_transaction);
+ ViewHostMsg_IDBObjectStoreCreateIndex::WriteReplyParams(
+ reply_msg, parent_->Add(index));
+ parent_->Send(reply_msg);
}
void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnIndex(
@@ -777,22 +822,26 @@ void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnIndex(
return;
WebIDBIndex* index = idb_object_store->index(name);
- int32 object_id = index ? parent_->Add(index) : 0;
- ViewHostMsg_IDBObjectStoreIndex::WriteReplyParams(reply_msg, !!index,
- object_id);
+ int32 object_id = parent_->Add(index);
+ ViewHostMsg_IDBObjectStoreIndex::WriteReplyParams(reply_msg, object_id);
parent_->Send(reply_msg);
}
void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnRemoveIndex(
- int32 idb_object_store_id, int32 response_id, const string16& name) {
+ int32 idb_object_store_id,
+ const string16& name,
+ int32 transaction_id) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess(
&map_, idb_object_store_id, NULL,
ViewHostMsg_IDBObjectStoreRemoveIndex::ID);
- if (!idb_object_store)
+ WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
+ &parent_->transaction_dispatcher_host_->map_, transaction_id, NULL,
+ ViewHostMsg_IDBObjectStoreRemoveIndex::ID);
+ if (!idb_object_store || !idb_transaction)
return;
- idb_object_store->removeIndex(
- name, new IndexedDBCallbacks<void>(parent_, response_id));
+
+ idb_object_store->removeIndex(name, *idb_transaction);
}
void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnOpenCursor(
@@ -828,6 +877,7 @@ void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDestroyed(
IndexedDBDispatcherHost::CursorDispatcherHost::CursorDispatcherHost(
IndexedDBDispatcherHost* parent)
: parent_(parent) {
+ map_.set_check_on_null_data(true);
}
IndexedDBDispatcherHost::CursorDispatcherHost::~CursorDispatcherHost() {
@@ -952,6 +1002,7 @@ void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed(
IndexedDBDispatcherHost::TransactionDispatcherHost::TransactionDispatcherHost(
IndexedDBDispatcherHost* parent)
: parent_(parent) {
+ map_.set_check_on_null_data(true);
}
IndexedDBDispatcherHost::
@@ -964,6 +1015,7 @@ bool IndexedDBDispatcherHost::TransactionDispatcherHost::OnMessageReceived(
IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::TransactionDispatcherHost,
message, *msg_is_ok)
IPC_MESSAGE_HANDLER(ViewHostMsg_IDBTransactionAbort, OnAbort)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBTransactionMode, OnMode)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBTransactionObjectStore,
OnObjectStore)
IPC_MESSAGE_HANDLER(ViewHostMsg_IDBTransactionDidCompleteTaskEvents,
@@ -992,6 +1044,19 @@ void IndexedDBDispatcherHost::TransactionDispatcherHost::OnAbort(
idb_transaction->abort();
}
+void IndexedDBDispatcherHost::TransactionDispatcherHost::OnMode(
+ int32 transaction_id,
+ IPC::Message* reply_msg) {
+ WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
+ &map_, transaction_id, 0, ViewHostMsg_IDBTransactionMode::ID);
+ if (!idb_transaction)
+ return;
+
+ int mode = idb_transaction->mode();
+ ViewHostMsg_IDBTransactionMode::WriteReplyParams(reply_msg, mode);
+ parent_->Send(reply_msg);
+}
+
void IndexedDBDispatcherHost::TransactionDispatcherHost::OnObjectStore(
int32 transaction_id, const string16& name, IPC::Message* reply_msg) {
WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
diff --git a/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h b/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h
index f048cbe..0112cce 100644
--- a/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h
+++ b/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h
@@ -64,7 +64,7 @@ class IndexedDBDispatcherHost
int32 Add(WebKit::WebIDBDatabase* idb_database);
int32 Add(WebKit::WebIDBIndex* idb_index);
int32 Add(WebKit::WebIDBObjectStore* idb_object_store);
- void Add(WebKit::WebIDBTransaction* idb_transaction);
+ int32 Add(WebKit::WebIDBTransaction* idb_transaction);
private:
friend class base::RefCountedThreadSafe<IndexedDBDispatcherHost>;
@@ -103,11 +103,13 @@ class IndexedDBDispatcherHost
void OnVersion(int32 idb_database_id, IPC::Message* reply_msg);
void OnObjectStores(int32 idb_database_id, IPC::Message* reply_msg);
void OnCreateObjectStore(
- const ViewHostMsg_IDBDatabaseCreateObjectStore_Params& params);
+ const ViewHostMsg_IDBDatabaseCreateObjectStore_Params& params,
+ IPC::Message* reply_msg);
void OnObjectStore(int32 idb_database_id, const string16& name, int32 mode,
IPC::Message* reply_msg);
- void OnRemoveObjectStore(int32 idb_database_id, int32 response_id,
- const string16& name);
+ void OnRemoveObjectStore(int32 idb_database_id,
+ const string16& name,
+ int32 transaction_id);
void OnSetVersion(int32 idb_database_id,
int32 response_id,
const string16& version);
@@ -134,15 +136,15 @@ class IndexedDBDispatcherHost
void OnUnique(int32 idb_index_id, IPC::Message* reply_msg);
void OnOpenObjectCursor(
const ViewHostMsg_IDBIndexOpenCursor_Params& params);
- void OnOpenCursor(const ViewHostMsg_IDBIndexOpenCursor_Params& params);
+ void OnOpenKeyCursor(const ViewHostMsg_IDBIndexOpenCursor_Params& params);
void OnGetObject(int idb_index_id,
int32 response_id,
const IndexedDBKey& key,
- int transaction_id);
- void OnGet(int idb_index_id,
- int32 response_id,
- const IndexedDBKey& key,
- int transaction_id);
+ int32 transaction_id);
+ void OnGetKey(int idb_index_id,
+ int32 response_id,
+ const IndexedDBKey& key,
+ int32 transaction_id);
void OnDestroyed(int32 idb_index_id);
IndexedDBDispatcherHost* parent_;
@@ -163,18 +165,20 @@ class IndexedDBDispatcherHost
void OnGet(int idb_object_store_id,
int32 response_id,
const IndexedDBKey& key,
- int transaction_id);
+ int32 transaction_id);
void OnPut(const ViewHostMsg_IDBObjectStorePut_Params& params);
void OnRemove(int idb_object_store_id,
int32 response_id,
const IndexedDBKey& key,
- int transaction_id);
+ int32 transaction_id);
void OnCreateIndex(
- const ViewHostMsg_IDBObjectStoreCreateIndex_Params& params);
+ const ViewHostMsg_IDBObjectStoreCreateIndex_Params& params,
+ IPC::Message* reply_msg);
void OnIndex(int32 idb_object_store_id, const string16& name,
IPC::Message* reply_msg);
- void OnRemoveIndex(int32 idb_object_store_id, int32 response_id,
- const string16& name);
+ void OnRemoveIndex(int32 idb_object_store_id,
+ const string16& name,
+ int32 transaction_id);
void OnOpenCursor(
const ViewHostMsg_IDBObjectStoreOpenCursor_Params& params);
void OnDestroyed(int32 idb_object_store_id);
@@ -218,6 +222,7 @@ class IndexedDBDispatcherHost
// TODO: add the rest of the transaction methods.
void OnAbort(int32 transaction_id);
+ void OnMode(int32 transaction_id, IPC::Message* reply_msg);
void OnObjectStore(int32 transaction_id, const string16& name,
IPC::Message* reply_msg);
void OnDidCompleteTaskEvents(int transaction_id);
@@ -243,7 +248,6 @@ class IndexedDBDispatcherHost
scoped_ptr<CursorDispatcherHost> cursor_dispatcher_host_;
scoped_ptr<TransactionDispatcherHost> transaction_dispatcher_host_;
-
// If we get a corrupt message from a renderer, we need to kill it using this
// handle.
base::ProcessHandle process_handle_;
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 1d6cd4f..1008de2 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -883,24 +883,27 @@ IPC_BEGIN_MESSAGES(View)
// IDBCallback message handlers.
IPC_MESSAGE_CONTROL1(ViewMsg_IDBCallbacksSuccessNull,
int32 /* response_id */)
+ IPC_MESSAGE_CONTROL2(ViewMsg_IDBCallbacksSuccessIDBCursor,
+ int32 /* response_id */,
+ int32 /* cursor_id */)
IPC_MESSAGE_CONTROL2(ViewMsg_IDBCallbacksSuccessIDBDatabase,
int32 /* response_id */,
int32 /* idb_database_id */)
IPC_MESSAGE_CONTROL2(ViewMsg_IDBCallbacksSuccessIndexedDBKey,
int32 /* response_id */,
IndexedDBKey /* indexed_db_key */)
+ IPC_MESSAGE_CONTROL2(ViewMsg_IDBCallbacksSuccessIDBIndex,
+ int32 /* response_id */,
+ int32 /* idb_index_id */)
IPC_MESSAGE_CONTROL2(ViewMsg_IDBCallbacksSuccessIDBObjectStore,
int32 /* response_id */,
int32 /* idb_object_store_id */)
- IPC_MESSAGE_CONTROL2(ViewMsg_IDBCallbacksSuccessIDBIndex,
+ IPC_MESSAGE_CONTROL2(ViewMsg_IDBCallbacksSuccessIDBTransaction,
int32 /* response_id */,
- int32 /* idb_index_id */)
+ int32 /* idb_transaction_id */)
IPC_MESSAGE_CONTROL2(ViewMsg_IDBCallbacksSuccessSerializedScriptValue,
int32 /* response_id */,
SerializedScriptValue /* serialized_script_value */)
- IPC_MESSAGE_CONTROL2(ViewMsg_IDBCallbackSuccessOpenCursor,
- int32 /* response_id */,
- int32 /* cursor_id */)
IPC_MESSAGE_CONTROL3(ViewMsg_IDBCallbacksError,
int32 /* response_id */,
int /* code */,
@@ -908,7 +911,11 @@ IPC_BEGIN_MESSAGES(View)
// IDBTransactionCallback message handlers.
IPC_MESSAGE_CONTROL1(ViewMsg_IDBTransactionCallbacksAbort,
- int /* transaction_id */)
+ int32 /* transaction_id */)
+ IPC_MESSAGE_CONTROL1(ViewMsg_IDBTransactionCallbacksComplete,
+ int32 /* transaction_id */)
+ IPC_MESSAGE_CONTROL1(ViewMsg_IDBTransactionCallbacksTimeout,
+ int32 /* transaction_id */)
#if defined(IPC_MESSAGE_LOG_ENABLED)
// Tell the renderer process to begin or end IPC message logging.
@@ -2402,8 +2409,9 @@ IPC_BEGIN_MESSAGES(ViewHost)
std::vector<string16> /* objectStores */)
// WebIDBDatabase::createObjectStore() message.
- IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBDatabaseCreateObjectStore,
- ViewHostMsg_IDBDatabaseCreateObjectStore_Params)
+ IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_IDBDatabaseCreateObjectStore,
+ ViewHostMsg_IDBDatabaseCreateObjectStore_Params,
+ int32 /* object_store_id */)
// WebIDBDatabase::objectStore() message.
IPC_SYNC_MESSAGE_CONTROL3_2(ViewHostMsg_IDBDatabaseObjectStore,
@@ -2416,8 +2424,8 @@ IPC_BEGIN_MESSAGES(ViewHost)
// WebIDBDatabase::removeObjectStore() message.
IPC_MESSAGE_CONTROL3(ViewHostMsg_IDBDatabaseRemoveObjectStore,
int32, /* idb_database_id */
- int32, /* response_id */
- string16 /* name */)
+ string16, /* name */
+ int32 /* transaction_id */)
// WebIDBDatabase::setVersion() message.
IPC_MESSAGE_CONTROL3(ViewHostMsg_IDBDatabaseSetVersion,
@@ -2461,12 +2469,12 @@ IPC_BEGIN_MESSAGES(ViewHost)
int32, /* idb_unique_id */
bool /* unique */)
- // WebIDBIndex::openObjectCursor() message. (Uses openCursor's params though.)
+ // WebIDBIndex::openObjectCursor() message.
IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBIndexOpenObjectCursor,
ViewHostMsg_IDBIndexOpenCursor_Params)
- // WebIDBIndex::openCursor() message.
- IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBIndexOpenCursor,
+ // WebIDBIndex::openKeyCursor() message.
+ IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBIndexOpenKeyCursor,
ViewHostMsg_IDBIndexOpenCursor_Params)
// WebIDBIndex::getObject() message.
@@ -2474,14 +2482,14 @@ IPC_BEGIN_MESSAGES(ViewHost)
int32, /* idb_index_id */
int32, /* response_id */
IndexedDBKey, /* key */
- int /* transaction_id */)
+ int32 /* transaction_id */)
- // WebIDBIndex::get() message.
- IPC_MESSAGE_CONTROL4(ViewHostMsg_IDBIndexGet,
+ // WebIDBIndex::getKey() message.
+ IPC_MESSAGE_CONTROL4(ViewHostMsg_IDBIndexGetKey,
int32, /* idb_index_id */
int32, /* response_id */
IndexedDBKey, /* key */
- int /* transaction_id */)
+ int32 /* transaction_id */)
// WebIDBIndex::~WebIDBIndex() message.
IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBIndexDestroyed,
@@ -2507,7 +2515,7 @@ IPC_BEGIN_MESSAGES(ViewHost)
int32, /* idb_object_store_id */
int32, /* response_id */
IndexedDBKey, /* key */
- int /* transaction_id */)
+ int32 /* transaction_id */)
// WebIDBObjectStore::put() message.
IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBObjectStorePut,
@@ -2518,24 +2526,24 @@ IPC_BEGIN_MESSAGES(ViewHost)
int32, /* idb_object_store_id */
int32, /* response_id */
IndexedDBKey, /* key */
- int /* transaction_id */)
+ int32 /* transaction_id */)
// WebIDBObjectStore::createIndex() message.
- IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBObjectStoreCreateIndex,
- ViewHostMsg_IDBObjectStoreCreateIndex_Params)
+ IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_IDBObjectStoreCreateIndex,
+ ViewHostMsg_IDBObjectStoreCreateIndex_Params,
+ int32 /* index_id */)
// WebIDBObjectStore::index() message.
- IPC_SYNC_MESSAGE_CONTROL2_2(ViewHostMsg_IDBObjectStoreIndex,
+ IPC_SYNC_MESSAGE_CONTROL2_1(ViewHostMsg_IDBObjectStoreIndex,
int32, /* idb_object_store_id */
string16, /* name */
- bool, /* success */
int32 /* idb_index_id */)
// WebIDBObjectStore::removeIndex() message.
IPC_MESSAGE_CONTROL3(ViewHostMsg_IDBObjectStoreRemoveIndex,
int32, /* idb_object_store_id */
- int32, /* response_id */
- string16 /* name */)
+ string16, /* name */
+ int32 /* transaction_id */)
// WebIDBObjectStore::openCursor() message.
IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBObjectStoreOpenCursor,
@@ -2555,6 +2563,11 @@ IPC_BEGIN_MESSAGES(ViewHost)
string16, /* name */
int32 /* object_store_id */)
+ // WebIDBTransaction::mode() message.
+ IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_IDBTransactionMode,
+ int32, /* idb_transaction_id */
+ int /* mode */)
+
// WebIDBTransaction::abort() message.
IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBTransactionAbort,
int32 /* idb_transaction_id */)
diff --git a/chrome/common/render_messages_params.cc b/chrome/common/render_messages_params.cc
index c5b4aa3..b9435b6 100644
--- a/chrome/common/render_messages_params.cc
+++ b/chrome/common/render_messages_params.cc
@@ -183,8 +183,8 @@ ViewHostMsg_IDBFactoryOpen_Params::~ViewHostMsg_IDBFactoryOpen_Params() {
ViewHostMsg_IDBDatabaseCreateObjectStore_Params::
ViewHostMsg_IDBDatabaseCreateObjectStore_Params()
- : response_id_(0),
- auto_increment_(false),
+ : auto_increment_(false),
+ transaction_id_(0),
idb_database_id_(0) {
}
@@ -217,8 +217,8 @@ ViewHostMsg_IDBObjectStorePut_Params::~ViewHostMsg_IDBObjectStorePut_Params() {
ViewHostMsg_IDBObjectStoreCreateIndex_Params::
ViewHostMsg_IDBObjectStoreCreateIndex_Params()
- : response_id_(0),
- unique_(false),
+ : unique_(false),
+ transaction_id_(0),
idb_object_store_id_(0) {
}
@@ -1246,10 +1246,10 @@ void ParamTraits<ViewHostMsg_IDBFactoryOpen_Params>::Log(const param_type& p,
void ParamTraits<ViewHostMsg_IDBDatabaseCreateObjectStore_Params>::Write(
Message* m,
const param_type& p) {
- WriteParam(m, p.response_id_);
WriteParam(m, p.name_);
WriteParam(m, p.key_path_);
WriteParam(m, p.auto_increment_);
+ WriteParam(m, p.transaction_id_);
WriteParam(m, p.idb_database_id_);
}
@@ -1258,10 +1258,10 @@ bool ParamTraits<ViewHostMsg_IDBDatabaseCreateObjectStore_Params>::Read(
void** iter,
param_type* p) {
return
- ReadParam(m, iter, &p->response_id_) &&
ReadParam(m, iter, &p->name_) &&
ReadParam(m, iter, &p->key_path_) &&
ReadParam(m, iter, &p->auto_increment_) &&
+ ReadParam(m, iter, &p->transaction_id_) &&
ReadParam(m, iter, &p->idb_database_id_);
}
@@ -1269,14 +1269,14 @@ void ParamTraits<ViewHostMsg_IDBDatabaseCreateObjectStore_Params>::Log(
const param_type& p,
std::string* l) {
l->append("(");
- LogParam(p.response_id_, l);
- l->append(", ");
LogParam(p.name_, l);
l->append(", ");
LogParam(p.key_path_, l);
l->append(", ");
LogParam(p.auto_increment_, l);
l->append(", ");
+ LogParam(p.transaction_id_, l);
+ l->append(", ");
LogParam(p.idb_database_id_, l);
l->append(")");
}
@@ -1372,10 +1372,10 @@ void ParamTraits<ViewHostMsg_IDBObjectStorePut_Params>::Log(
void ParamTraits<ViewHostMsg_IDBObjectStoreCreateIndex_Params>::Write(
Message* m,
const param_type& p) {
- WriteParam(m, p.response_id_);
WriteParam(m, p.name_);
WriteParam(m, p.key_path_);
WriteParam(m, p.unique_);
+ WriteParam(m, p.transaction_id_);
WriteParam(m, p.idb_object_store_id_);
}
@@ -1384,10 +1384,10 @@ bool ParamTraits<ViewHostMsg_IDBObjectStoreCreateIndex_Params>::Read(
void** iter,
param_type* p) {
return
- ReadParam(m, iter, &p->response_id_) &&
ReadParam(m, iter, &p->name_) &&
ReadParam(m, iter, &p->key_path_) &&
ReadParam(m, iter, &p->unique_) &&
+ ReadParam(m, iter, &p->transaction_id_) &&
ReadParam(m, iter, &p->idb_object_store_id_);
}
@@ -1395,14 +1395,14 @@ void ParamTraits<ViewHostMsg_IDBObjectStoreCreateIndex_Params>::Log(
const param_type& p,
std::string* l) {
l->append("(");
- LogParam(p.response_id_, l);
- l->append(", ");
LogParam(p.name_, l);
l->append(", ");
LogParam(p.key_path_, l);
l->append(", ");
LogParam(p.unique_, l);
l->append(", ");
+ LogParam(p.transaction_id_, l);
+ l->append(", ");
LogParam(p.idb_object_store_id_, l);
l->append(")");
}
diff --git a/chrome/common/render_messages_params.h b/chrome/common/render_messages_params.h
index 2b0c0d0..a64d5fa 100644
--- a/chrome/common/render_messages_params.h
+++ b/chrome/common/render_messages_params.h
@@ -640,9 +640,6 @@ struct ViewHostMsg_IDBDatabaseCreateObjectStore_Params {
ViewHostMsg_IDBDatabaseCreateObjectStore_Params();
~ViewHostMsg_IDBDatabaseCreateObjectStore_Params();
- // The response should have this id.
- int32 response_id_;
-
// The name of the object store.
string16 name_;
@@ -652,6 +649,9 @@ struct ViewHostMsg_IDBDatabaseCreateObjectStore_Params {
// Whether the object store created should have a key generator.
bool auto_increment_;
+ // The transaction this is associated with.
+ int32 transaction_id_;
+
// The database the object store belongs to.
int32 idb_database_id_;
};
@@ -712,9 +712,6 @@ struct ViewHostMsg_IDBObjectStoreCreateIndex_Params {
ViewHostMsg_IDBObjectStoreCreateIndex_Params();
~ViewHostMsg_IDBObjectStoreCreateIndex_Params();
- // The response should have this id.
- int32 response_id_;
-
// The name of the index.
string16 name_;
@@ -724,6 +721,9 @@ struct ViewHostMsg_IDBObjectStoreCreateIndex_Params {
// Whether the index created has unique keys.
bool unique_;
+ // The transaction this is associated with.
+ int32 transaction_id_;
+
// The object store the index belongs to.
int32 idb_object_store_id_;
};
diff --git a/chrome/renderer/indexed_db_dispatcher.cc b/chrome/renderer/indexed_db_dispatcher.cc
index 813a4fc..b04434f 100644
--- a/chrome/renderer/indexed_db_dispatcher.cc
+++ b/chrome/renderer/indexed_db_dispatcher.cc
@@ -14,6 +14,7 @@
#include "chrome/renderer/renderer_webidbdatabase_impl.h"
#include "chrome/renderer/renderer_webidbindex_impl.h"
#include "chrome/renderer/renderer_webidbobjectstore_impl.h"
+#include "chrome/renderer/renderer_webidbtransaction_impl.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/WebKit/chromium/public/WebIDBDatabaseError.h"
#include "third_party/WebKit/WebKit/chromium/public/WebIDBKeyRange.h"
@@ -26,6 +27,8 @@ using WebKit::WebIDBCallbacks;
using WebKit::WebIDBKeyRange;
using WebKit::WebIDBDatabase;
using WebKit::WebIDBDatabaseError;
+using WebKit::WebIDBTransaction;
+using WebKit::WebIDBTransactionCallbacks;
IndexedDBDispatcher::IndexedDBDispatcher() {
}
@@ -38,22 +41,28 @@ bool IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) {
IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcher, msg)
IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksSuccessNull,
OnSuccessNull)
+ IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksSuccessIDBCursor,
+ OnSuccessOpenCursor)
IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksSuccessIDBDatabase,
OnSuccessIDBDatabase)
+ IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksSuccessIDBIndex,
+ OnSuccessIDBIndex)
IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksSuccessIndexedDBKey,
OnSuccessIndexedDBKey)
IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksSuccessIDBObjectStore,
OnSuccessIDBObjectStore)
- IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksSuccessIDBIndex,
- OnSuccessIDBIndex)
- IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbackSuccessOpenCursor,
- OnSuccessOpenCursor)
+ IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksSuccessIDBTransaction,
+ OnSuccessIDBTransaction)
IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksSuccessSerializedScriptValue,
OnSuccessSerializedScriptValue)
IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksError,
OnError)
IPC_MESSAGE_HANDLER(ViewMsg_IDBTransactionCallbacksAbort,
OnAbort)
+ IPC_MESSAGE_HANDLER(ViewMsg_IDBTransactionCallbacksComplete,
+ OnComplete)
+ IPC_MESSAGE_HANDLER(ViewMsg_IDBTransactionCallbacksTimeout,
+ OnTimeout)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -112,31 +121,6 @@ void IndexedDBDispatcher::RequestIDBFactoryOpen(
RenderThread::current()->Send(new ViewHostMsg_IDBFactoryOpen(params));
}
-void IndexedDBDispatcher::RequestIDBDatabaseCreateObjectStore(
- const string16& name, const NullableString16& key_path, bool auto_increment,
- WebIDBCallbacks* callbacks_ptr, int32 idb_database_id) {
- scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
-
- ViewHostMsg_IDBDatabaseCreateObjectStore_Params params;
- params.response_id_ = pending_callbacks_.Add(callbacks.release());
- params.name_ = name;
- params.key_path_ = key_path;
- params.auto_increment_ = auto_increment;
- params.idb_database_id_ = idb_database_id;
- RenderThread::current()->Send(
- new ViewHostMsg_IDBDatabaseCreateObjectStore(params));
-}
-
-void IndexedDBDispatcher::RequestIDBDatabaseRemoveObjectStore(
- const string16& name, WebIDBCallbacks* callbacks_ptr,
- int32 idb_database_id) {
- scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
-
- RenderThread::current()->Send(
- new ViewHostMsg_IDBDatabaseRemoveObjectStore(
- idb_database_id, pending_callbacks_.Add(callbacks.release()), name));
-}
-
void IndexedDBDispatcher::RequestIDBDatabaseSetVersion(
const string16& version,
WebIDBCallbacks* callbacks_ptr,
@@ -154,7 +138,7 @@ void IndexedDBDispatcher::RequestIDBIndexOpenObjectCursor(
unsigned short direction,
WebIDBCallbacks* callbacks_ptr,
int32 idb_index_id,
- int transaction_id) {
+ const WebIDBTransaction& transaction) {
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
ViewHostMsg_IDBIndexOpenCursor_Params params;
params.response_id_ = pending_callbacks_.Add(callbacks.release());
@@ -163,7 +147,7 @@ void IndexedDBDispatcher::RequestIDBIndexOpenObjectCursor(
params.key_flags_ = idb_key_range.flags();
params.direction_ = direction;
params.idb_index_id_ = idb_index_id;
- params.transaction_id_ = transaction_id;
+ params.transaction_id_ = TransactionId(transaction);
RenderThread::current()->Send(
new ViewHostMsg_IDBIndexOpenObjectCursor(params));
}
@@ -173,66 +157,68 @@ void IndexedDBDispatcher::RequestIDBIndexOpenCursor(
unsigned short direction,
WebIDBCallbacks* callbacks_ptr,
int32 idb_index_id,
- int transaction_id) {
+ const WebIDBTransaction& transaction) {
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
ViewHostMsg_IDBIndexOpenCursor_Params params;
params.response_id_ = pending_callbacks_.Add(callbacks.release());
+ // TODO(jorlow): We really should just create a Chromium abstraction for
+ // KeyRange rather than doing it ad-hoc like this.
params.left_key_.Set(idb_key_range.left());
params.right_key_.Set(idb_key_range.right());
params.key_flags_ = idb_key_range.flags();
params.direction_ = direction;
params.idb_index_id_ = idb_index_id;
- params.transaction_id_ = transaction_id;
+ params.transaction_id_ = TransactionId(transaction);
RenderThread::current()->Send(
- new ViewHostMsg_IDBIndexOpenCursor(params));
+ new ViewHostMsg_IDBIndexOpenKeyCursor(params));
}
void IndexedDBDispatcher::RequestIDBIndexGetObject(
const IndexedDBKey& key,
- WebKit::WebIDBCallbacks* callbacks_ptr,
+ WebIDBCallbacks* callbacks_ptr,
int32 idb_index_id,
- int transaction_id) {
+ const WebIDBTransaction& transaction) {
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
RenderThread::current()->Send(
new ViewHostMsg_IDBIndexGetObject(
idb_index_id, pending_callbacks_.Add(callbacks.release()), key,
- transaction_id));
+ TransactionId(transaction)));
}
void IndexedDBDispatcher::RequestIDBIndexGet(
const IndexedDBKey& key,
- WebKit::WebIDBCallbacks* callbacks_ptr,
+ WebIDBCallbacks* callbacks_ptr,
int32 idb_index_id,
- int transaction_id) {
+ const WebIDBTransaction& transaction) {
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
RenderThread::current()->Send(
- new ViewHostMsg_IDBIndexGet(
+ new ViewHostMsg_IDBIndexGetKey(
idb_index_id, pending_callbacks_.Add(callbacks.release()), key,
- transaction_id));
+ TransactionId(transaction)));
}
void IndexedDBDispatcher::RequestIDBObjectStoreGet(
const IndexedDBKey& key,
- WebKit::WebIDBCallbacks* callbacks_ptr,
+ WebIDBCallbacks* callbacks_ptr,
int32 idb_object_store_id,
- int transaction_id) {
+ const WebIDBTransaction& transaction) {
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
RenderThread::current()->Send(
new ViewHostMsg_IDBObjectStoreGet(
idb_object_store_id, pending_callbacks_.Add(callbacks.release()),
- key, transaction_id));
+ key, TransactionId(transaction)));
}
void IndexedDBDispatcher::RequestIDBObjectStorePut(
const SerializedScriptValue& value,
const IndexedDBKey& key,
bool add_only,
- WebKit::WebIDBCallbacks* callbacks_ptr,
+ WebIDBCallbacks* callbacks_ptr,
int32 idb_object_store_id,
- int transaction_id) {
+ const WebIDBTransaction& transaction) {
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
ViewHostMsg_IDBObjectStorePut_Params params;
params.idb_object_store_id_ = idb_object_store_id;
@@ -240,47 +226,21 @@ void IndexedDBDispatcher::RequestIDBObjectStorePut(
params.serialized_value_ = value;
params.key_ = key;
params.add_only_ = add_only;
- params.transaction_id_ = transaction_id;
+ params.transaction_id_ = TransactionId(transaction);
RenderThread::current()->Send(new ViewHostMsg_IDBObjectStorePut(params));
}
void IndexedDBDispatcher::RequestIDBObjectStoreRemove(
const IndexedDBKey& key,
- WebKit::WebIDBCallbacks* callbacks_ptr,
+ WebIDBCallbacks* callbacks_ptr,
int32 idb_object_store_id,
- int transaction_id) {
+ const WebIDBTransaction& transaction) {
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
RenderThread::current()->Send(
new ViewHostMsg_IDBObjectStoreRemove(
idb_object_store_id, pending_callbacks_.Add(callbacks.release()),
- key, transaction_id));
-}
-
-void IndexedDBDispatcher::RequestIDBObjectStoreCreateIndex(
- const string16& name, const NullableString16& key_path, bool unique,
- WebIDBCallbacks* callbacks_ptr, int32 idb_object_store_id) {
- scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
-
- ViewHostMsg_IDBObjectStoreCreateIndex_Params params;
- params.response_id_ = pending_callbacks_.Add(callbacks.release());
- params.name_ = name;
- params.key_path_ = key_path;
- params.unique_ = unique;
- params.idb_object_store_id_ = idb_object_store_id;
- RenderThread::current()->Send(
- new ViewHostMsg_IDBObjectStoreCreateIndex(params));
-}
-
-void IndexedDBDispatcher::RequestIDBObjectStoreRemoveIndex(
- const string16& name, WebIDBCallbacks* callbacks_ptr,
- int32 idb_object_store_id) {
- scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
-
- RenderThread::current()->Send(
- new ViewHostMsg_IDBObjectStoreRemoveIndex(
- idb_object_store_id, pending_callbacks_.Add(callbacks.release()),
- name));
+ key, TransactionId(transaction)));
}
void IndexedDBDispatcher::RequestIDBObjectStoreOpenCursor(
@@ -288,7 +248,7 @@ void IndexedDBDispatcher::RequestIDBObjectStoreOpenCursor(
unsigned short direction,
WebIDBCallbacks* callbacks_ptr,
int32 idb_object_store_id,
- int transaction_id) {
+ const WebIDBTransaction& transaction) {
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
ViewHostMsg_IDBObjectStoreOpenCursor_Params params;
params.response_id_ = pending_callbacks_.Add(callbacks.release());
@@ -297,60 +257,75 @@ void IndexedDBDispatcher::RequestIDBObjectStoreOpenCursor(
params.flags_ = idb_key_range.flags();
params.direction_ = direction;
params.idb_object_store_id_ = idb_object_store_id;
- params.transaction_id_ = transaction_id;
+ params.transaction_id_ = TransactionId(transaction);
RenderThread::current()->Send(
new ViewHostMsg_IDBObjectStoreOpenCursor(params));
}
-void IndexedDBDispatcher::RequestIDBTransactionSetCallbacks(
- WebKit::WebIDBTransactionCallbacks* callbacks) {
- pending_transaction_callbacks_.AddWithID(callbacks, callbacks->id());
+void IndexedDBDispatcher::RegisterWebIDBTransactionCallbacks(
+ WebIDBTransactionCallbacks* callbacks,
+ int32 id) {
+ pending_transaction_callbacks_.AddWithID(callbacks, id);
+}
+
+int32 IndexedDBDispatcher::TransactionId(
+ const WebIDBTransaction& transaction) {
+ const RendererWebIDBTransactionImpl* impl =
+ static_cast<const RendererWebIDBTransactionImpl*>(&transaction);
+ return impl->id();
}
void IndexedDBDispatcher::OnSuccessNull(int32 response_id) {
- WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
+ WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
callbacks->onSuccess();
pending_callbacks_.Remove(response_id);
}
void IndexedDBDispatcher::OnSuccessIDBDatabase(int32 response_id,
int32 object_id) {
- WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
+ WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
callbacks->onSuccess(new RendererWebIDBDatabaseImpl(object_id));
pending_callbacks_.Remove(response_id);
}
void IndexedDBDispatcher::OnSuccessIndexedDBKey(int32 response_id,
const IndexedDBKey& key) {
- WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
+ WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
callbacks->onSuccess(key);
pending_callbacks_.Remove(response_id);
}
void IndexedDBDispatcher::OnSuccessIDBObjectStore(int32 response_id,
int32 object_id) {
- WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
+ WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
callbacks->onSuccess(new RendererWebIDBObjectStoreImpl(object_id));
pending_callbacks_.Remove(response_id);
}
+void IndexedDBDispatcher::OnSuccessIDBTransaction(int32 response_id,
+ int32 object_id) {
+ WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
+ callbacks->onSuccess(new RendererWebIDBTransactionImpl(object_id));
+ pending_callbacks_.Remove(response_id);
+}
+
void IndexedDBDispatcher::OnSuccessIDBIndex(int32 response_id,
int32 object_id) {
- WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
+ WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
callbacks->onSuccess(new RendererWebIDBIndexImpl(object_id));
pending_callbacks_.Remove(response_id);
}
void IndexedDBDispatcher::OnSuccessSerializedScriptValue(
int32 response_id, const SerializedScriptValue& value) {
- WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
+ WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
callbacks->onSuccess(value);
pending_callbacks_.Remove(response_id);
}
void IndexedDBDispatcher::OnSuccessOpenCursor(int32 repsonse_id,
int32 object_id) {
- WebKit::WebIDBCallbacks* callbacks =
+ WebIDBCallbacks* callbacks =
pending_callbacks_.Lookup(repsonse_id);
callbacks->onSuccess(new RendererWebIDBCursorImpl(object_id));
pending_callbacks_.Remove(repsonse_id);
@@ -358,15 +333,28 @@ void IndexedDBDispatcher::OnSuccessOpenCursor(int32 repsonse_id,
void IndexedDBDispatcher::OnError(int32 response_id, int code,
const string16& message) {
- WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
+ WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
callbacks->onError(WebIDBDatabaseError(code, message));
pending_callbacks_.Remove(response_id);
}
-void IndexedDBDispatcher::OnAbort(int transaction_id) {
- WebKit::WebIDBTransactionCallbacks* callbacks =
+void IndexedDBDispatcher::OnAbort(int32 transaction_id) {
+ WebIDBTransactionCallbacks* callbacks =
pending_transaction_callbacks_.Lookup(transaction_id);
- DCHECK(callbacks);
callbacks->onAbort();
pending_transaction_callbacks_.Remove(transaction_id);
}
+
+void IndexedDBDispatcher::OnComplete(int32 transaction_id) {
+ WebIDBTransactionCallbacks* callbacks =
+ pending_transaction_callbacks_.Lookup(transaction_id);
+ callbacks->onComplete();
+ pending_transaction_callbacks_.Remove(transaction_id);
+}
+
+void IndexedDBDispatcher::OnTimeout(int32 transaction_id) {
+ WebIDBTransactionCallbacks* callbacks =
+ pending_transaction_callbacks_.Lookup(transaction_id);
+ callbacks->onTimeout();
+ pending_transaction_callbacks_.Remove(transaction_id);
+}
diff --git a/chrome/renderer/indexed_db_dispatcher.h b/chrome/renderer/indexed_db_dispatcher.h
index 2868358..8e78141 100644
--- a/chrome/renderer/indexed_db_dispatcher.h
+++ b/chrome/renderer/indexed_db_dispatcher.h
@@ -19,6 +19,7 @@ class SerializedScriptValue;
namespace WebKit {
class WebFrame;
class WebIDBKeyRange;
+class WebIDBTransaction;
}
// Handle the indexed db related communication for this entire renderer.
@@ -50,15 +51,6 @@ class IndexedDBDispatcher {
WebKit::WebIDBCallbacks* callbacks_ptr,
int32 idb_cursor_id);
- void RequestIDBDatabaseCreateObjectStore(
- const string16& name, const NullableString16& key_path,
- bool auto_increment, WebKit::WebIDBCallbacks* callbacks,
- int32 idb_database_id);
-
- void RequestIDBDatabaseRemoveObjectStore(
- const string16& name, WebKit::WebIDBCallbacks* callbacks,
- int32 idb_database_id);
-
void RequestIDBDatabaseSetVersion(
const string16& version,
WebKit::WebIDBCallbacks* callbacks,
@@ -69,58 +61,54 @@ class IndexedDBDispatcher {
unsigned short direction,
WebKit::WebIDBCallbacks* callbacks,
int32 idb_index_id,
- int transaction_id);
+ const WebKit::WebIDBTransaction& transaction);
void RequestIDBIndexOpenCursor(const WebKit::WebIDBKeyRange& idb_key_range,
unsigned short direction,
WebKit::WebIDBCallbacks* callbacks,
int32 idb_index_id,
- int transaction_id);
+ const WebKit::WebIDBTransaction& transaction);
void RequestIDBIndexGetObject(const IndexedDBKey& key,
WebKit::WebIDBCallbacks* callbacks,
int32 idb_index_id,
- int transaction_id);
+ const WebKit::WebIDBTransaction& transaction);
void RequestIDBIndexGet(const IndexedDBKey& key,
WebKit::WebIDBCallbacks* callbacks,
int32 idb_index_id,
- int transaction_id);
+ const WebKit::WebIDBTransaction& transaction);
void RequestIDBObjectStoreGet(const IndexedDBKey& key,
WebKit::WebIDBCallbacks* callbacks,
int32 idb_object_store_id,
- int transaction_id);
+ const WebKit::WebIDBTransaction& transaction);
void RequestIDBObjectStorePut(const SerializedScriptValue& value,
const IndexedDBKey& key,
bool add_only,
WebKit::WebIDBCallbacks* callbacks,
int32 idb_object_store_id,
- int transaction_id);
-
- void RequestIDBObjectStoreRemove(const IndexedDBKey& key,
- WebKit::WebIDBCallbacks* callbacks,
- int32 idb_object_store_id,
- int transaction_id);
+ const WebKit::WebIDBTransaction& transaction);
- void RequestIDBObjectStoreCreateIndex(
- const string16& name, const NullableString16& key_path, bool unique,
- WebKit::WebIDBCallbacks* callbacks, int32 idb_object_store_id);
-
- void RequestIDBObjectStoreRemoveIndex(
- const string16& name, WebKit::WebIDBCallbacks* callbacks,
- int32 idb_object_store_id);
+ void RequestIDBObjectStoreRemove(
+ const IndexedDBKey& key,
+ WebKit::WebIDBCallbacks* callbacks,
+ int32 idb_object_store_id,
+ const WebKit::WebIDBTransaction& transaction);
void RequestIDBObjectStoreOpenCursor(
const WebKit::WebIDBKeyRange& idb_key_range,
unsigned short direction,
WebKit::WebIDBCallbacks* callbacks,
int32 idb_object_store_id,
- int transaction_id);
+ const WebKit::WebIDBTransaction& transaction);
+
+ void RegisterWebIDBTransactionCallbacks(
+ WebKit::WebIDBTransactionCallbacks* callbacks,
+ int32 id);
- void RequestIDBTransactionSetCallbacks(
- WebKit::WebIDBTransactionCallbacks* callbacks);
+ static int32 TransactionId(const WebKit::WebIDBTransaction& transaction);
private:
// IDBCallback message handlers.
@@ -128,12 +116,15 @@ class IndexedDBDispatcher {
void OnSuccessIDBDatabase(int32 response_id, int32 object_id);
void OnSuccessIndexedDBKey(int32 response_id, const IndexedDBKey& key);
void OnSuccessIDBObjectStore(int32 response_id, int32 object_id);
+ void OnSuccessIDBTransaction(int32 response_id, int32 object_id);
void OnSuccessIDBIndex(int32 response_id, int32 object_id);
void OnSuccessOpenCursor(int32 response_id, int32 object_id);
void OnSuccessSerializedScriptValue(int32 response_id,
const SerializedScriptValue& value);
void OnError(int32 response_id, int code, const string16& message);
- void OnAbort(int transaction_id);
+ void OnAbort(int32 transaction_id);
+ void OnComplete(int32 transaction_id);
+ void OnTimeout(int32 transaction_id);
// Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be
// destroyed and used on the same thread it was created on.
diff --git a/chrome/renderer/renderer_webidbdatabase_impl.cc b/chrome/renderer/renderer_webidbdatabase_impl.cc
index fb8b607..56d7f02 100644
--- a/chrome/renderer/renderer_webidbdatabase_impl.cc
+++ b/chrome/renderer/renderer_webidbdatabase_impl.cc
@@ -5,8 +5,10 @@
#include "chrome/renderer/renderer_webidbdatabase_impl.h"
#include "chrome/common/render_messages.h"
+#include "chrome/common/render_messages_params.h"
#include "chrome/renderer/render_thread.h"
#include "chrome/renderer/indexed_db_dispatcher.h"
+#include "chrome/renderer/renderer_webidbobjectstore_impl.h"
#include "chrome/renderer/renderer_webidbtransaction_impl.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
@@ -61,21 +63,33 @@ WebDOMStringList RendererWebIDBDatabaseImpl::objectStores() const {
return webResult;
}
-void RendererWebIDBDatabaseImpl::createObjectStore(
- const WebString& name, const WebString& key_path, bool auto_increment,
- WebIDBCallbacks* callbacks) {
- IndexedDBDispatcher* dispatcher =
- RenderThread::current()->indexed_db_dispatcher();
- dispatcher->RequestIDBDatabaseCreateObjectStore(
- name, key_path, auto_increment, callbacks, idb_database_id_);
+WebKit::WebIDBObjectStore* RendererWebIDBDatabaseImpl::createObjectStore(
+ const WebKit::WebString& name,
+ const WebKit::WebString& key_path,
+ bool auto_increment,
+ const WebKit::WebIDBTransaction& transaction) {
+ ViewHostMsg_IDBDatabaseCreateObjectStore_Params params;
+ params.name_ = name;
+ params.key_path_ = key_path;
+ params.auto_increment_ = auto_increment;
+ params.transaction_id_ = IndexedDBDispatcher::TransactionId(transaction);
+ params.idb_database_id_ = idb_database_id_;
+
+ int object_store;
+ RenderThread::current()->Send(
+ new ViewHostMsg_IDBDatabaseCreateObjectStore(params, &object_store));
+ if (!object_store)
+ return NULL;
+ return new RendererWebIDBObjectStoreImpl(object_store);
}
void RendererWebIDBDatabaseImpl::removeObjectStore(
- const WebString& name, WebIDBCallbacks* callbacks) {
- IndexedDBDispatcher* dispatcher =
- RenderThread::current()->indexed_db_dispatcher();
- dispatcher->RequestIDBDatabaseRemoveObjectStore(
- name, callbacks, idb_database_id_);
+ const WebString& name,
+ const WebIDBTransaction& transaction) {
+ RenderThread::current()->Send(
+ new ViewHostMsg_IDBDatabaseRemoveObjectStore(
+ idb_database_id_, name,
+ IndexedDBDispatcher::TransactionId(transaction)));
}
void RendererWebIDBDatabaseImpl::setVersion(
diff --git a/chrome/renderer/renderer_webidbdatabase_impl.h b/chrome/renderer/renderer_webidbdatabase_impl.h
index b315344..8c12436 100644
--- a/chrome/renderer/renderer_webidbdatabase_impl.h
+++ b/chrome/renderer/renderer_webidbdatabase_impl.h
@@ -27,11 +27,14 @@ class RendererWebIDBDatabaseImpl : public WebKit::WebIDBDatabase {
virtual WebKit::WebString description() const;
virtual WebKit::WebString version() const;
virtual WebKit::WebDOMStringList objectStores() const;
- virtual void createObjectStore(
- const WebKit::WebString& name, const WebKit::WebString& key_path,
- bool auto_increment, WebKit::WebIDBCallbacks* callbacks);
+ virtual WebKit::WebIDBObjectStore* createObjectStore(
+ const WebKit::WebString& name,
+ const WebKit::WebString& key_path,
+ bool auto_increment,
+ const WebKit::WebIDBTransaction& transaction);
virtual void removeObjectStore(
- const WebKit::WebString& name, WebKit::WebIDBCallbacks* callbacks);
+ const WebKit::WebString& name,
+ const WebKit::WebIDBTransaction& transaction);
virtual void setVersion(
const WebKit::WebString& version, WebKit::WebIDBCallbacks* callbacks);
virtual WebKit::WebIDBTransaction* transaction(
diff --git a/chrome/renderer/renderer_webidbindex_impl.cc b/chrome/renderer/renderer_webidbindex_impl.cc
index 5f9a36d..14c9e4c 100644
--- a/chrome/renderer/renderer_webidbindex_impl.cc
+++ b/chrome/renderer/renderer_webidbindex_impl.cc
@@ -61,10 +61,10 @@ void RendererWebIDBIndexImpl::openObjectCursor(
IndexedDBDispatcher* dispatcher =
RenderThread::current()->indexed_db_dispatcher();
dispatcher->RequestIDBIndexOpenObjectCursor(
- range, direction, callbacks, idb_index_id_, transaction.id());
+ range, direction, callbacks, idb_index_id_, transaction);
}
-void RendererWebIDBIndexImpl::openCursor(
+void RendererWebIDBIndexImpl::openKeyCursor(
const WebKit::WebIDBKeyRange& range,
unsigned short direction,
WebKit::WebIDBCallbacks* callbacks,
@@ -72,7 +72,7 @@ void RendererWebIDBIndexImpl::openCursor(
IndexedDBDispatcher* dispatcher =
RenderThread::current()->indexed_db_dispatcher();
dispatcher->RequestIDBIndexOpenCursor(
- range, direction, callbacks, idb_index_id_, transaction.id());
+ range, direction, callbacks, idb_index_id_, transaction);
}
void RendererWebIDBIndexImpl::getObject(
@@ -82,15 +82,15 @@ void RendererWebIDBIndexImpl::getObject(
IndexedDBDispatcher* dispatcher =
RenderThread::current()->indexed_db_dispatcher();
dispatcher->RequestIDBIndexGetObject(
- IndexedDBKey(key), callbacks, idb_index_id_, transaction.id());
+ IndexedDBKey(key), callbacks, idb_index_id_, transaction);
}
-void RendererWebIDBIndexImpl::get(
+void RendererWebIDBIndexImpl::getKey(
const WebKit::WebIDBKey& key,
WebKit::WebIDBCallbacks* callbacks,
const WebKit::WebIDBTransaction& transaction) {
IndexedDBDispatcher* dispatcher =
RenderThread::current()->indexed_db_dispatcher();
dispatcher->RequestIDBIndexGet(
- IndexedDBKey(key), callbacks, idb_index_id_, transaction.id());
+ IndexedDBKey(key), callbacks, idb_index_id_, transaction);
}
diff --git a/chrome/renderer/renderer_webidbindex_impl.h b/chrome/renderer/renderer_webidbindex_impl.h
index 1faab64..8283109 100644
--- a/chrome/renderer/renderer_webidbindex_impl.h
+++ b/chrome/renderer/renderer_webidbindex_impl.h
@@ -24,16 +24,16 @@ class RendererWebIDBIndexImpl : public WebKit::WebIDBIndex {
unsigned short direction,
WebKit::WebIDBCallbacks* callbacks,
const WebKit::WebIDBTransaction& transaction);
- virtual void openCursor(const WebKit::WebIDBKeyRange& range,
- unsigned short direction,
- WebKit::WebIDBCallbacks* callbacks,
- const WebKit::WebIDBTransaction& transaction);
+ virtual void openKeyCursor(const WebKit::WebIDBKeyRange& range,
+ unsigned short direction,
+ WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebIDBTransaction& transaction);
virtual void getObject(const WebKit::WebIDBKey& key,
WebKit::WebIDBCallbacks* callbacks,
const WebKit::WebIDBTransaction& transaction);
- virtual void get(const WebKit::WebIDBKey& key,
- WebKit::WebIDBCallbacks* callbacks,
- const WebKit::WebIDBTransaction& transaction);
+ virtual void getKey(const WebKit::WebIDBKey& key,
+ WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebIDBTransaction& transaction);
private:
int32 idb_index_id_;
diff --git a/chrome/renderer/renderer_webidbobjectstore_impl.cc b/chrome/renderer/renderer_webidbobjectstore_impl.cc
index ce456dd1..8d0aa6d 100644
--- a/chrome/renderer/renderer_webidbobjectstore_impl.cc
+++ b/chrome/renderer/renderer_webidbobjectstore_impl.cc
@@ -6,6 +6,7 @@
#include "chrome/common/indexed_db_key.h"
#include "chrome/common/render_messages.h"
+#include "chrome/common/render_messages_params.h"
#include "chrome/common/serialized_script_value.h"
#include "chrome/renderer/indexed_db_dispatcher.h"
#include "chrome/renderer/render_thread.h"
@@ -71,7 +72,7 @@ void RendererWebIDBObjectStoreImpl::get(
IndexedDBDispatcher* dispatcher =
RenderThread::current()->indexed_db_dispatcher();
dispatcher->RequestIDBObjectStoreGet(
- IndexedDBKey(key), callbacks, idb_object_store_id_, transaction.id());
+ IndexedDBKey(key), callbacks, idb_object_store_id_, transaction);
}
void RendererWebIDBObjectStoreImpl::put(
@@ -84,7 +85,7 @@ void RendererWebIDBObjectStoreImpl::put(
RenderThread::current()->indexed_db_dispatcher();
dispatcher->RequestIDBObjectStorePut(
SerializedScriptValue(value), IndexedDBKey(key), add_only, callbacks,
- idb_object_store_id_, transaction.id());
+ idb_object_store_id_, transaction);
}
void RendererWebIDBObjectStoreImpl::remove(
@@ -94,36 +95,46 @@ void RendererWebIDBObjectStoreImpl::remove(
IndexedDBDispatcher* dispatcher =
RenderThread::current()->indexed_db_dispatcher();
dispatcher->RequestIDBObjectStoreRemove(
- IndexedDBKey(key), callbacks, idb_object_store_id_, transaction.id());
+ IndexedDBKey(key), callbacks, idb_object_store_id_, transaction);
}
-void RendererWebIDBObjectStoreImpl::createIndex(
- const WebString& name, const WebString& key_path, bool unique,
- WebIDBCallbacks* callbacks) {
- IndexedDBDispatcher* dispatcher =
- RenderThread::current()->indexed_db_dispatcher();
- dispatcher->RequestIDBObjectStoreCreateIndex(
- name, key_path, unique, callbacks, idb_object_store_id_);
-
+WebKit::WebIDBIndex* RendererWebIDBObjectStoreImpl::createIndex(
+ const WebKit::WebString& name,
+ const WebKit::WebString& key_path,
+ bool unique,
+ const WebKit::WebIDBTransaction& transaction) {
+ ViewHostMsg_IDBObjectStoreCreateIndex_Params params;
+ params.name_ = name;
+ params.key_path_ = key_path;
+ params.unique_ = unique;
+ params.transaction_id_ = IndexedDBDispatcher::TransactionId(transaction);
+ params.idb_object_store_id_ = idb_object_store_id_;
+
+ int32 index_id;
+ RenderThread::current()->Send(
+ new ViewHostMsg_IDBObjectStoreCreateIndex(params, &index_id));
+ if (!index_id)
+ return NULL;
+ return new RendererWebIDBIndexImpl(index_id);
}
WebIDBIndex* RendererWebIDBObjectStoreImpl::index(const WebString& name) {
- bool success;
int32 idb_index_id;
RenderThread::current()->Send(
new ViewHostMsg_IDBObjectStoreIndex(idb_object_store_id_, name,
- &success, &idb_index_id));
- if (!success)
+ &idb_index_id));
+ if (!idb_index_id)
return NULL;
return new RendererWebIDBIndexImpl(idb_index_id);
}
-void RendererWebIDBObjectStoreImpl::removeIndex(const WebString& name,
- WebIDBCallbacks* callbacks) {
- IndexedDBDispatcher* dispatcher =
- RenderThread::current()->indexed_db_dispatcher();
- dispatcher->RequestIDBObjectStoreRemoveIndex(name, callbacks,
- idb_object_store_id_);
+void RendererWebIDBObjectStoreImpl::removeIndex(
+ const WebString& name,
+ const WebKit::WebIDBTransaction& transaction) {
+ RenderThread::current()->Send(
+ new ViewHostMsg_IDBObjectStoreRemoveIndex(
+ idb_object_store_id_, name,
+ IndexedDBDispatcher::TransactionId(transaction)));
}
void RendererWebIDBObjectStoreImpl::openCursor(
@@ -134,5 +145,5 @@ void RendererWebIDBObjectStoreImpl::openCursor(
RenderThread::current()->indexed_db_dispatcher();
dispatcher->RequestIDBObjectStoreOpenCursor(
idb_key_range, direction, callbacks, idb_object_store_id_,
- transaction.id());
+ transaction);
}
diff --git a/chrome/renderer/renderer_webidbobjectstore_impl.h b/chrome/renderer/renderer_webidbobjectstore_impl.h
index 1cca553..210a03c 100644
--- a/chrome/renderer/renderer_webidbobjectstore_impl.h
+++ b/chrome/renderer/renderer_webidbobjectstore_impl.h
@@ -41,14 +41,15 @@ class RendererWebIDBObjectStoreImpl : public WebKit::WebIDBObjectStore {
WebKit::WebIDBCallbacks* callbacks,
const WebKit::WebIDBTransaction& transaction);
- void createIndex(const WebKit::WebString& name,
- const WebKit::WebString& key_path,
- bool unique,
- WebKit::WebIDBCallbacks* callbacks);
+ WebKit::WebIDBIndex* createIndex(
+ const WebKit::WebString& name,
+ const WebKit::WebString& key_path,
+ bool unique,
+ const WebKit::WebIDBTransaction& transaction);
// Transfers ownership of the WebIDBIndex to the caller.
WebKit::WebIDBIndex* index(const WebKit::WebString& name);
void removeIndex(const WebKit::WebString& name,
- WebKit::WebIDBCallbacks* callbacks);
+ const WebKit::WebIDBTransaction&);
void openCursor(const WebKit::WebIDBKeyRange& idb_key_range,
unsigned short direction,
diff --git a/chrome/renderer/renderer_webidbtransaction_impl.cc b/chrome/renderer/renderer_webidbtransaction_impl.cc
index 3aa2387..f918275 100644
--- a/chrome/renderer/renderer_webidbtransaction_impl.cc
+++ b/chrome/renderer/renderer_webidbtransaction_impl.cc
@@ -28,9 +28,10 @@ RendererWebIDBTransactionImpl::~RendererWebIDBTransactionImpl() {
int RendererWebIDBTransactionImpl::mode() const
{
- // TODO: implement
- DCHECK(false);
- return 0;
+ int mode;
+ RenderThread::current()->Send(new ViewHostMsg_IDBTransactionMode(
+ idb_transaction_id_, &mode));
+ return mode;
}
WebIDBObjectStore* RendererWebIDBTransactionImpl::objectStore(
@@ -58,15 +59,11 @@ void RendererWebIDBTransactionImpl::didCompleteTaskEvents()
idb_transaction_id_));
}
-int RendererWebIDBTransactionImpl::id() const
-{
- return idb_transaction_id_;
-}
-
void RendererWebIDBTransactionImpl::setCallbacks(
WebIDBTransactionCallbacks* callbacks)
{
IndexedDBDispatcher* dispatcher =
RenderThread::current()->indexed_db_dispatcher();
- dispatcher->RequestIDBTransactionSetCallbacks(callbacks);
+ dispatcher->RegisterWebIDBTransactionCallbacks(callbacks,
+ idb_transaction_id_);
}
diff --git a/chrome/renderer/renderer_webidbtransaction_impl.h b/chrome/renderer/renderer_webidbtransaction_impl.h
index d1f74fb..728bafe 100644
--- a/chrome/renderer/renderer_webidbtransaction_impl.h
+++ b/chrome/renderer/renderer_webidbtransaction_impl.h
@@ -24,9 +24,10 @@ class RendererWebIDBTransactionImpl : public WebKit::WebIDBTransaction {
virtual WebKit::WebIDBObjectStore* objectStore(const WebKit::WebString& name);
virtual void abort();
virtual void didCompleteTaskEvents();
- virtual int id() const;
virtual void setCallbacks(WebKit::WebIDBTransactionCallbacks*);
+ int id() const { return idb_transaction_id_; }
+
private:
int32 idb_transaction_id_;
};
diff --git a/webkit/glue/idb_bindings.cc b/webkit/glue/idb_bindings.cc
index fd26130..4af085f 100644
--- a/webkit/glue/idb_bindings.cc
+++ b/webkit/glue/idb_bindings.cc
@@ -20,35 +20,11 @@ using WebKit::WebIDBKey;
using WebKit::WebIDBKeyPath;
using WebKit::WebSerializedScriptValue;
-namespace {
-
-class LocalContext {
- public:
- LocalContext()
- : context_(v8::Context::New()) {
- context_->Enter();
- }
-
- virtual ~LocalContext() {
- context_->Exit();
- context_.Dispose();
- }
-
- private:
- v8::Locker lock_;
- v8::HandleScope scope_;
- v8::Persistent<v8::Context> context_;
-
- DISALLOW_COPY_AND_ASSIGN(LocalContext);
-};
-
-} // namespace
-
bool IDBKeysFromValuesAndKeyPath(
const std::vector<WebSerializedScriptValue>& serialized_script_values,
const string16& idb_key_path,
std::vector<WebIDBKey>* values) {
- LocalContext env;
+ v8::Locker lock;
WebIDBKeyPath web_idb_key_path = WebIDBKeyPath::create(idb_key_path);
bool error = web_idb_key_path.parseError() != 0;
// TODO(bulach): what to do when we have a parse error? For now, setting