Chromium glue for Preemptive cursors and passing keys from renderer to browser

This will allow indexing to happen renderer-side

BUG=134493


Review URL: https://chromiumcodereview.appspot.com/10830228

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151047 0039d316-1c4b-4281-b951-d872f2087c98
parent 2487bee4
...@@ -643,6 +643,10 @@ bool IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnMessageReceived( ...@@ -643,6 +643,10 @@ bool IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnMessageReceived(
message, *msg_is_ok) message, *msg_is_ok)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreGet, OnGet) IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreGet, OnGet)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStorePut, OnPut) IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStorePut, OnPut)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreSetIndexKeys,
OnSetIndexKeys)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreSetIndexesReady,
OnSetIndexesReady)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDelete, OnDelete) IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDelete, OnDelete)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreClear, OnClear) IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreClear, OnClear)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCreateIndex, OnCreateIndex) IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCreateIndex, OnCreateIndex)
...@@ -710,6 +714,38 @@ void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnPut( ...@@ -710,6 +714,38 @@ void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnPut(
(*map)[params.transaction_id] += size; (*map)[params.transaction_id] += size;
} }
void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnSetIndexKeys(
int32 idb_object_store_id,
const content::IndexedDBKey& primary_key,
const std::vector<string16>& index_names,
const std::vector<std::vector<content::IndexedDBKey> >& index_keys,
int32 transaction_id) {
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;
idb_object_store->setIndexKeys(primary_key, index_names,
index_keys, *idb_transaction);
}
void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnSetIndexesReady(
int32 idb_object_store_id,
const std::vector<string16>& index_names,
int32 transaction_id) {
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;
idb_object_store->setIndexesReady(index_names, *idb_transaction);
}
void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDelete( void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDelete(
int idb_object_store_id, int idb_object_store_id,
int32 thread_id, int32 thread_id,
...@@ -828,6 +864,7 @@ void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnOpenCursor( ...@@ -828,6 +864,7 @@ void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnOpenCursor(
params.response_id, -1)); params.response_id, -1));
idb_object_store->openCursor( idb_object_store->openCursor(
params.key_range, params.direction, callbacks.release(), params.key_range, params.direction, callbacks.release(),
params.task_type,
*idb_transaction, *ec); *idb_transaction, *ec);
} }
......
...@@ -191,6 +191,16 @@ class IndexedDBDispatcherHost : public content::BrowserMessageFilter { ...@@ -191,6 +191,16 @@ class IndexedDBDispatcherHost : public content::BrowserMessageFilter {
WebKit::WebExceptionCode* ec); WebKit::WebExceptionCode* ec);
void OnPut(const IndexedDBHostMsg_ObjectStorePut_Params& params, void OnPut(const IndexedDBHostMsg_ObjectStorePut_Params& params,
WebKit::WebExceptionCode* ec); WebKit::WebExceptionCode* ec);
void OnSetIndexKeys(
int32 idb_object_store_id,
const content::IndexedDBKey& primary_key,
const std::vector<string16>& index_names,
const std::vector<std::vector<content::IndexedDBKey> >& index_keys,
int32 transaction_id);
void OnSetIndexesReady(int32 idb_object_store_id,
const std::vector<string16>& names,
int32 transaction_id);
void OnDelete(int idb_object_store_id, void OnDelete(int idb_object_store_id,
int32 thread_id, int32 thread_id,
int32 response_id, int32 response_id,
......
...@@ -483,9 +483,10 @@ void IndexedDBDispatcher::RequestIDBObjectStoreClear( ...@@ -483,9 +483,10 @@ void IndexedDBDispatcher::RequestIDBObjectStoreClear(
void IndexedDBDispatcher::RequestIDBObjectStoreOpenCursor( void IndexedDBDispatcher::RequestIDBObjectStoreOpenCursor(
const WebIDBKeyRange& idb_key_range, const WebIDBKeyRange& idb_key_range,
unsigned short direction, WebKit::WebIDBCursor::Direction direction,
WebIDBCallbacks* callbacks_ptr, WebIDBCallbacks* callbacks_ptr,
int32 idb_object_store_id, int32 idb_object_store_id,
WebKit::WebIDBTransaction::TaskType task_type,
const WebIDBTransaction& transaction, const WebIDBTransaction& transaction,
WebExceptionCode* ec) { WebExceptionCode* ec) {
ResetCursorPrefetchCaches(); ResetCursorPrefetchCaches();
...@@ -496,6 +497,7 @@ void IndexedDBDispatcher::RequestIDBObjectStoreOpenCursor( ...@@ -496,6 +497,7 @@ void IndexedDBDispatcher::RequestIDBObjectStoreOpenCursor(
params.key_range = IndexedDBKeyRange(idb_key_range); params.key_range = IndexedDBKeyRange(idb_key_range);
params.direction = direction; params.direction = direction;
params.idb_object_store_id = idb_object_store_id; params.idb_object_store_id = idb_object_store_id;
params.task_type = task_type;
params.transaction_id = TransactionId(transaction); params.transaction_id = TransactionId(transaction);
Send(new IndexedDBHostMsg_ObjectStoreOpenCursor(params, ec)); Send(new IndexedDBHostMsg_ObjectStoreOpenCursor(params, ec));
if (*ec) if (*ec)
......
...@@ -14,9 +14,11 @@ ...@@ -14,9 +14,11 @@
#include "ipc/ipc_sync_message_filter.h" #include "ipc/ipc_sync_message_filter.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebExceptionCode.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebExceptionCode.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseCallbacks.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseCallbacks.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransactionCallbacks.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransactionCallbacks.h"
#include "webkit/glue/worker_task_runner.h" #include "webkit/glue/worker_task_runner.h"
...@@ -33,7 +35,6 @@ class Message; ...@@ -33,7 +35,6 @@ class Message;
namespace WebKit { namespace WebKit {
class WebFrame; class WebFrame;
class WebIDBKeyRange; class WebIDBKeyRange;
class WebIDBTransaction;
} }
namespace content { namespace content {
...@@ -191,9 +192,10 @@ class CONTENT_EXPORT IndexedDBDispatcher ...@@ -191,9 +192,10 @@ class CONTENT_EXPORT IndexedDBDispatcher
void RequestIDBObjectStoreOpenCursor( void RequestIDBObjectStoreOpenCursor(
const WebKit::WebIDBKeyRange& idb_key_range, const WebKit::WebIDBKeyRange& idb_key_range,
unsigned short direction, WebKit::WebIDBCursor::Direction direction,
WebKit::WebIDBCallbacks* callbacks, WebKit::WebIDBCallbacks* callbacks,
int32 idb_object_store_id, int32 idb_object_store_id,
WebKit::WebIDBTransaction::TaskType task_type,
const WebKit::WebIDBTransaction& transaction, const WebKit::WebIDBTransaction& transaction,
WebKit::WebExceptionCode* ec); WebKit::WebExceptionCode* ec);
......
...@@ -15,14 +15,18 @@ ...@@ -15,14 +15,18 @@
#include "ipc/ipc_message_macros.h" #include "ipc/ipc_message_macros.h"
#include "ipc/ipc_param_traits.h" #include "ipc/ipc_param_traits.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebExceptionCode.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebExceptionCode.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBMetadata.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBMetadata.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h"
#define IPC_MESSAGE_START IndexedDBMsgStart #define IPC_MESSAGE_START IndexedDBMsgStart
// Argument structures used in messages // Argument structures used in messages
IPC_ENUM_TRAITS(WebKit::WebIDBObjectStore::PutMode) IPC_ENUM_TRAITS(WebKit::WebIDBObjectStore::PutMode)
IPC_ENUM_TRAITS(WebKit::WebIDBCursor::Direction)
IPC_ENUM_TRAITS(WebKit::WebIDBTransaction::TaskType)
// Used to enumerate indexed databases. // Used to enumerate indexed databases.
IPC_STRUCT_BEGIN(IndexedDBHostMsg_FactoryGetDatabaseNames_Params) IPC_STRUCT_BEGIN(IndexedDBHostMsg_FactoryGetDatabaseNames_Params)
...@@ -146,7 +150,9 @@ IPC_STRUCT_BEGIN(IndexedDBHostMsg_ObjectStoreOpenCursor_Params) ...@@ -146,7 +150,9 @@ IPC_STRUCT_BEGIN(IndexedDBHostMsg_ObjectStoreOpenCursor_Params)
// The serialized key range. // The serialized key range.
IPC_STRUCT_MEMBER(content::IndexedDBKeyRange, key_range) IPC_STRUCT_MEMBER(content::IndexedDBKeyRange, key_range)
// The direction of this cursor. // The direction of this cursor.
IPC_STRUCT_MEMBER(int32, direction) IPC_STRUCT_MEMBER(WebKit::WebIDBCursor::Direction, direction)
// The priority of this cursor.
IPC_STRUCT_MEMBER(WebKit::WebIDBTransaction::TaskType, task_type)
// The object store the cursor belongs to. // The object store the cursor belongs to.
IPC_STRUCT_MEMBER(int32, idb_object_store_id) IPC_STRUCT_MEMBER(int32, idb_object_store_id)
// The transaction this request belongs to. // The transaction this request belongs to.
...@@ -454,6 +460,21 @@ IPC_SYNC_MESSAGE_CONTROL1_1(IndexedDBHostMsg_ObjectStorePut, ...@@ -454,6 +460,21 @@ IPC_SYNC_MESSAGE_CONTROL1_1(IndexedDBHostMsg_ObjectStorePut,
IndexedDBHostMsg_ObjectStorePut_Params, IndexedDBHostMsg_ObjectStorePut_Params,
WebKit::WebExceptionCode /* ec */) WebKit::WebExceptionCode /* ec */)
// WebIDBObjectStore::setIndexKeys() message.
IPC_MESSAGE_CONTROL5(IndexedDBHostMsg_ObjectStoreSetIndexKeys,
int32, /* idb_object_store_id */
content::IndexedDBKey, /* primary_key */
std::vector<string16>, /* index_names */
std::vector<std::vector<content::IndexedDBKey> >,
/* index_keys */
int32 /* transaction_id */)
// WebIDBObjectStore::setIndexesReady() message.
IPC_MESSAGE_CONTROL3(IndexedDBHostMsg_ObjectStoreSetIndexesReady,
int32, /* idb_object_store_id */
std::vector<string16>, /* index_names */
int32 /* transaction_id */)
// WebIDBObjectStore::delete() message. // WebIDBObjectStore::delete() message.
IPC_SYNC_MESSAGE_CONTROL5_1(IndexedDBHostMsg_ObjectStoreDelete, IPC_SYNC_MESSAGE_CONTROL5_1(IndexedDBHostMsg_ObjectStoreDelete,
int32, /* idb_object_store_id */ int32, /* idb_object_store_id */
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "content/common/indexed_db/proxy_webidbobjectstore_impl.h" #include "content/common/indexed_db/proxy_webidbobjectstore_impl.h"
#include <vector>
#include "content/common/indexed_db/indexed_db_messages.h" #include "content/common/indexed_db/indexed_db_messages.h"
#include "content/public/common/serialized_script_value.h" #include "content/public/common/serialized_script_value.h"
#include "content/common/indexed_db/indexed_db_dispatcher.h" #include "content/common/indexed_db/indexed_db_dispatcher.h"
...@@ -67,17 +69,58 @@ void RendererWebIDBObjectStoreImpl::putWithIndexKeys( ...@@ -67,17 +69,58 @@ void RendererWebIDBObjectStoreImpl::putWithIndexKeys(
PutMode put_mode, PutMode put_mode,
WebIDBCallbacks* callbacks, WebIDBCallbacks* callbacks,
const WebIDBTransaction& transaction, const WebIDBTransaction& transaction,
const WebVector<WebString>& indexNames, const WebVector<WebString>& index_names,
const WebVector<WebVector<WebIDBKey> >& indexKeys, const WebVector<WebVector<WebIDBKey> >& index_keys,
WebExceptionCode& ec) { WebExceptionCode& ec) {
IndexedDBDispatcher* dispatcher = IndexedDBDispatcher* dispatcher =
IndexedDBDispatcher::ThreadSpecificInstance(); IndexedDBDispatcher::ThreadSpecificInstance();
dispatcher->RequestIDBObjectStorePut( dispatcher->RequestIDBObjectStorePut(
SerializedScriptValue(value), IndexedDBKey(key), SerializedScriptValue(value), IndexedDBKey(key),
put_mode, callbacks, idb_object_store_id_, transaction, put_mode, callbacks, idb_object_store_id_, transaction,
indexNames, indexKeys, &ec); index_names, index_keys, &ec);
}
void RendererWebIDBObjectStoreImpl::setIndexKeys(
const WebKit::WebIDBKey& primaryKey,
const WebKit::WebVector<WebKit::WebString>& index_names,
const WebKit::WebVector<WebIndexKeys>& index_keys,
const WebKit::WebIDBTransaction& transaction) {
std::vector<string16> index_names_list(index_names.size());
for (size_t i = 0; i < index_names.size(); ++i) {
index_names_list[i] = index_names[i];
}
std::vector<std::vector<content::IndexedDBKey> >
index_keys_list(index_keys.size());
for (size_t i = 0; i < index_keys.size(); ++i) {
index_keys_list[i].resize(index_keys[i].size());
for (size_t j = 0; j < index_keys[i].size(); ++j) {
index_keys_list[i][j] = content::IndexedDBKey(index_keys[i][j]);
}
}
IndexedDBDispatcher::Send(new IndexedDBHostMsg_ObjectStoreSetIndexKeys(
idb_object_store_id_,
IndexedDBKey(primaryKey),
index_names_list,
index_keys_list,
IndexedDBDispatcher::TransactionId(transaction)));
} }
void RendererWebIDBObjectStoreImpl::setIndexesReady(
const WebKit::WebVector<WebKit::WebString>& index_names,
const WebKit::WebIDBTransaction& transaction) {
std::vector<string16> index_name_list(index_names.size());
for (size_t i = 0; i < index_names.size(); ++i) {
index_name_list[i] = index_names[i];
}
IndexedDBDispatcher::Send(new IndexedDBHostMsg_ObjectStoreSetIndexesReady(
idb_object_store_id_,
index_name_list, IndexedDBDispatcher::TransactionId(transaction)));
}
void RendererWebIDBObjectStoreImpl::deleteFunction( void RendererWebIDBObjectStoreImpl::deleteFunction(
const WebIDBKeyRange& key_range, const WebIDBKeyRange& key_range,
WebIDBCallbacks* callbacks, WebIDBCallbacks* callbacks,
...@@ -147,14 +190,28 @@ void RendererWebIDBObjectStoreImpl::deleteIndex( ...@@ -147,14 +190,28 @@ void RendererWebIDBObjectStoreImpl::deleteIndex(
void RendererWebIDBObjectStoreImpl::openCursor( void RendererWebIDBObjectStoreImpl::openCursor(
const WebIDBKeyRange& idb_key_range, const WebIDBKeyRange& idb_key_range,
unsigned short direction, WebIDBCallbacks* callbacks, WebKit::WebIDBCursor::Direction direction, WebIDBCallbacks* callbacks,
WebKit::WebIDBTransaction::TaskType task_type,
const WebIDBTransaction& transaction, const WebIDBTransaction& transaction,
WebExceptionCode& ec) { WebExceptionCode& ec) {
IndexedDBDispatcher* dispatcher = IndexedDBDispatcher* dispatcher =
IndexedDBDispatcher::ThreadSpecificInstance(); IndexedDBDispatcher::ThreadSpecificInstance();
dispatcher->RequestIDBObjectStoreOpenCursor( dispatcher->RequestIDBObjectStoreOpenCursor(
idb_key_range, direction, callbacks, idb_object_store_id_, idb_key_range, direction, callbacks, idb_object_store_id_,
transaction, &ec); task_type, transaction, &ec);
}
void RendererWebIDBObjectStoreImpl::openCursor(
const WebIDBKeyRange& idb_key_range,
unsigned short direction, WebIDBCallbacks* callbacks,
const WebIDBTransaction& transaction,
WebExceptionCode& ec) {
IndexedDBDispatcher* dispatcher =
IndexedDBDispatcher::ThreadSpecificInstance();
dispatcher->RequestIDBObjectStoreOpenCursor(
idb_key_range, static_cast<WebKit::WebIDBCursor::Direction>(direction),
callbacks, idb_object_store_id_,
WebKit::WebIDBTransaction::NormalTask, transaction, &ec);
} }
void RendererWebIDBObjectStoreImpl::count( void RendererWebIDBObjectStoreImpl::count(
......
...@@ -36,6 +36,12 @@ class RendererWebIDBObjectStoreImpl : public WebKit::WebIDBObjectStore { ...@@ -36,6 +36,12 @@ class RendererWebIDBObjectStoreImpl : public WebKit::WebIDBObjectStore {
const WebKit::WebVector<WebKit::WebString>&, const WebKit::WebVector<WebKit::WebString>&,
const WebKit::WebVector<WebKit::WebIDBObjectStore::WebIndexKeys>&, const WebKit::WebVector<WebKit::WebIDBObjectStore::WebIndexKeys>&,
WebKit::WebExceptionCode&); WebKit::WebExceptionCode&);
virtual void setIndexKeys(const WebKit::WebIDBKey&,
const WebKit::WebVector<WebKit::WebString>&,
const WebKit::WebVector<WebIndexKeys>&,
const WebKit::WebIDBTransaction&);
virtual void setIndexesReady(const WebKit::WebVector<WebKit::WebString>&,
const WebKit::WebIDBTransaction&);
virtual void deleteFunction(const WebKit::WebIDBKeyRange& key_range, virtual void deleteFunction(const WebKit::WebIDBKeyRange& key_range,
WebKit::WebIDBCallbacks* callbacks, WebKit::WebIDBCallbacks* callbacks,
const WebKit::WebIDBTransaction& transaction, const WebKit::WebIDBTransaction& transaction,
...@@ -58,12 +64,19 @@ class RendererWebIDBObjectStoreImpl : public WebKit::WebIDBObjectStore { ...@@ -58,12 +64,19 @@ class RendererWebIDBObjectStoreImpl : public WebKit::WebIDBObjectStore {
const WebKit::WebIDBTransaction& transaction, const WebKit::WebIDBTransaction& transaction,
WebKit::WebExceptionCode& ec); WebKit::WebExceptionCode& ec);
virtual void openCursor(const WebKit::WebIDBKeyRange& idb_key_range, virtual void openCursor(const WebKit::WebIDBKeyRange& range,
unsigned short direction, unsigned short direction,
WebKit::WebIDBCallbacks* callbacks, WebKit::WebIDBCallbacks* callbacks,
const WebKit::WebIDBTransaction& transaction, const WebKit::WebIDBTransaction& transaction,
WebKit::WebExceptionCode& ec); WebKit::WebExceptionCode& ec);
virtual void openCursor(const WebKit::WebIDBKeyRange&,
WebKit::WebIDBCursor::Direction direction,
WebKit::WebIDBCallbacks*,
WebKit::WebIDBTransaction::TaskType,
const WebKit::WebIDBTransaction&,
WebKit::WebExceptionCode&);
virtual void count(const WebKit::WebIDBKeyRange& idb_key_range, virtual void count(const WebKit::WebIDBKeyRange& idb_key_range,
WebKit::WebIDBCallbacks* callbacks, WebKit::WebIDBCallbacks* callbacks,
const WebKit::WebIDBTransaction& transaction, const WebKit::WebIDBTransaction& transaction,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment