summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authoralecflett@chromium.org <alecflett@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-10 16:35:08 +0000
committeralecflett@chromium.org <alecflett@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-10 16:35:08 +0000
commit8904bd57aa1393a20c51adfb94c818973038cbea (patch)
treecd4c370f0f6bb931a637f7835d61948d74252c22 /content
parent2487bee42ccd4deca3b08d9c267b4bb285f95d45 (diff)
downloadchromium_src-8904bd57aa1393a20c51adfb94c818973038cbea.zip
chromium_src-8904bd57aa1393a20c51adfb94c818973038cbea.tar.gz
chromium_src-8904bd57aa1393a20c51adfb94c818973038cbea.tar.bz2
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
Diffstat (limited to 'content')
-rw-r--r--content/browser/in_process_webkit/indexed_db_dispatcher_host.cc37
-rw-r--r--content/browser/in_process_webkit/indexed_db_dispatcher_host.h10
-rw-r--r--content/common/indexed_db/indexed_db_dispatcher.cc4
-rw-r--r--content/common/indexed_db/indexed_db_dispatcher.h6
-rw-r--r--content/common/indexed_db/indexed_db_messages.h23
-rw-r--r--content/common/indexed_db/proxy_webidbobjectstore_impl.cc67
-rw-r--r--content/common/indexed_db/proxy_webidbobjectstore_impl.h23
7 files changed, 156 insertions, 14 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 6547911..c1b5e36 100644
--- a/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc
+++ b/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc
@@ -643,6 +643,10 @@ bool IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnMessageReceived(
message, *msg_is_ok)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreGet, OnGet)
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_ObjectStoreClear, OnClear)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCreateIndex, OnCreateIndex)
@@ -710,6 +714,38 @@ void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnPut(
(*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(
int idb_object_store_id,
int32 thread_id,
@@ -828,6 +864,7 @@ void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnOpenCursor(
params.response_id, -1));
idb_object_store->openCursor(
params.key_range, params.direction, callbacks.release(),
+ params.task_type,
*idb_transaction, *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 cfa73dd..cf23c2e 100644
--- a/content/browser/in_process_webkit/indexed_db_dispatcher_host.h
+++ b/content/browser/in_process_webkit/indexed_db_dispatcher_host.h
@@ -191,6 +191,16 @@ class IndexedDBDispatcherHost : public content::BrowserMessageFilter {
WebKit::WebExceptionCode* ec);
void OnPut(const IndexedDBHostMsg_ObjectStorePut_Params& params,
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,
int32 thread_id,
int32 response_id,
diff --git a/content/common/indexed_db/indexed_db_dispatcher.cc b/content/common/indexed_db/indexed_db_dispatcher.cc
index 55a7bdb..e4f6732 100644
--- a/content/common/indexed_db/indexed_db_dispatcher.cc
+++ b/content/common/indexed_db/indexed_db_dispatcher.cc
@@ -483,9 +483,10 @@ void IndexedDBDispatcher::RequestIDBObjectStoreClear(
void IndexedDBDispatcher::RequestIDBObjectStoreOpenCursor(
const WebIDBKeyRange& idb_key_range,
- unsigned short direction,
+ WebKit::WebIDBCursor::Direction direction,
WebIDBCallbacks* callbacks_ptr,
int32 idb_object_store_id,
+ WebKit::WebIDBTransaction::TaskType task_type,
const WebIDBTransaction& transaction,
WebExceptionCode* ec) {
ResetCursorPrefetchCaches();
@@ -496,6 +497,7 @@ void IndexedDBDispatcher::RequestIDBObjectStoreOpenCursor(
params.key_range = IndexedDBKeyRange(idb_key_range);
params.direction = direction;
params.idb_object_store_id = idb_object_store_id;
+ params.task_type = task_type;
params.transaction_id = TransactionId(transaction);
Send(new IndexedDBHostMsg_ObjectStoreOpenCursor(params, ec));
if (*ec)
diff --git a/content/common/indexed_db/indexed_db_dispatcher.h b/content/common/indexed_db/indexed_db_dispatcher.h
index 9c589fc..7e1a450 100644
--- a/content/common/indexed_db/indexed_db_dispatcher.h
+++ b/content/common/indexed_db/indexed_db_dispatcher.h
@@ -14,9 +14,11 @@
#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/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/WebIDBDatabaseCallbacks.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 "webkit/glue/worker_task_runner.h"
@@ -33,7 +35,6 @@ class Message;
namespace WebKit {
class WebFrame;
class WebIDBKeyRange;
-class WebIDBTransaction;
}
namespace content {
@@ -191,9 +192,10 @@ class CONTENT_EXPORT IndexedDBDispatcher
void RequestIDBObjectStoreOpenCursor(
const WebKit::WebIDBKeyRange& idb_key_range,
- unsigned short direction,
+ WebKit::WebIDBCursor::Direction direction,
WebKit::WebIDBCallbacks* callbacks,
int32 idb_object_store_id,
+ WebKit::WebIDBTransaction::TaskType task_type,
const WebKit::WebIDBTransaction& transaction,
WebKit::WebExceptionCode* ec);
diff --git a/content/common/indexed_db/indexed_db_messages.h b/content/common/indexed_db/indexed_db_messages.h
index 2a478fd..7b3a308 100644
--- a/content/common/indexed_db/indexed_db_messages.h
+++ b/content/common/indexed_db/indexed_db_messages.h
@@ -15,14 +15,18 @@
#include "ipc/ipc_message_macros.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/WebIDBCursor.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/WebIDBTransaction.h"
#define IPC_MESSAGE_START IndexedDBMsgStart
// Argument structures used in messages
IPC_ENUM_TRAITS(WebKit::WebIDBObjectStore::PutMode)
+IPC_ENUM_TRAITS(WebKit::WebIDBCursor::Direction)
+IPC_ENUM_TRAITS(WebKit::WebIDBTransaction::TaskType)
// Used to enumerate indexed databases.
IPC_STRUCT_BEGIN(IndexedDBHostMsg_FactoryGetDatabaseNames_Params)
@@ -146,7 +150,9 @@ IPC_STRUCT_BEGIN(IndexedDBHostMsg_ObjectStoreOpenCursor_Params)
// The serialized key range.
IPC_STRUCT_MEMBER(content::IndexedDBKeyRange, key_range)
// 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.
IPC_STRUCT_MEMBER(int32, idb_object_store_id)
// The transaction this request belongs to.
@@ -454,6 +460,21 @@ IPC_SYNC_MESSAGE_CONTROL1_1(IndexedDBHostMsg_ObjectStorePut,
IndexedDBHostMsg_ObjectStorePut_Params,
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.
IPC_SYNC_MESSAGE_CONTROL5_1(IndexedDBHostMsg_ObjectStoreDelete,
int32, /* idb_object_store_id */
diff --git a/content/common/indexed_db/proxy_webidbobjectstore_impl.cc b/content/common/indexed_db/proxy_webidbobjectstore_impl.cc
index 47da0df..46416d3 100644
--- a/content/common/indexed_db/proxy_webidbobjectstore_impl.cc
+++ b/content/common/indexed_db/proxy_webidbobjectstore_impl.cc
@@ -4,6 +4,8 @@
#include "content/common/indexed_db/proxy_webidbobjectstore_impl.h"
+#include <vector>
+
#include "content/common/indexed_db/indexed_db_messages.h"
#include "content/public/common/serialized_script_value.h"
#include "content/common/indexed_db/indexed_db_dispatcher.h"
@@ -67,17 +69,58 @@ void RendererWebIDBObjectStoreImpl::putWithIndexKeys(
PutMode put_mode,
WebIDBCallbacks* callbacks,
const WebIDBTransaction& transaction,
- const WebVector<WebString>& indexNames,
- const WebVector<WebVector<WebIDBKey> >& indexKeys,
+ const WebVector<WebString>& index_names,
+ const WebVector<WebVector<WebIDBKey> >& index_keys,
WebExceptionCode& ec) {
IndexedDBDispatcher* dispatcher =
IndexedDBDispatcher::ThreadSpecificInstance();
dispatcher->RequestIDBObjectStorePut(
SerializedScriptValue(value), IndexedDBKey(key),
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(
const WebIDBKeyRange& key_range,
WebIDBCallbacks* callbacks,
@@ -147,14 +190,28 @@ void RendererWebIDBObjectStoreImpl::deleteIndex(
void RendererWebIDBObjectStoreImpl::openCursor(
const WebIDBKeyRange& idb_key_range,
- unsigned short direction, WebIDBCallbacks* callbacks,
+ WebKit::WebIDBCursor::Direction direction, WebIDBCallbacks* callbacks,
+ WebKit::WebIDBTransaction::TaskType task_type,
const WebIDBTransaction& transaction,
WebExceptionCode& ec) {
IndexedDBDispatcher* dispatcher =
IndexedDBDispatcher::ThreadSpecificInstance();
dispatcher->RequestIDBObjectStoreOpenCursor(
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(
diff --git a/content/common/indexed_db/proxy_webidbobjectstore_impl.h b/content/common/indexed_db/proxy_webidbobjectstore_impl.h
index 0ced4b8..509f5bf 100644
--- a/content/common/indexed_db/proxy_webidbobjectstore_impl.h
+++ b/content/common/indexed_db/proxy_webidbobjectstore_impl.h
@@ -36,6 +36,12 @@ class RendererWebIDBObjectStoreImpl : public WebKit::WebIDBObjectStore {
const WebKit::WebVector<WebKit::WebString>&,
const WebKit::WebVector<WebKit::WebIDBObjectStore::WebIndexKeys>&,
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,
WebKit::WebIDBCallbacks* callbacks,
const WebKit::WebIDBTransaction& transaction,
@@ -58,11 +64,18 @@ class RendererWebIDBObjectStoreImpl : public WebKit::WebIDBObjectStore {
const WebKit::WebIDBTransaction& transaction,
WebKit::WebExceptionCode& ec);
- virtual void openCursor(const WebKit::WebIDBKeyRange& idb_key_range,
- unsigned short direction,
- WebKit::WebIDBCallbacks* callbacks,
- const WebKit::WebIDBTransaction& transaction,
- WebKit::WebExceptionCode& ec);
+ virtual void openCursor(const WebKit::WebIDBKeyRange& range,
+ unsigned short direction,
+ WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebIDBTransaction& transaction,
+ 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,
WebKit::WebIDBCallbacks* callbacks,