summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorjsbell@chromium.org <jsbell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-17 20:20:26 +0000
committerjsbell@chromium.org <jsbell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-17 20:20:26 +0000
commit981e06a668466746e6735239ce2bb046a4e681ef (patch)
tree90dc2d968096f656e474076f67df4f1c7baa2e85 /content
parent31309a4e207bf2ca11524de8e94c199d64b0685b (diff)
downloadchromium_src-981e06a668466746e6735239ce2bb046a4e681ef.zip
chromium_src-981e06a668466746e6735239ce2bb046a4e681ef.tar.gz
chromium_src-981e06a668466746e6735239ce2bb046a4e681ef.tar.bz2
IndexedDB: Implement IPC plumbing for IDBObjectStore.delete(IDBKeyRange)
Introduces an IndexedDBKeyRange type for simplifying IPC messages, but existing messages have not yet been changed to use it. BUG=101384 TEST= Review URL: http://codereview.chromium.org/9389025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122567 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/in_process_webkit/indexed_db_dispatcher_host.cc24
-rw-r--r--content/browser/in_process_webkit/indexed_db_dispatcher_host.h7
-rw-r--r--content/common/indexed_db/indexed_db_dispatcher.cc17
-rw-r--r--content/common/indexed_db/indexed_db_dispatcher.h8
-rw-r--r--content/common/indexed_db/indexed_db_key_range.cc41
-rw-r--r--content/common/indexed_db/indexed_db_key_range.h37
-rw-r--r--content/common/indexed_db/indexed_db_messages.h12
-rw-r--r--content/common/indexed_db/indexed_db_param_traits.cc44
-rw-r--r--content/common/indexed_db/indexed_db_param_traits.h11
-rw-r--r--content/common/indexed_db/proxy_webidbobjectstore_impl.cc12
-rw-r--r--content/common/indexed_db/proxy_webidbobjectstore_impl.h4
-rw-r--r--content/content_common.gypi2
12 files changed, 217 insertions, 2 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 00d8514..2875a43 100644
--- a/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc
+++ b/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc
@@ -706,6 +706,7 @@ bool IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnMessageReceived(
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreGet, OnGet)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStorePut, OnPut)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDelete, OnDelete)
+ IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDeleteRange, OnDeleteRange)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreClear, OnClear)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCreateIndex, OnCreateIndex)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreIndex, OnIndex)
@@ -818,6 +819,29 @@ void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDelete(
key, callbacks.release(), *idb_transaction, *ec);
}
+void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDeleteRange(
+ 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->deleteFunction(
+ key_range, callbacks.release(), *idb_transaction, *ec);
+}
+
void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnClear(
int idb_object_store_id,
int32 thread_id,
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 1d2bb5e..6de97aa 100644
--- a/content/browser/in_process_webkit/indexed_db_dispatcher_host.h
+++ b/content/browser/in_process_webkit/indexed_db_dispatcher_host.h
@@ -13,6 +13,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebExceptionCode.h"
class IndexedDBKey;
+class IndexedDBKeyRange;
class NullableString16;
struct IndexedDBHostMsg_DatabaseCreateObjectStore_Params;
struct IndexedDBHostMsg_FactoryDeleteDatabase_Params;
@@ -207,6 +208,12 @@ class IndexedDBDispatcherHost : public content::BrowserMessageFilter {
const IndexedDBKey& key,
int32 transaction_id,
WebKit::WebExceptionCode* ec);
+ void OnDeleteRange(int idb_object_store_id,
+ int32 thread_id,
+ int32 response_id,
+ const IndexedDBKeyRange& key_range,
+ int32 transaction_id,
+ WebKit::WebExceptionCode* ec);
void OnClear(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 c8de358..86ac318b 100644
--- a/content/common/indexed_db/indexed_db_dispatcher.cc
+++ b/content/common/indexed_db/indexed_db_dispatcher.cc
@@ -423,6 +423,23 @@ void IndexedDBDispatcher::RequestIDBObjectStoreDelete(
pending_callbacks_.Remove(response_id);
}
+void IndexedDBDispatcher::RequestIDBObjectStoreDeleteRange(
+ 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_ObjectStoreDeleteRange(
+ idb_object_store_id, CurrentWorkerId(), response_id, key_range,
+ TransactionId(transaction), ec));
+ if (*ec)
+ pending_callbacks_.Remove(response_id);
+}
+
void IndexedDBDispatcher::RequestIDBObjectStoreClear(
WebIDBCallbacks* callbacks_ptr,
int32 idb_object_store_id,
diff --git a/content/common/indexed_db/indexed_db_dispatcher.h b/content/common/indexed_db/indexed_db_dispatcher.h
index 1872eeb..8d80047 100644
--- a/content/common/indexed_db/indexed_db_dispatcher.h
+++ b/content/common/indexed_db/indexed_db_dispatcher.h
@@ -20,6 +20,7 @@
#include "webkit/glue/worker_task_runner.h"
class IndexedDBKey;
+class IndexedDBKeyRange;
struct IndexedDBMsg_CallbacksSuccessCursorContinue_Params;
struct IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params;
struct IndexedDBMsg_CallbacksSuccessIDBCursor_Params;
@@ -164,6 +165,13 @@ class IndexedDBDispatcher : public webkit_glue::WorkerTaskRunner::Observer {
const WebKit::WebIDBTransaction& transaction,
WebKit::WebExceptionCode* ec);
+ void RequestIDBObjectStoreDeleteRange(
+ const IndexedDBKeyRange& key_range,
+ WebKit::WebIDBCallbacks* callbacks,
+ int32 idb_object_store_id,
+ const WebKit::WebIDBTransaction& transaction,
+ WebKit::WebExceptionCode* ec);
+
void RequestIDBObjectStoreClear(
WebKit::WebIDBCallbacks* callbacks,
int32 idb_object_store_id,
diff --git a/content/common/indexed_db/indexed_db_key_range.cc b/content/common/indexed_db/indexed_db_key_range.cc
new file mode 100644
index 0000000..0567e8d
--- /dev/null
+++ b/content/common/indexed_db/indexed_db_key_range.cc
@@ -0,0 +1,41 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/indexed_db/indexed_db_key_range.h"
+
+#include "base/logging.h"
+
+using WebKit::WebIDBKeyRange;
+using WebKit::WebIDBKey;
+
+IndexedDBKeyRange::IndexedDBKeyRange()
+ : lower_open_(false),
+ upper_open_(false) {
+ lower_.SetNull();
+ upper_.SetNull();
+}
+
+IndexedDBKeyRange::IndexedDBKeyRange(const WebIDBKeyRange& key_range) {
+ lower_.Set(key_range.lower());
+ upper_.Set(key_range.upper());
+ lower_open_ = key_range.lowerOpen();
+ upper_open_ = key_range.upperOpen();
+}
+
+IndexedDBKeyRange::~IndexedDBKeyRange() {
+}
+
+
+void IndexedDBKeyRange::Set(const IndexedDBKey& lower,
+ const IndexedDBKey& upper,
+ bool lower_open, bool upper_open) {
+ lower_.Set(lower);
+ upper_.Set(upper);
+ lower_open_ = lower_open;
+ upper_open_ = upper_open;
+}
+
+IndexedDBKeyRange::operator WebIDBKeyRange() const {
+ return WebIDBKeyRange(lower_, upper_, lower_open_, upper_open_);
+}
diff --git a/content/common/indexed_db/indexed_db_key_range.h b/content/common/indexed_db/indexed_db_key_range.h
new file mode 100644
index 0000000..4b5e0fa
--- /dev/null
+++ b/content/common/indexed_db/indexed_db_key_range.h
@@ -0,0 +1,37 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_COMMON_INDEXED_DB_INDEXED_DB_KEY_RANGE_H_
+#define CONTENT_COMMON_INDEXED_DB_INDEXED_DB_KEY_RANGE_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "content/common/content_export.h"
+#include "content/common/indexed_db/indexed_db_key.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyRange.h"
+
+class CONTENT_EXPORT IndexedDBKeyRange {
+ public:
+ IndexedDBKeyRange();
+ explicit IndexedDBKeyRange(const WebKit::WebIDBKeyRange& key_range);
+ ~IndexedDBKeyRange();
+
+ const IndexedDBKey& lower() const { return lower_; }
+ const IndexedDBKey& upper() const { return upper_; }
+ bool lowerOpen() const { return lower_open_; }
+ bool upperOpen() const { return upper_open_; }
+
+ void Set(const IndexedDBKey& lower, const IndexedDBKey& upper,
+ bool lower_open, bool upper_open);
+
+ operator WebKit::WebIDBKeyRange() const;
+
+ private:
+ IndexedDBKey lower_;
+ IndexedDBKey upper_;
+ bool lower_open_;
+ bool upper_open_;
+};
+
+#endif // CONTENT_COMMON_INDEXED_DB_INDEXED_DB_KEY_RANGE_H_
diff --git a/content/common/indexed_db/indexed_db_messages.h b/content/common/indexed_db/indexed_db_messages.h
index 2ade76f..6ca348f 100644
--- a/content/common/indexed_db/indexed_db_messages.h
+++ b/content/common/indexed_db/indexed_db_messages.h
@@ -7,6 +7,7 @@
#include <vector>
#include "content/common/indexed_db/indexed_db_key.h"
+#include "content/common/indexed_db/indexed_db_key_range.h"
#include "content/common/indexed_db/indexed_db_param_traits.h"
#include "content/public/common/serialized_script_value.h"
#include "ipc/ipc_message_macros.h"
@@ -474,7 +475,7 @@ IPC_SYNC_MESSAGE_CONTROL1_1(IndexedDBHostMsg_ObjectStorePut,
IndexedDBHostMsg_ObjectStorePut_Params,
WebKit::WebExceptionCode /* ec */)
-// WebIDBObjectStore::delete() message.
+// WebIDBObjectStore::delete(key) message.
IPC_SYNC_MESSAGE_CONTROL5_1(IndexedDBHostMsg_ObjectStoreDelete,
int32, /* idb_object_store_id */
int32, /* thread_id */
@@ -483,6 +484,15 @@ IPC_SYNC_MESSAGE_CONTROL5_1(IndexedDBHostMsg_ObjectStoreDelete,
int32, /* transaction_id */
WebKit::WebExceptionCode /* ec */)
+// WebIDBObjectStore::delete(keyRange) message.
+IPC_SYNC_MESSAGE_CONTROL5_1(IndexedDBHostMsg_ObjectStoreDeleteRange,
+ int32, /* idb_object_store_id */
+ int32, /* thread_id */
+ int32, /* response_id */
+ IndexedDBKeyRange, /* key_range */
+ int32, /* transaction_id */
+ WebKit::WebExceptionCode /* ec */)
+
// WebIDBObjectStore::clear() message.
IPC_SYNC_MESSAGE_CONTROL4_1(IndexedDBHostMsg_ObjectStoreClear,
int32, /* idb_object_store_id */
diff --git a/content/common/indexed_db/indexed_db_param_traits.cc b/content/common/indexed_db/indexed_db_param_traits.cc
index 34dfde5..c580cd1 100644
--- a/content/common/indexed_db/indexed_db_param_traits.cc
+++ b/content/common/indexed_db/indexed_db_param_traits.cc
@@ -5,6 +5,7 @@
#include "content/common/indexed_db/indexed_db_param_traits.h"
#include "content/common/indexed_db/indexed_db_key.h"
+#include "content/common/indexed_db/indexed_db_key_range.h"
#include "content/public/common/serialized_script_value.h"
#include "ipc/ipc_message_utils.h"
@@ -140,4 +141,47 @@ void ParamTraits<IndexedDBKey>::Log(const param_type& p, std::string* l) {
l->append(")");
}
+void ParamTraits<IndexedDBKeyRange>::Write(Message* m, const param_type& p) {
+ WriteParam(m, p.lower());
+ WriteParam(m, p.upper());
+ WriteParam(m, p.lowerOpen());
+ WriteParam(m, p.upperOpen());
+}
+
+bool ParamTraits<IndexedDBKeyRange>::Read(const Message* m,
+ void** iter,
+ param_type* r) {
+
+ IndexedDBKey lower;
+ if (!ReadParam(m, iter, &lower))
+ return false;
+
+ IndexedDBKey upper;
+ if (!ReadParam(m, iter, &upper))
+ return false;
+
+ bool lower_open;
+ if (!ReadParam(m, iter, &lower_open))
+ return false;
+
+ bool upper_open;
+ if (!ReadParam(m, iter, &upper_open))
+ return false;
+
+ r->Set(lower, upper, lower_open, upper_open);
+ return true;
+}
+
+void ParamTraits<IndexedDBKeyRange>::Log(const param_type& p, std::string* l) {
+ l->append("<IndexedDBKeyRange>(lower=");
+ LogParam(p.lower(), l);
+ l->append(", upper=");
+ LogParam(p.upper(), l);
+ l->append(", lower_open=");
+ LogParam(p.lowerOpen(), l);
+ l->append(", upper_open=");
+ LogParam(p.upperOpen(), l);
+ l->append(")");
+}
+
} // namespace IPC
diff --git a/content/common/indexed_db/indexed_db_param_traits.h b/content/common/indexed_db/indexed_db_param_traits.h
index 3112342..930ed0b 100644
--- a/content/common/indexed_db/indexed_db_param_traits.h
+++ b/content/common/indexed_db/indexed_db_param_traits.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,6 +10,7 @@
#include "ipc/ipc_param_traits.h"
class IndexedDBKey;
+class IndexedDBKeyRange;
namespace content {
class SerializedScriptValue;
@@ -38,6 +39,14 @@ struct ParamTraits<IndexedDBKey> {
static void Log(const param_type& p, std::string* l);
};
+template <>
+struct ParamTraits<IndexedDBKeyRange> {
+ typedef IndexedDBKeyRange param_type;
+ static void Write(Message* m, const param_type& p);
+ static bool Read(const Message* m, void** iter, param_type* r);
+ static void Log(const param_type& p, std::string* l);
+};
+
} // namespace IPC
#endif // CONTENT_COMMON_INDEXED_DB_INDEXED_DB_PARAM_TRAITS_H_
diff --git a/content/common/indexed_db/proxy_webidbobjectstore_impl.cc b/content/common/indexed_db/proxy_webidbobjectstore_impl.cc
index ed70c41..5340db6 100644
--- a/content/common/indexed_db/proxy_webidbobjectstore_impl.cc
+++ b/content/common/indexed_db/proxy_webidbobjectstore_impl.cc
@@ -105,6 +105,18 @@ void RendererWebIDBObjectStoreImpl::deleteFunction(
IndexedDBKey(key), callbacks, idb_object_store_id_, transaction, &ec);
}
+void RendererWebIDBObjectStoreImpl::deleteFunction(
+ const WebIDBKeyRange& key_range,
+ WebIDBCallbacks* callbacks,
+ const WebIDBTransaction& transaction,
+ WebExceptionCode& ec) {
+ IndexedDBDispatcher* dispatcher =
+ IndexedDBDispatcher::ThreadSpecificInstance();
+ dispatcher->RequestIDBObjectStoreDeleteRange(
+ IndexedDBKeyRange(key_range), callbacks, idb_object_store_id_,
+ transaction, &ec);
+}
+
void RendererWebIDBObjectStoreImpl::clear(
WebIDBCallbacks* callbacks,
const WebIDBTransaction& transaction,
diff --git a/content/common/indexed_db/proxy_webidbobjectstore_impl.h b/content/common/indexed_db/proxy_webidbobjectstore_impl.h
index 4921a2f..3c54907 100644
--- a/content/common/indexed_db/proxy_webidbobjectstore_impl.h
+++ b/content/common/indexed_db/proxy_webidbobjectstore_impl.h
@@ -42,6 +42,10 @@ class RendererWebIDBObjectStoreImpl : public WebKit::WebIDBObjectStore {
WebKit::WebIDBCallbacks* callbacks,
const WebKit::WebIDBTransaction& transaction,
WebKit::WebExceptionCode& ec);
+ virtual void deleteFunction(const WebKit::WebIDBKeyRange& key_range,
+ WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebIDBTransaction& transaction,
+ WebKit::WebExceptionCode& ec);
virtual void clear(WebKit::WebIDBCallbacks* callbacks,
const WebKit::WebIDBTransaction& transaction,
WebKit::WebExceptionCode& ec);
diff --git a/content/content_common.gypi b/content/content_common.gypi
index d860215..5ff552b 100644
--- a/content/content_common.gypi
+++ b/content/content_common.gypi
@@ -192,6 +192,8 @@
'common/hi_res_timer_manager.h',
'common/indexed_db/indexed_db_key.cc',
'common/indexed_db/indexed_db_key.h',
+ 'common/indexed_db/indexed_db_key_range.cc',
+ 'common/indexed_db/indexed_db_key_range.h',
'common/indexed_db/indexed_db_messages.h',
'common/indexed_db/indexed_db_param_traits.cc',
'common/indexed_db/indexed_db_param_traits.h',