summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-14 14:29:40 +0000
committerjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-14 14:29:40 +0000
commit5c71640cdf15c2782b8331e9e2623da50ec5d102 (patch)
treeda7cf7505bb23c3e206bdcaab66f064d3edc5936 /chrome/renderer
parent699f2246bf56e1aadf31e1edd6c5aef9b4b39638 (diff)
downloadchromium_src-5c71640cdf15c2782b8331e9e2623da50ec5d102.zip
chromium_src-5c71640cdf15c2782b8331e9e2623da50ec5d102.tar.gz
chromium_src-5c71640cdf15c2782b8331e9e2623da50ec5d102.tar.bz2
The Chrome half of implementing get/put/remove for object stores (https://bugs.webkit.org/show_bug.cgi?id=41250).
TEST=none BUG=none Review URL: http://codereview.chromium.org/2830030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52313 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/indexed_db_dispatcher.cc93
-rw-r--r--chrome/renderer/indexed_db_dispatcher.h36
-rw-r--r--chrome/renderer/renderer_webidbindex_impl.cc2
-rw-r--r--chrome/renderer/renderer_webidbobjectstore_impl.cc33
-rw-r--r--chrome/renderer/renderer_webidbobjectstore_impl.h15
5 files changed, 145 insertions, 34 deletions
diff --git a/chrome/renderer/indexed_db_dispatcher.cc b/chrome/renderer/indexed_db_dispatcher.cc
index 8834b0a..d77903cf 100644
--- a/chrome/renderer/indexed_db_dispatcher.cc
+++ b/chrome/renderer/indexed_db_dispatcher.cc
@@ -5,6 +5,7 @@
#include "chrome/renderer/indexed_db_dispatcher.h"
#include "chrome/common/render_messages.h"
+#include "chrome/common/serialized_script_value.h"
#include "chrome/renderer/render_thread.h"
#include "chrome/renderer/render_view.h"
#include "chrome/renderer/renderer_webidbdatabase_impl.h"
@@ -29,15 +30,19 @@ IndexedDBDispatcher::~IndexedDBDispatcher() {
bool IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcher, msg)
- IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbackSuccessReturnNull,
- OnSuccessReturnNull)
- IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbackSuccessCreateIDBDatabase,
- OnSuccessCreateIDBDatabase)
- IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbackSuccessCreateIDBObjectStore,
- OnSuccessCreateIDBObjectStore)
- IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbackSuccessCreateIDBIndex,
- OnSuccessCreateIDBIndex)
- IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbackError,
+ IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksSuccessNull,
+ OnSuccessNull)
+ IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksSuccessIDBDatabase,
+ OnSuccessIDBDatabase)
+ IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksSuccessIndexedDBKey,
+ OnSuccessIndexedDBKey)
+ IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksSuccessIDBObjectStore,
+ OnSuccessIDBObjectStore)
+ IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksSuccessIDBIndex,
+ OnSuccessIDBIndex)
+ IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksSuccessSerializedScriptValue,
+ OnSuccessSerializedScriptValue)
+ IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksError,
OnError)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -66,14 +71,14 @@ void IndexedDBDispatcher::RequestIndexedDatabaseOpen(
}
void IndexedDBDispatcher::RequestIDBDatabaseCreateObjectStore(
- const string16& name, const string16& keypath, bool auto_increment,
+ const string16& name, const NullableString16& key_path, bool auto_increment,
WebIDBCallbacks* callbacks_ptr, int32 idb_database_id) {
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
ViewHostMsg_IDBDatabaseCreateObjectStore_Params params;
params.response_id_ = pending_callbacks_.Add(callbacks.release());
params.name_ = name;
- params.keypath_ = keypath;
+ params.key_path_ = key_path;
params.auto_increment_ = auto_increment;
params.idb_database_id_ = idb_database_id;
RenderThread::current()->Send(
@@ -90,15 +95,49 @@ void IndexedDBDispatcher::RequestIDBDatabaseRemoveObjectStore(
idb_database_id, pending_callbacks_.Add(callbacks.release()), name));
}
+void IndexedDBDispatcher::RequestIDBObjectStoreGet(
+ const IndexedDBKey& key, WebKit::WebIDBCallbacks* callbacks_ptr,
+ int32 idb_object_store_id) {
+ scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
+
+ RenderThread::current()->Send(
+ new ViewHostMsg_IDBObjectStoreGet(
+ idb_object_store_id, pending_callbacks_.Add(callbacks.release()),
+ key));
+}
+
+void IndexedDBDispatcher::RequestIDBObjectStorePut(
+ const SerializedScriptValue& value, const IndexedDBKey& key,
+ bool add_only, WebKit::WebIDBCallbacks* callbacks_ptr,
+ int32 idb_object_store_id) {
+ scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
+
+ RenderThread::current()->Send(
+ new ViewHostMsg_IDBObjectStorePut(
+ idb_object_store_id, pending_callbacks_.Add(callbacks.release()),
+ value, key, add_only));
+}
+
+void IndexedDBDispatcher::RequestIDBObjectStoreRemove(
+ const IndexedDBKey& key, WebKit::WebIDBCallbacks* callbacks_ptr,
+ int32 idb_object_store_id) {
+ scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
+
+ RenderThread::current()->Send(
+ new ViewHostMsg_IDBObjectStoreRemove(
+ idb_object_store_id, pending_callbacks_.Add(callbacks.release()),
+ key));
+}
+
void IndexedDBDispatcher::RequestIDBObjectStoreCreateIndex(
- const string16& name, const string16& keypath, bool unique,
+ const string16& name, const NullableString16& key_path, bool unique,
WebIDBCallbacks* callbacks_ptr, int32 idb_object_store_id) {
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
ViewHostMsg_IDBObjectStoreCreateIndex_Params params;
params.response_id_ = pending_callbacks_.Add(callbacks.release());
params.name_ = name;
- params.keypath_ = keypath;
+ params.key_path_ = key_path;
params.unique_ = unique;
params.idb_object_store_id_ = idb_object_store_id;
RenderThread::current()->Send(
@@ -116,33 +155,47 @@ void IndexedDBDispatcher::RequestIDBObjectStoreRemoveIndex(
name));
}
-void IndexedDBDispatcher::OnSuccessReturnNull(int32 response_id) {
+void IndexedDBDispatcher::OnSuccessNull(int32 response_id) {
WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
callbacks->onSuccess();
pending_callbacks_.Remove(response_id);
}
-void IndexedDBDispatcher::OnSuccessCreateIDBDatabase(int32 response_id,
- int32 object_id) {
+void IndexedDBDispatcher::OnSuccessIDBDatabase(int32 response_id,
+ int32 object_id) {
WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
callbacks->onSuccess(new RendererWebIDBDatabaseImpl(object_id));
pending_callbacks_.Remove(response_id);
}
-void IndexedDBDispatcher::OnSuccessCreateIDBObjectStore(int32 response_id,
- int32 object_id) {
+void IndexedDBDispatcher::OnSuccessIndexedDBKey(int32 response_id,
+ const IndexedDBKey& key) {
+ WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
+ callbacks->onSuccess(key);
+ pending_callbacks_.Remove(response_id);
+}
+
+void IndexedDBDispatcher::OnSuccessIDBObjectStore(int32 response_id,
+ int32 object_id) {
WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
callbacks->onSuccess(new RendererWebIDBObjectStoreImpl(object_id));
pending_callbacks_.Remove(response_id);
}
-void IndexedDBDispatcher::OnSuccessCreateIDBIndex(int32 response_id,
- int32 object_id) {
+void IndexedDBDispatcher::OnSuccessIDBIndex(int32 response_id,
+ int32 object_id) {
WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
callbacks->onSuccess(new RendererWebIDBIndexImpl(object_id));
pending_callbacks_.Remove(response_id);
}
+void IndexedDBDispatcher::OnSuccessSerializedScriptValue(
+ int32 response_id, const SerializedScriptValue& value) {
+ WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
+ callbacks->onSuccess(value);
+ pending_callbacks_.Remove(response_id);
+}
+
void IndexedDBDispatcher::OnError(int32 response_id, int code,
const string16& message) {
WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
diff --git a/chrome/renderer/indexed_db_dispatcher.h b/chrome/renderer/indexed_db_dispatcher.h
index a9eb1cb..e405ea9 100644
--- a/chrome/renderer/indexed_db_dispatcher.h
+++ b/chrome/renderer/indexed_db_dispatcher.h
@@ -6,11 +6,14 @@
#define CHROME_RENDERER_INDEXED_DB_DISPATCHER_H_
#include "base/id_map.h"
-#include "base/string16.h"
+#include "base/nullable_string16.h"
#include "ipc/ipc_message.h"
#include "third_party/WebKit/WebKit/chromium/public/WebIDBCallbacks.h"
#include "third_party/WebKit/WebKit/chromium/public/WebIDBDatabase.h"
+class IndexedDBKey;
+class SerializedScriptValue;
+
namespace WebKit {
class WebFrame;
}
@@ -31,15 +34,29 @@ class IndexedDBDispatcher {
WebKit::WebFrame* web_frame);
void RequestIDBDatabaseCreateObjectStore(
- const string16& name, const string16& keypath, bool auto_increment,
- WebKit::WebIDBCallbacks* callbacks, int32 idb_database_id);
+ const string16& name, const NullableString16& key_path,
+ bool auto_increment, WebKit::WebIDBCallbacks* callbacks,
+ int32 idb_database_id);
void RequestIDBDatabaseRemoveObjectStore(
const string16& name, WebKit::WebIDBCallbacks* callbacks,
int32 idb_database_id);
+ void RequestIDBObjectStoreGet(
+ const IndexedDBKey& key, WebKit::WebIDBCallbacks* callbacks,
+ int32 idb_object_store_id);
+
+ void RequestIDBObjectStorePut(
+ const SerializedScriptValue& value, const IndexedDBKey& key,
+ bool add_only, WebKit::WebIDBCallbacks* callbacks,
+ int32 idb_object_store_id);
+
+ void RequestIDBObjectStoreRemove(
+ const IndexedDBKey& key, WebKit::WebIDBCallbacks* callbacks,
+ int32 idb_object_store_id);
+
void RequestIDBObjectStoreCreateIndex(
- const string16& name, const string16& keypath, bool unique,
+ const string16& name, const NullableString16& key_path, bool unique,
WebKit::WebIDBCallbacks* callbacks, int32 idb_object_store_id);
void RequestIDBObjectStoreRemoveIndex(
@@ -48,10 +65,13 @@ class IndexedDBDispatcher {
private:
// IDBCallback message handlers.
- void OnSuccessReturnNull(int32 response_id);
- void OnSuccessCreateIDBDatabase(int32 response_id, int32 object_id);
- void OnSuccessCreateIDBObjectStore(int32 response_id, int32 object_id);
- void OnSuccessCreateIDBIndex(int32 response_id, int32 object_id);
+ void OnSuccessNull(int32 response_id);
+ void OnSuccessIDBDatabase(int32 response_id, int32 object_id);
+ void OnSuccessIndexedDBKey(int32 response_id, const IndexedDBKey& key);
+ void OnSuccessIDBObjectStore(int32 response_id, int32 object_id);
+ void OnSuccessIDBIndex(int32 response_id, int32 object_id);
+ void OnSuccessSerializedScriptValue(int32 response_id,
+ const SerializedScriptValue& value);
void OnError(int32 response_id, int code, const string16& message);
// Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be
diff --git a/chrome/renderer/renderer_webidbindex_impl.cc b/chrome/renderer/renderer_webidbindex_impl.cc
index 916ccd9..9f69c51 100644
--- a/chrome/renderer/renderer_webidbindex_impl.cc
+++ b/chrome/renderer/renderer_webidbindex_impl.cc
@@ -31,7 +31,7 @@ WebString RendererWebIDBIndexImpl::name() {
}
WebString RendererWebIDBIndexImpl::keyPath() {
- string16 result;
+ NullableString16 result;
RenderThread::current()->Send(
new ViewHostMsg_IDBIndexKeyPath(idb_index_id_, &result));
return result;
diff --git a/chrome/renderer/renderer_webidbobjectstore_impl.cc b/chrome/renderer/renderer_webidbobjectstore_impl.cc
index 79c0da8..5441dab 100644
--- a/chrome/renderer/renderer_webidbobjectstore_impl.cc
+++ b/chrome/renderer/renderer_webidbobjectstore_impl.cc
@@ -4,17 +4,22 @@
#include "chrome/renderer/renderer_webidbobjectstore_impl.h"
+#include "chrome/common/indexed_db_key.h"
#include "chrome/common/render_messages.h"
+#include "chrome/common/serialized_script_value.h"
#include "chrome/renderer/indexed_db_dispatcher.h"
#include "chrome/renderer/render_thread.h"
#include "chrome/renderer/renderer_webidbindex_impl.h"
#include "third_party/WebKit/WebKit/chromium/public/WebDOMStringList.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebIDBKey.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
using WebKit::WebDOMStringList;
using WebKit::WebFrame;
using WebKit::WebIDBCallbacks;
using WebKit::WebIDBIndex;
+using WebKit::WebIDBKey;
+using WebKit::WebSerializedScriptValue;
using WebKit::WebString;
RendererWebIDBObjectStoreImpl::RendererWebIDBObjectStoreImpl(
@@ -35,7 +40,7 @@ WebString RendererWebIDBObjectStoreImpl::name() const {
}
WebString RendererWebIDBObjectStoreImpl::keyPath() const {
- string16 result;
+ NullableString16 result;
RenderThread::current()->Send(
new ViewHostMsg_IDBObjectStoreKeyPath(idb_object_store_id_, &result));
return result;
@@ -53,6 +58,32 @@ WebDOMStringList RendererWebIDBObjectStoreImpl::indexNames() const {
return web_result;
}
+void RendererWebIDBObjectStoreImpl::get(const WebIDBKey& key,
+ WebIDBCallbacks* callbacks) {
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RequestIDBObjectStoreGet(IndexedDBKey(key),
+ callbacks, idb_object_store_id_);
+}
+
+void RendererWebIDBObjectStoreImpl::put(
+ const WebSerializedScriptValue& value, const WebIDBKey& key, bool add_only,
+ WebIDBCallbacks* callbacks) {
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RequestIDBObjectStorePut(
+ SerializedScriptValue(value), IndexedDBKey(key), add_only, callbacks,
+ idb_object_store_id_);
+}
+
+void RendererWebIDBObjectStoreImpl::remove(const WebIDBKey& key,
+ WebIDBCallbacks* callbacks) {
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RequestIDBObjectStoreRemove(IndexedDBKey(key), callbacks,
+ idb_object_store_id_);
+}
+
void RendererWebIDBObjectStoreImpl::createIndex(
const WebString& name, const WebString& key_path, bool unique,
WebIDBCallbacks* callbacks) {
diff --git a/chrome/renderer/renderer_webidbobjectstore_impl.h b/chrome/renderer/renderer_webidbobjectstore_impl.h
index 06625fd..462f02e 100644
--- a/chrome/renderer/renderer_webidbobjectstore_impl.h
+++ b/chrome/renderer/renderer_webidbobjectstore_impl.h
@@ -13,18 +13,25 @@ namespace WebKit {
class WebFrame;
class WebIDBCallbacks;
class WebIDBIndex;
+class WebIDBKey;
class WebString;
}
class RendererWebIDBObjectStoreImpl : public WebKit::WebIDBObjectStore {
public:
explicit RendererWebIDBObjectStoreImpl(int32 idb_object_store_id);
- virtual ~RendererWebIDBObjectStoreImpl();
+ ~RendererWebIDBObjectStoreImpl();
// WebKit::WebIDBObjectStore
- virtual WebKit::WebString name() const;
- virtual WebKit::WebString keyPath() const;
- virtual WebKit::WebDOMStringList indexNames() const;
+ WebKit::WebString name() const;
+ WebKit::WebString keyPath() const;
+ WebKit::WebDOMStringList indexNames() const;
+
+ void get(const WebKit::WebIDBKey& key, WebKit::WebIDBCallbacks* callbacks);
+ void put(const WebKit::WebSerializedScriptValue& value,
+ const WebKit::WebIDBKey& key, bool add_only,
+ WebKit::WebIDBCallbacks* callbacks);
+ void remove(const WebKit::WebIDBKey& key, WebKit::WebIDBCallbacks* callbacks);
void createIndex(const WebKit::WebString& name,
const WebKit::WebString& key_path, bool unique,