diff options
author | alecflett@chromium.org <alecflett@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-19 02:35:33 +0000 |
---|---|---|
committer | alecflett@chromium.org <alecflett@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-19 02:35:33 +0000 |
commit | 9fee277fa201cc1c1290dad08d5898130308cef4 (patch) | |
tree | f6f222ce99ee1dd57e0b4411ec79b723ae34985f /content | |
parent | 05b6a82cc9bb9215c8e86ce6113c537e9da1064d (diff) | |
download | chromium_src-9fee277fa201cc1c1290dad08d5898130308cef4.zip chromium_src-9fee277fa201cc1c1290dad08d5898130308cef4.tar.gz chromium_src-9fee277fa201cc1c1290dad08d5898130308cef4.tar.bz2 |
IndexedDB: Support get/getKey(keyRange)
This is the Chromium IPC plumbing to talk to the WebKit API.
This won't be used until https://bugs.webkit.org/show_bug.cgi?id=83638
is fixed.
BUG=92047
Review URL: http://codereview.chromium.org/10083053
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132918 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
9 files changed, 231 insertions, 0 deletions
diff --git a/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc b/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc index 38f94fa..4c5bee6 100644 --- a/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc +++ b/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc @@ -506,7 +506,10 @@ bool IndexedDBDispatcherHost::IndexDispatcherHost::OnMessageReceived( IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexOpenKeyCursor, OnOpenKeyCursor) IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexCount, OnCount) IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetObject, OnGetObject) + IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetObjectByRange, + OnGetObjectByRange) IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetKey, OnGetKey) + IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetKeyByRange, OnGetKeyByRange) IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexDestroyed, OnDestroyed) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -632,6 +635,28 @@ void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetObject( idb_index->getObject(key, callbacks.release(), *idb_transaction, *ec); } +void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetObjectByRange( + int idb_index_id, + int32 thread_id, + int32 response_id, + const IndexedDBKeyRange& key_range, + int32 transaction_id, + WebKit::WebExceptionCode* ec) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); + WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( + &map_, idb_index_id); + WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( + &parent_->transaction_dispatcher_host_->map_, transaction_id); + if (!idb_transaction || !idb_index) + return; + + *ec = 0; + scoped_ptr<WebIDBCallbacks> callbacks( + new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, thread_id, + response_id)); + idb_index->getObject(key_range, callbacks.release(), *idb_transaction, *ec); +} + void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetKey( int idb_index_id, int32 thread_id, @@ -653,6 +678,27 @@ void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetKey( idb_index->getKey(key, callbacks.release(), *idb_transaction, *ec); } +void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetKeyByRange( + int idb_index_id, + int32 thread_id, + int32 response_id, + const IndexedDBKeyRange& key_range, + int32 transaction_id, + WebKit::WebExceptionCode* ec) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); + WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( + &map_, idb_index_id); + WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( + &parent_->transaction_dispatcher_host_->map_, transaction_id); + if (!idb_transaction || !idb_index) + return; + + *ec = 0; + scoped_ptr<WebIDBCallbacks> callbacks( + new IndexedDBCallbacks<WebIDBKey>(parent_, thread_id, response_id)); + idb_index->getKey(key_range, callbacks.release(), *idb_transaction, *ec); +} + void IndexedDBDispatcherHost::IndexDispatcherHost::OnDestroyed( int32 object_id) { parent_->DestroyObject(&map_, object_id); @@ -681,6 +727,7 @@ bool IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnMessageReceived( IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreKeyPath, OnKeyPath) IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreIndexNames, OnIndexNames) IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreGet, OnGet) + IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreGetByRange, OnGetByRange) IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStorePut, OnPut) IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDelete, OnDelete) IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDeleteRange, OnDeleteRange) @@ -748,6 +795,28 @@ void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnGet( idb_object_store->get(key, callbacks.release(), *idb_transaction, *ec); } +void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnGetByRange( + int idb_object_store_id, + int32 thread_id, + int32 response_id, + const IndexedDBKeyRange& key_range, + int32 transaction_id, + WebKit::WebExceptionCode* ec) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); + WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( + &map_, idb_object_store_id); + WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( + &parent_->transaction_dispatcher_host_->map_, transaction_id); + if (!idb_transaction || !idb_object_store) + return; + + *ec = 0; + scoped_ptr<WebIDBCallbacks> callbacks( + new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, thread_id, + response_id)); + idb_object_store->get(key_range, callbacks.release(), *idb_transaction, *ec); +} + void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnPut( const IndexedDBHostMsg_ObjectStorePut_Params& params, WebKit::WebExceptionCode* ec) { diff --git a/content/browser/in_process_webkit/indexed_db_dispatcher_host.h b/content/browser/in_process_webkit/indexed_db_dispatcher_host.h index c59bc03..cf56fef 100644 --- a/content/browser/in_process_webkit/indexed_db_dispatcher_host.h +++ b/content/browser/in_process_webkit/indexed_db_dispatcher_host.h @@ -172,12 +172,24 @@ class IndexedDBDispatcherHost : public content::BrowserMessageFilter { const IndexedDBKey& key, int32 transaction_id, WebKit::WebExceptionCode* ec); + void OnGetObjectByRange(int idb_index_id, + int32 thread_id, + int32 response_id, + const IndexedDBKeyRange& key_range, + int32 transaction_id, + WebKit::WebExceptionCode* ec); void OnGetKey(int idb_index_id, int32 thread_id, int32 response_id, const IndexedDBKey& key, int32 transaction_id, WebKit::WebExceptionCode* ec); + void OnGetKeyByRange(int idb_index_id, + int32 thread_id, + int32 response_id, + const IndexedDBKeyRange& key_range, + int32 transaction_id, + WebKit::WebExceptionCode* ec); void OnDestroyed(int32 idb_index_id); IndexedDBDispatcherHost* parent_; @@ -202,6 +214,12 @@ class IndexedDBDispatcherHost : public content::BrowserMessageFilter { const IndexedDBKey& key, int32 transaction_id, WebKit::WebExceptionCode* ec); + void OnGetByRange(int idb_object_store_id, + int32 thread_id, + int32 response_id, + const IndexedDBKeyRange& key_range, + int32 transaction_id, + WebKit::WebExceptionCode* ec); void OnPut(const IndexedDBHostMsg_ObjectStorePut_Params& params, WebKit::WebExceptionCode* ec); void OnDelete(int idb_object_store_id, diff --git a/content/common/indexed_db/indexed_db_dispatcher.cc b/content/common/indexed_db/indexed_db_dispatcher.cc index a914f9e..ccb123f 100644 --- a/content/common/indexed_db/indexed_db_dispatcher.cc +++ b/content/common/indexed_db/indexed_db_dispatcher.cc @@ -369,6 +369,23 @@ void IndexedDBDispatcher::RequestIDBIndexGetObject( pending_callbacks_.Remove(response_id); } +void IndexedDBDispatcher::RequestIDBIndexGetObjectByRange( + const IndexedDBKeyRange& key_range, + WebIDBCallbacks* callbacks_ptr, + int32 idb_index_id, + const WebIDBTransaction& transaction, + WebExceptionCode* ec) { + ResetCursorPrefetchCaches(); + scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); + int32 response_id = pending_callbacks_.Add(callbacks.release()); + Send(new IndexedDBHostMsg_IndexGetObjectByRange( + idb_index_id, CurrentWorkerId(), + response_id, key_range, + TransactionId(transaction), ec)); + if (*ec) + pending_callbacks_.Remove(response_id); +} + void IndexedDBDispatcher::RequestIDBIndexGetKey( const IndexedDBKey& key, WebIDBCallbacks* callbacks_ptr, @@ -385,6 +402,22 @@ void IndexedDBDispatcher::RequestIDBIndexGetKey( pending_callbacks_.Remove(response_id); } +void IndexedDBDispatcher::RequestIDBIndexGetKeyByRange( + const IndexedDBKeyRange& key_range, + WebIDBCallbacks* callbacks_ptr, + int32 idb_index_id, + const WebIDBTransaction& transaction, + WebExceptionCode* ec) { + ResetCursorPrefetchCaches(); + scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); + int32 response_id = pending_callbacks_.Add(callbacks.release()); + Send(new IndexedDBHostMsg_IndexGetKeyByRange( + idb_index_id, CurrentWorkerId(), response_id, key_range, + TransactionId(transaction), ec)); + if (*ec) + pending_callbacks_.Remove(response_id); +} + void IndexedDBDispatcher::RequestIDBObjectStoreGet( const IndexedDBKey& key, WebIDBCallbacks* callbacks_ptr, @@ -402,6 +435,23 @@ void IndexedDBDispatcher::RequestIDBObjectStoreGet( pending_callbacks_.Remove(response_id); } +void IndexedDBDispatcher::RequestIDBObjectStoreGetByRange( + const IndexedDBKeyRange& key_range, + WebIDBCallbacks* callbacks_ptr, + int32 idb_object_store_id, + const WebIDBTransaction& transaction, + WebExceptionCode* ec) { + ResetCursorPrefetchCaches(); + scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); + + int32 response_id = pending_callbacks_.Add(callbacks.release()); + Send(new IndexedDBHostMsg_ObjectStoreGetByRange( + idb_object_store_id, CurrentWorkerId(), response_id, + key_range, TransactionId(transaction), ec)); + if (*ec) + pending_callbacks_.Remove(response_id); +} + void IndexedDBDispatcher::RequestIDBObjectStorePut( const content::SerializedScriptValue& value, const IndexedDBKey& key, diff --git a/content/common/indexed_db/indexed_db_dispatcher.h b/content/common/indexed_db/indexed_db_dispatcher.h index 761c035..5c6d705 100644 --- a/content/common/indexed_db/indexed_db_dispatcher.h +++ b/content/common/indexed_db/indexed_db_dispatcher.h @@ -148,18 +148,39 @@ class CONTENT_EXPORT IndexedDBDispatcher const WebKit::WebIDBTransaction& transaction, WebKit::WebExceptionCode* ec); + void RequestIDBIndexGetObjectByRange( + const IndexedDBKeyRange& key_range, + WebKit::WebIDBCallbacks* callbacks, + int32 idb_index_id, + const WebKit::WebIDBTransaction& transaction, + WebKit::WebExceptionCode* ec); + void RequestIDBIndexGetKey(const IndexedDBKey& key, WebKit::WebIDBCallbacks* callbacks, int32 idb_index_id, const WebKit::WebIDBTransaction& transaction, WebKit::WebExceptionCode* ec); + void RequestIDBIndexGetKeyByRange( + const IndexedDBKeyRange& key_range, + WebKit::WebIDBCallbacks* callbacks, + int32 idb_index_id, + const WebKit::WebIDBTransaction& transaction, + WebKit::WebExceptionCode* ec); + void RequestIDBObjectStoreGet(const IndexedDBKey& key, WebKit::WebIDBCallbacks* callbacks, int32 idb_object_store_id, const WebKit::WebIDBTransaction& transaction, WebKit::WebExceptionCode* ec); + void RequestIDBObjectStoreGetByRange( + const IndexedDBKeyRange& key_range, + WebKit::WebIDBCallbacks* callbacks, + int32 idb_object_store_id, + const WebKit::WebIDBTransaction& transaction, + WebKit::WebExceptionCode* ec); + void RequestIDBObjectStorePut(const content::SerializedScriptValue& value, const IndexedDBKey& key, WebKit::WebIDBObjectStore::PutMode putMode, diff --git a/content/common/indexed_db/indexed_db_messages.h b/content/common/indexed_db/indexed_db_messages.h index 6ca348f..f24e79a 100644 --- a/content/common/indexed_db/indexed_db_messages.h +++ b/content/common/indexed_db/indexed_db_messages.h @@ -433,6 +433,15 @@ IPC_SYNC_MESSAGE_CONTROL5_1(IndexedDBHostMsg_IndexGetObject, int32, /* transaction_id */ WebKit::WebExceptionCode /* ec */) +// WebIDBIndex::getObjectByRange() message. +IPC_SYNC_MESSAGE_CONTROL5_1(IndexedDBHostMsg_IndexGetObjectByRange, + int32, /* idb_index_id */ + int32, /* thread_id */ + int32, /* response_id */ + IndexedDBKeyRange, /* key */ + int32, /* transaction_id */ + WebKit::WebExceptionCode /* ec */) + // WebIDBIndex::getKey() message. IPC_SYNC_MESSAGE_CONTROL5_1(IndexedDBHostMsg_IndexGetKey, int32, /* idb_index_id */ @@ -442,6 +451,15 @@ IPC_SYNC_MESSAGE_CONTROL5_1(IndexedDBHostMsg_IndexGetKey, int32, /* transaction_id */ WebKit::WebExceptionCode /* ec */) +// WebIDBIndex::getKeyByRange() message. +IPC_SYNC_MESSAGE_CONTROL5_1(IndexedDBHostMsg_IndexGetKeyByRange, + int32, /* idb_index_id */ + int32, /* thread_id */ + int32, /* response_id */ + IndexedDBKeyRange, /* key */ + int32, /* transaction_id */ + WebKit::WebExceptionCode /* ec */) + // WebIDBIndex::~WebIDBIndex() message. IPC_MESSAGE_CONTROL1(IndexedDBHostMsg_IndexDestroyed, int32 /* idb_index_id */) @@ -470,6 +488,15 @@ IPC_SYNC_MESSAGE_CONTROL5_1(IndexedDBHostMsg_ObjectStoreGet, int32, /* transaction_id */ WebKit::WebExceptionCode /* ec */) +// WebIDBObjectStore::get() message. +IPC_SYNC_MESSAGE_CONTROL5_1(IndexedDBHostMsg_ObjectStoreGetByRange, + int32, /* idb_object_store_id */ + int32, /* thread_id */ + int32, /* response_id */ + IndexedDBKeyRange, /* key_range */ + int32, /* transaction_id */ + WebKit::WebExceptionCode /* ec */) + // WebIDBObjectStore::put() message. IPC_SYNC_MESSAGE_CONTROL1_1(IndexedDBHostMsg_ObjectStorePut, IndexedDBHostMsg_ObjectStorePut_Params, diff --git a/content/common/indexed_db/proxy_webidbindex_impl.cc b/content/common/indexed_db/proxy_webidbindex_impl.cc index af9034d..9171e27 100644 --- a/content/common/indexed_db/proxy_webidbindex_impl.cc +++ b/content/common/indexed_db/proxy_webidbindex_impl.cc @@ -110,6 +110,17 @@ void RendererWebIDBIndexImpl::getObject( IndexedDBKey(key), callbacks, idb_index_id_, transaction, &ec); } +void RendererWebIDBIndexImpl::getObject( + const WebKit::WebIDBKeyRange& key_range, + WebKit::WebIDBCallbacks* callbacks, + const WebKit::WebIDBTransaction& transaction, + WebExceptionCode& ec) { + IndexedDBDispatcher* dispatcher = + IndexedDBDispatcher::ThreadSpecificInstance(); + dispatcher->RequestIDBIndexGetObjectByRange( + IndexedDBKeyRange(key_range), callbacks, idb_index_id_, transaction, &ec); +} + void RendererWebIDBIndexImpl::getKey( const WebKit::WebIDBKey& key, WebKit::WebIDBCallbacks* callbacks, @@ -120,3 +131,14 @@ void RendererWebIDBIndexImpl::getKey( dispatcher->RequestIDBIndexGetKey( IndexedDBKey(key), callbacks, idb_index_id_, transaction, &ec); } + +void RendererWebIDBIndexImpl::getKey( + const WebKit::WebIDBKeyRange& key_range, + WebKit::WebIDBCallbacks* callbacks, + const WebKit::WebIDBTransaction& transaction, + WebExceptionCode& ec) { + IndexedDBDispatcher* dispatcher = + IndexedDBDispatcher::ThreadSpecificInstance(); + dispatcher->RequestIDBIndexGetKeyByRange( + IndexedDBKeyRange(key_range), callbacks, idb_index_id_, transaction, &ec); +} diff --git a/content/common/indexed_db/proxy_webidbindex_impl.h b/content/common/indexed_db/proxy_webidbindex_impl.h index 59eafb2..a5e3dda 100644 --- a/content/common/indexed_db/proxy_webidbindex_impl.h +++ b/content/common/indexed_db/proxy_webidbindex_impl.h @@ -40,10 +40,18 @@ class RendererWebIDBIndexImpl : public WebKit::WebIDBIndex { WebKit::WebIDBCallbacks* callbacks, const WebKit::WebIDBTransaction& transaction, WebKit::WebExceptionCode& ec); + virtual void getObject(const WebKit::WebIDBKeyRange& key_range, + WebKit::WebIDBCallbacks* callbacks, + const WebKit::WebIDBTransaction& transaction, + WebKit::WebExceptionCode& ec); virtual void getKey(const WebKit::WebIDBKey& key, WebKit::WebIDBCallbacks* callbacks, const WebKit::WebIDBTransaction& transaction, WebKit::WebExceptionCode& ec); + virtual void getKey(const WebKit::WebIDBKeyRange& key_range, + WebKit::WebIDBCallbacks* callbacks, + const WebKit::WebIDBTransaction& transaction, + WebKit::WebExceptionCode& ec); private: int32 idb_index_id_; diff --git a/content/common/indexed_db/proxy_webidbobjectstore_impl.cc b/content/common/indexed_db/proxy_webidbobjectstore_impl.cc index 1259bbc6..4bcfddf 100644 --- a/content/common/indexed_db/proxy_webidbobjectstore_impl.cc +++ b/content/common/indexed_db/proxy_webidbobjectstore_impl.cc @@ -80,6 +80,18 @@ void RendererWebIDBObjectStoreImpl::get( IndexedDBKey(key), callbacks, idb_object_store_id_, transaction, &ec); } +void RendererWebIDBObjectStoreImpl::get( + const WebIDBKeyRange& key_range, + WebIDBCallbacks* callbacks, + const WebIDBTransaction& transaction, + WebExceptionCode& ec) { + IndexedDBDispatcher* dispatcher = + IndexedDBDispatcher::ThreadSpecificInstance(); + dispatcher->RequestIDBObjectStoreGetByRange( + IndexedDBKeyRange(key_range), callbacks, + idb_object_store_id_, transaction, &ec); +} + void RendererWebIDBObjectStoreImpl::put( const WebSerializedScriptValue& value, const WebIDBKey& key, diff --git a/content/common/indexed_db/proxy_webidbobjectstore_impl.h b/content/common/indexed_db/proxy_webidbobjectstore_impl.h index 3c54907..610d698 100644 --- a/content/common/indexed_db/proxy_webidbobjectstore_impl.h +++ b/content/common/indexed_db/proxy_webidbobjectstore_impl.h @@ -32,6 +32,10 @@ class RendererWebIDBObjectStoreImpl : public WebKit::WebIDBObjectStore { WebKit::WebIDBCallbacks* callbacks, const WebKit::WebIDBTransaction& transaction, WebKit::WebExceptionCode& ec); + virtual void get(const WebKit::WebIDBKeyRange& key_range, + WebKit::WebIDBCallbacks* callbacks, + const WebKit::WebIDBTransaction& transaction, + WebKit::WebExceptionCode& ec); virtual void put(const WebKit::WebSerializedScriptValue& value, const WebKit::WebIDBKey& key, PutMode put_mode, |