summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/indexed_db_dispatcher.cc
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/indexed_db_dispatcher.cc
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/indexed_db_dispatcher.cc')
-rw-r--r--chrome/renderer/indexed_db_dispatcher.cc172
1 files changed, 80 insertions, 92 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);
+}