summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
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 /chrome/renderer
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
Diffstat (limited to 'chrome/renderer')
-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
10 files changed, 194 insertions, 188 deletions
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_;
};