summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-17 11:27:26 +0000
committerjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-17 11:27:26 +0000
commite7fd1980c7fbe92aea58b6d7256770d7be9ac621 (patch)
treea5ad99c8f423f086d79bd1612ebf517434650ea4 /chrome/renderer
parent56d73f2dcb38999c4ec15f8a9c5236bf1ab5cf2d (diff)
downloadchromium_src-e7fd1980c7fbe92aea58b6d7256770d7be9ac621.zip
chromium_src-e7fd1980c7fbe92aea58b6d7256770d7be9ac621.tar.gz
chromium_src-e7fd1980c7fbe92aea58b6d7256770d7be9ac621.tar.bz2
Add IDBIndex plumbing (for IndexedDB).
BUG=none TEST=none Review URL: http://codereview.chromium.org/3442001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59780 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/indexed_db_dispatcher.cc50
-rw-r--r--chrome/renderer/indexed_db_dispatcher.h16
-rw-r--r--chrome/renderer/renderer_webidbcursor_impl.cc15
-rw-r--r--chrome/renderer/renderer_webidbcursor_impl.h3
-rw-r--r--chrome/renderer/renderer_webidbindex_impl.cc43
-rw-r--r--chrome/renderer/renderer_webidbindex_impl.h11
6 files changed, 133 insertions, 5 deletions
diff --git a/chrome/renderer/indexed_db_dispatcher.cc b/chrome/renderer/indexed_db_dispatcher.cc
index fa6d307..3ba6f08 100644
--- a/chrome/renderer/indexed_db_dispatcher.cc
+++ b/chrome/renderer/indexed_db_dispatcher.cc
@@ -149,6 +149,56 @@ void IndexedDBDispatcher::RequestIDBDatabaseSetVersion(
version));
}
+void IndexedDBDispatcher::RequestIDBIndexOpenObjectCursor(
+ const WebIDBKeyRange& idb_key_range, unsigned short direction,
+ WebIDBCallbacks* callbacks_ptr, int32 idb_index_id) {
+ scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
+ ViewHostMsg_IDBIndexOpenCursor_Params params;
+ params.response_id_ = pending_callbacks_.Add(callbacks.release());
+ 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;
+ RenderThread::current()->Send(
+ new ViewHostMsg_IDBIndexOpenObjectCursor(params));
+}
+
+void IndexedDBDispatcher::RequestIDBIndexOpenCursor(
+ const WebIDBKeyRange& idb_key_range, unsigned short direction,
+ WebIDBCallbacks* callbacks_ptr, int32 idb_index_id) {
+ scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
+ ViewHostMsg_IDBIndexOpenCursor_Params params;
+ params.response_id_ = pending_callbacks_.Add(callbacks.release());
+ 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;
+ RenderThread::current()->Send(
+ new ViewHostMsg_IDBIndexOpenCursor(params));
+}
+
+void IndexedDBDispatcher::RequestIDBIndexGetObject(
+ const IndexedDBKey& key, WebKit::WebIDBCallbacks* callbacks_ptr,
+ int32 idb_index_id) {
+ scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
+
+ RenderThread::current()->Send(
+ new ViewHostMsg_IDBIndexGetObject(
+ idb_index_id, pending_callbacks_.Add(callbacks.release()), key));
+}
+
+void IndexedDBDispatcher::RequestIDBIndexGet(
+ const IndexedDBKey& key, WebKit::WebIDBCallbacks* callbacks_ptr,
+ int32 idb_index_id) {
+ scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
+
+ RenderThread::current()->Send(
+ new ViewHostMsg_IDBIndexGet(
+ idb_index_id, pending_callbacks_.Add(callbacks.release()), key));
+}
+
void IndexedDBDispatcher::RequestIDBObjectStoreGet(
const IndexedDBKey& key, WebKit::WebIDBCallbacks* callbacks_ptr,
int32 idb_object_store_id) {
diff --git a/chrome/renderer/indexed_db_dispatcher.h b/chrome/renderer/indexed_db_dispatcher.h
index e4ec55f..edf11b2 100644
--- a/chrome/renderer/indexed_db_dispatcher.h
+++ b/chrome/renderer/indexed_db_dispatcher.h
@@ -64,6 +64,22 @@ class IndexedDBDispatcher {
WebKit::WebIDBCallbacks* callbacks,
int32 idb_database_id);
+ void RequestIDBIndexOpenObjectCursor(
+ const WebKit::WebIDBKeyRange& idb_key_range, unsigned short direction,
+ WebKit::WebIDBCallbacks* callbacks, int32 idb_index_id);
+
+ void RequestIDBIndexOpenCursor(
+ const WebKit::WebIDBKeyRange& idb_key_range, unsigned short direction,
+ WebKit::WebIDBCallbacks* callbacks, int32 idb_index_id);
+
+ void RequestIDBIndexGetObject(
+ const IndexedDBKey& key, WebKit::WebIDBCallbacks* callbacks,
+ int32 idb_index_id);
+
+ void RequestIDBIndexGet(
+ const IndexedDBKey& key, WebKit::WebIDBCallbacks* callbacks,
+ int32 idb_index_id);
+
void RequestIDBObjectStoreGet(
const IndexedDBKey& key, WebKit::WebIDBCallbacks* callbacks,
int32 idb_object_store_id);
diff --git a/chrome/renderer/renderer_webidbcursor_impl.cc b/chrome/renderer/renderer_webidbcursor_impl.cc
index dd78eec..88affd1 100644
--- a/chrome/renderer/renderer_webidbcursor_impl.cc
+++ b/chrome/renderer/renderer_webidbcursor_impl.cc
@@ -37,11 +37,18 @@ WebIDBKey RendererWebIDBCursorImpl::key() const {
return key;
}
-WebSerializedScriptValue RendererWebIDBCursorImpl::value() const {
- SerializedScriptValue value;
+void RendererWebIDBCursorImpl::value(
+ WebSerializedScriptValue& webScriptValue,
+ WebIDBKey& webKey) const {
+ SerializedScriptValue scriptValue;
+ IndexedDBKey key;
RenderThread::current()->Send(
- new ViewHostMsg_IDBCursorValue(idb_cursor_id_, &value));
- return value;
+ new ViewHostMsg_IDBCursorValue(idb_cursor_id_, &scriptValue,
+ &key));
+ DCHECK(scriptValue.is_null());
+ webScriptValue = scriptValue;
+ DCHECK(key.type() == WebIDBKey::InvalidType);
+ webKey = key;
}
void RendererWebIDBCursorImpl::update(const WebSerializedScriptValue& value,
diff --git a/chrome/renderer/renderer_webidbcursor_impl.h b/chrome/renderer/renderer_webidbcursor_impl.h
index 9f197f8..e252518 100644
--- a/chrome/renderer/renderer_webidbcursor_impl.h
+++ b/chrome/renderer/renderer_webidbcursor_impl.h
@@ -20,7 +20,8 @@ class RendererWebIDBCursorImpl : public WebKit::WebIDBCursor {
virtual unsigned short direction() const;
virtual WebKit::WebIDBKey key() const;
- virtual WebKit::WebSerializedScriptValue value() const;
+ virtual void value(WebKit::WebSerializedScriptValue&,
+ WebKit::WebIDBKey&) const;
virtual void update(const WebKit::WebSerializedScriptValue& value,
WebKit::WebIDBCallbacks* callback);
virtual void continueFunction(const WebKit::WebIDBKey& key,
diff --git a/chrome/renderer/renderer_webidbindex_impl.cc b/chrome/renderer/renderer_webidbindex_impl.cc
index 97e6409..5fa4115 100644
--- a/chrome/renderer/renderer_webidbindex_impl.cc
+++ b/chrome/renderer/renderer_webidbindex_impl.cc
@@ -4,6 +4,7 @@
#include "chrome/renderer/renderer_webidbindex_impl.h"
+#include "chrome/common/indexed_db_key.h"
#include "chrome/common/render_messages.h"
#include "chrome/renderer/render_thread.h"
#include "chrome/renderer/indexed_db_dispatcher.h"
@@ -30,6 +31,13 @@ WebString RendererWebIDBIndexImpl::name() const {
return result;
}
+WebString RendererWebIDBIndexImpl::storeName() const {
+ string16 result;
+ RenderThread::current()->Send(
+ new ViewHostMsg_IDBIndexStoreName(idb_index_id_, &result));
+ return result;
+}
+
WebString RendererWebIDBIndexImpl::keyPath() const {
NullableString16 result;
RenderThread::current()->Send(
@@ -43,3 +51,38 @@ bool RendererWebIDBIndexImpl::unique() const {
new ViewHostMsg_IDBIndexUnique(idb_index_id_, &result));
return result;
}
+
+void RendererWebIDBIndexImpl::openObjectCursor(
+ const WebKit::WebIDBKeyRange& range,
+ unsigned short direction,
+ WebKit::WebIDBCallbacks* callbacks) {
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RequestIDBIndexOpenObjectCursor(range, direction,
+ callbacks, idb_index_id_);
+}
+
+void RendererWebIDBIndexImpl::openCursor(
+ const WebKit::WebIDBKeyRange& range,
+ unsigned short direction,
+ WebKit::WebIDBCallbacks* callbacks) {
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RequestIDBIndexOpenCursor(range, direction,
+ callbacks, idb_index_id_);
+}
+
+void RendererWebIDBIndexImpl::getObject(const WebKit::WebIDBKey& key,
+ WebKit::WebIDBCallbacks* callbacks) {
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RequestIDBIndexGetObject(IndexedDBKey(key), callbacks,
+ idb_index_id_);
+}
+
+void RendererWebIDBIndexImpl::get(const WebKit::WebIDBKey& key,
+ WebKit::WebIDBCallbacks* callbacks) {
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RequestIDBIndexGet(IndexedDBKey(key), callbacks, idb_index_id_);
+}
diff --git a/chrome/renderer/renderer_webidbindex_impl.h b/chrome/renderer/renderer_webidbindex_impl.h
index 9c19ae7..de77920 100644
--- a/chrome/renderer/renderer_webidbindex_impl.h
+++ b/chrome/renderer/renderer_webidbindex_impl.h
@@ -17,8 +17,19 @@ class RendererWebIDBIndexImpl : public WebKit::WebIDBIndex {
// WebKit::WebIDBIndex
virtual WebKit::WebString name() const;
+ virtual WebKit::WebString storeName() const;
virtual WebKit::WebString keyPath() const;
virtual bool unique() const;
+ virtual void openObjectCursor(const WebKit::WebIDBKeyRange& range,
+ unsigned short direction,
+ WebKit::WebIDBCallbacks* callbacks);
+ virtual void openCursor(const WebKit::WebIDBKeyRange& range,
+ unsigned short direction,
+ WebKit::WebIDBCallbacks* callbacks);
+ virtual void getObject(const WebKit::WebIDBKey& key,
+ WebKit::WebIDBCallbacks* callbacks);
+ virtual void get(const WebKit::WebIDBKey& key,
+ WebKit::WebIDBCallbacks* callbacks);
private:
int32 idb_index_id_;