summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/in_process_webkit/indexed_db_callbacks.h54
-rw-r--r--chrome/browser/in_process_webkit/indexed_db_dispatcher_host.cc66
-rw-r--r--chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h9
-rw-r--r--chrome/chrome_common.gypi4
-rw-r--r--chrome/common/indexed_db_key.cc54
-rw-r--r--chrome/common/indexed_db_key.h34
-rw-r--r--chrome/common/render_messages.h99
-rw-r--r--chrome/common/render_messages_internal.h42
-rw-r--r--chrome/common/serialized_script_value.cc37
-rw-r--r--chrome/common/serialized_script_value.h34
-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
15 files changed, 552 insertions, 60 deletions
diff --git a/chrome/browser/in_process_webkit/indexed_db_callbacks.h b/chrome/browser/in_process_webkit/indexed_db_callbacks.h
index 56c5fd5..126a8f6 100644
--- a/chrome/browser/in_process_webkit/indexed_db_callbacks.h
+++ b/chrome/browser/in_process_webkit/indexed_db_callbacks.h
@@ -9,7 +9,9 @@
#include "base/logging.h"
#include "base/ref_counted.h"
#include "chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h"
+#include "chrome/common/indexed_db_key.h"
#include "chrome/common/render_messages.h"
+#include "chrome/common/serialized_script_value.h"
#include "third_party/WebKit/WebKit/chromium/public/WebIDBCallbacks.h"
#include "third_party/WebKit/WebKit/chromium/public/WebIDBDatabaseError.h"
@@ -17,13 +19,13 @@
// which (overloaded) onSuccess method we expect to be called.
template <class Type> struct WebIDBToMsgHelper { };
template <> struct WebIDBToMsgHelper<WebKit::WebIDBDatabase> {
- typedef ViewMsg_IDBCallbackSuccessCreateIDBDatabase MsgType;
+ typedef ViewMsg_IDBCallbacksSuccessIDBDatabase MsgType;
};
template <> struct WebIDBToMsgHelper<WebKit::WebIDBIndex> {
- typedef ViewMsg_IDBCallbackSuccessCreateIDBIndex MsgType;
+ typedef ViewMsg_IDBCallbacksSuccessIDBIndex MsgType;
};
template <> struct WebIDBToMsgHelper<WebKit::WebIDBObjectStore> {
- typedef ViewMsg_IDBCallbackSuccessCreateIDBObjectStore MsgType;
+ typedef ViewMsg_IDBCallbacksSuccessIDBObjectStore MsgType;
};
// The code the following two classes share.
@@ -34,7 +36,7 @@ class IndexedDBCallbacksBase : public WebKit::WebIDBCallbacks {
: dispatcher_host_(dispatcher_host), response_id_(response_id) { }
virtual void onError(const WebKit::WebIDBDatabaseError& error) {
- dispatcher_host_->Send(new ViewMsg_IDBCallbackError(
+ dispatcher_host_->Send(new ViewMsg_IDBCallbacksError(
response_id_, error.code(), error.message()));
}
@@ -70,6 +72,48 @@ class IndexedDBCallbacks : public IndexedDBCallbacksBase {
DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks);
};
+// WebIDBKey is implemented in WebKit as opposed to being an interface Chromium
+// implements. Thus we pass a const ___& version and thus we need this
+// specialization.
+template <>
+class IndexedDBCallbacks<WebKit::WebIDBKey>
+ : public IndexedDBCallbacksBase {
+ public:
+ IndexedDBCallbacks(
+ IndexedDBDispatcherHost* dispatcher_host, int32 response_id)
+ : IndexedDBCallbacksBase(dispatcher_host, response_id) { }
+
+ virtual void onSuccess(const WebKit::WebIDBKey& value) {
+ dispatcher_host()->Send(
+ new ViewMsg_IDBCallbacksSuccessIndexedDBKey(
+ response_id(), IndexedDBKey(value)));
+ }
+
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks);
+};
+
+// WebSerializedScriptValue is implemented in WebKit as opposed to being an
+// interface Chromium implements. Thus we pass a const ___& version and thus
+// we need this specialization.
+template <>
+class IndexedDBCallbacks<WebKit::WebSerializedScriptValue>
+ : public IndexedDBCallbacksBase {
+ public:
+ IndexedDBCallbacks(
+ IndexedDBDispatcherHost* dispatcher_host, int32 response_id)
+ : IndexedDBCallbacksBase(dispatcher_host, response_id) { }
+
+ virtual void onSuccess(const WebKit::WebSerializedScriptValue& value) {
+ dispatcher_host()->Send(
+ new ViewMsg_IDBCallbacksSuccessSerializedScriptValue(
+ response_id(), SerializedScriptValue(value)));
+ }
+
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks);
+};
+
// A WebIDBCallbacks implementation that doesn't return a result.
template <>
class IndexedDBCallbacks<void> : public IndexedDBCallbacksBase {
@@ -80,7 +124,7 @@ class IndexedDBCallbacks<void> : public IndexedDBCallbacksBase {
virtual void onSuccess() {
dispatcher_host()->Send(
- new ViewMsg_IDBCallbackSuccessReturnNull(response_id()));
+ new ViewMsg_IDBCallbacksSuccessNull(response_id()));
}
private:
diff --git a/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.cc b/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.cc
index 8c1b69e..f6523a1 100644
--- a/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.cc
+++ b/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/renderer_host/resource_message_filter.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/render_messages.h"
+#include "chrome/common/serialized_script_value.h"
#include "third_party/WebKit/WebKit/chromium/public/WebDOMStringList.h"
#include "third_party/WebKit/WebKit/chromium/public/WebIDBDatabase.h"
#include "third_party/WebKit/WebKit/chromium/public/WebIDBDatabaseError.h"
@@ -23,8 +24,10 @@ using WebKit::WebDOMStringList;
using WebKit::WebIDBDatabase;
using WebKit::WebIDBDatabaseError;
using WebKit::WebIDBIndex;
+using WebKit::WebIDBKey;
using WebKit::WebIDBObjectStore;
using WebKit::WebSecurityOrigin;
+using WebKit::WebSerializedScriptValue;
IndexedDBDispatcherHost::IndexedDBDispatcherHost(
IPC::Message::Sender* sender, WebKitContext* webkit_context)
@@ -82,8 +85,10 @@ bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message) {
case ViewHostMsg_IDBDatabaseName::ID:
case ViewHostMsg_IDBDatabaseDescription::ID:
case ViewHostMsg_IDBDatabaseVersion::ID:
- case ViewHostMsg_IDBDatabaseCreateObjectStore::ID:
case ViewHostMsg_IDBDatabaseObjectStores::ID:
+ case ViewHostMsg_IDBDatabaseCreateObjectStore::ID:
+ case ViewHostMsg_IDBDatabaseObjectStore::ID:
+ case ViewHostMsg_IDBDatabaseRemoveObjectStore::ID:
case ViewHostMsg_IDBDatabaseDestroyed::ID:
case ViewHostMsg_IDBIndexName::ID:
case ViewHostMsg_IDBIndexKeyPath::ID:
@@ -91,6 +96,13 @@ bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message) {
case ViewHostMsg_IDBIndexDestroyed::ID:
case ViewHostMsg_IDBObjectStoreName::ID:
case ViewHostMsg_IDBObjectStoreKeyPath::ID:
+ case ViewHostMsg_IDBObjectStoreIndexNames::ID:
+ case ViewHostMsg_IDBObjectStoreGet::ID:
+ case ViewHostMsg_IDBObjectStorePut::ID:
+ case ViewHostMsg_IDBObjectStoreRemove::ID:
+ case ViewHostMsg_IDBObjectStoreCreateIndex::ID:
+ case ViewHostMsg_IDBObjectStoreIndex::ID:
+ case ViewHostMsg_IDBObjectStoreRemoveIndex::ID:
case ViewHostMsg_IDBObjectStoreDestroyed::ID:
break;
default:
@@ -309,7 +321,7 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStore(
if (!idb_database)
return;
idb_database->createObjectStore(
- params.name_, params.keypath_, params.auto_increment_,
+ params.name_, params.key_path_, params.auto_increment_,
new IndexedDBCallbacks<WebIDBObjectStore>(parent_, params.response_id_));
}
@@ -390,7 +402,7 @@ void IndexedDBDispatcherHost::IndexDispatcherHost::OnName(
void IndexedDBDispatcherHost::IndexDispatcherHost::OnKeyPath(
int32 object_id, IPC::Message* reply_msg) {
- parent_->SyncGetter<string16, ViewHostMsg_IDBIndexKeyPath>(
+ parent_->SyncGetter<NullableString16, ViewHostMsg_IDBIndexKeyPath>(
&map_, object_id, reply_msg, &WebIDBIndex::keyPath);
}
@@ -426,6 +438,14 @@ bool IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnMessageReceived(
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBObjectStoreName, OnName)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBObjectStoreKeyPath,
OnKeyPath)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBObjectStoreIndexNames,
+ OnIndexNames)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_IDBObjectStoreGet, OnGet);
+ IPC_MESSAGE_HANDLER(ViewHostMsg_IDBObjectStorePut, OnPut);
+ IPC_MESSAGE_HANDLER(ViewHostMsg_IDBObjectStoreRemove, OnRemove);
+ IPC_MESSAGE_HANDLER(ViewHostMsg_IDBObjectStoreCreateIndex, OnCreateIndex);
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBObjectStoreIndex, OnIndex);
+ IPC_MESSAGE_HANDLER(ViewHostMsg_IDBObjectStoreRemoveIndex, OnRemoveIndex);
IPC_MESSAGE_HANDLER(ViewHostMsg_IDBObjectStoreDestroyed, OnDestroyed)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -448,7 +468,7 @@ void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnName(
void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnKeyPath(
int32 object_id, IPC::Message* reply_msg) {
- parent_->SyncGetter<string16, ViewHostMsg_IDBObjectStoreKeyPath>(
+ parent_->SyncGetter<NullableString16, ViewHostMsg_IDBObjectStoreKeyPath>(
&map_, object_id, reply_msg, &WebIDBObjectStore::keyPath);
}
@@ -470,6 +490,42 @@ void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnIndexNames(
parent_->Send(reply_msg);
}
+void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnGet(
+ int idb_object_store_id, int32 response_id, const IndexedDBKey& key) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
+ WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess(
+ &map_, idb_object_store_id, NULL, ViewHostMsg_IDBObjectStoreGet::ID);
+ if (!idb_object_store)
+ return;
+ idb_object_store->get(key, new IndexedDBCallbacks<WebSerializedScriptValue>(
+ parent_, response_id));
+}
+
+void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnPut(
+ int idb_object_store_id, int32 response_id,
+ const SerializedScriptValue& value, const IndexedDBKey& key,
+ bool add_only) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
+ WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess(
+ &map_, idb_object_store_id, NULL, ViewHostMsg_IDBObjectStorePut::ID);
+ if (!idb_object_store)
+ return;
+ idb_object_store->put(
+ value, key, add_only, new IndexedDBCallbacks<WebIDBKey>(
+ parent_, response_id));
+}
+
+void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnRemove(
+ int idb_object_store_id, int32 response_id, const IndexedDBKey& key) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
+ WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess(
+ &map_, idb_object_store_id, NULL, ViewHostMsg_IDBObjectStoreRemove::ID);
+ if (!idb_object_store)
+ return;
+ idb_object_store->remove(key, new IndexedDBCallbacks<void>(parent_,
+ response_id));
+}
+
void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnCreateIndex(
const ViewHostMsg_IDBObjectStoreCreateIndex_Params& params) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
@@ -479,7 +535,7 @@ void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnCreateIndex(
if (!idb_object_store)
return;
idb_object_store->createIndex(
- params.name_, params.keypath_, params.unique_,
+ params.name_, params.key_path_, params.unique_,
new IndexedDBCallbacks<WebIDBIndex>(parent_, params.response_id_));
}
diff --git a/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h b/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h
index 368e489..cc132ae 100644
--- a/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h
+++ b/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h
@@ -12,6 +12,8 @@
#include "chrome/browser/in_process_webkit/webkit_context.h"
#include "ipc/ipc_message.h"
+class IndexedDBKey;
+class SerializedScriptValue;
struct ViewHostMsg_IndexedDatabaseOpen_Params;
struct ViewHostMsg_IDBDatabaseCreateObjectStore_Params;
struct ViewHostMsg_IDBObjectStoreCreateIndex_Params;
@@ -131,6 +133,13 @@ class IndexedDBDispatcherHost
void OnName(int32 idb_object_store_id, IPC::Message* reply_msg);
void OnKeyPath(int32 idb_object_store_id, IPC::Message* reply_msg);
void OnIndexNames(int32 idb_object_store_id, IPC::Message* reply_msg);
+ void OnGet(int idb_object_store_id, int32 response_id,
+ const IndexedDBKey& key);
+ void OnPut(int idb_object_store_id, int32 response_id,
+ const SerializedScriptValue& value, const IndexedDBKey& key,
+ bool add_only);
+ void OnRemove(int idb_object_store_id, int32 response_id,
+ const IndexedDBKey& key);
void OnCreateIndex(
const ViewHostMsg_IDBObjectStoreCreateIndex_Params& params);
void OnIndex(int32 idb_object_store_id, const string16& name,
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index e3e3c16..34ba21b 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -57,6 +57,8 @@
'common/gpu_info.cc',
'common/gpu_messages.h',
'common/gpu_messages_internal.h',
+ 'common/indexed_db_key.cc',
+ 'common/indexed_db_key.h',
'common/logging_chrome.cc',
'common/logging_chrome.h',
'common/main_function_params.h',
@@ -96,6 +98,8 @@
'common/sandbox_mac.mm',
'common/sandbox_policy.cc',
'common/sandbox_policy.h',
+ 'common/serialized_script_value.cc',
+ 'common/serialized_script_value.h',
'common/task_queue.cc',
'common/task_queue.h',
'common/time_format.cc',
diff --git a/chrome/common/indexed_db_key.cc b/chrome/common/indexed_db_key.cc
new file mode 100644
index 0000000..1c09ea2
--- /dev/null
+++ b/chrome/common/indexed_db_key.cc
@@ -0,0 +1,54 @@
+// Copyright (c) 2010 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 "chrome/common/indexed_db_key.h"
+
+#include "base/logging.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
+
+using WebKit::WebIDBKey;
+
+IndexedDBKey::IndexedDBKey()
+ : type_(WebIDBKey::InvalidType) {
+}
+
+IndexedDBKey::IndexedDBKey(const WebIDBKey& key)
+ : type_(key.type()),
+ string_(key.type() == WebIDBKey::StringType
+ ? static_cast<string16>(key.string()) : string16()),
+ number_(key.type() == WebIDBKey::NumberType ? key.number() : 0) {
+}
+
+void IndexedDBKey::SetNull() {
+ type_ = WebIDBKey::NullType;
+}
+
+void IndexedDBKey::SetInvalid() {
+ type_ = WebIDBKey::InvalidType;
+}
+
+void IndexedDBKey::Set(const string16& string) {
+ type_ = WebIDBKey::StringType;
+ string_ = string;
+}
+
+void IndexedDBKey::Set(int32_t number) {
+ type_ = WebIDBKey::NumberType;
+ number_ = number;
+}
+
+IndexedDBKey::operator WebIDBKey() const {
+ switch (type_) {
+ case WebIDBKey::NullType:
+ return WebIDBKey::createNull();
+ case WebIDBKey::StringType:
+ return WebIDBKey(string_);
+ case WebIDBKey::NumberType:
+ return WebIDBKey(number_);
+ case WebIDBKey::InvalidType:
+ return WebIDBKey::createInvalid();
+ }
+ NOTREACHED();
+ return WebIDBKey::createInvalid();
+}
diff --git a/chrome/common/indexed_db_key.h b/chrome/common/indexed_db_key.h
new file mode 100644
index 0000000..13bfae3
--- /dev/null
+++ b/chrome/common/indexed_db_key.h
@@ -0,0 +1,34 @@
+// Copyright (c) 2010 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 CHROME_COMMON_INDEXED_DB_KEY_H_
+#define CHROME_COMMON_INDEXED_DB_KEY_H_
+
+#include "base/basictypes.h"
+#include "base/string16.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebIDBKey.h"
+
+class IndexedDBKey {
+ public:
+ IndexedDBKey(); // Defaults to WebKit::WebIDBKey::InvalidType.
+ explicit IndexedDBKey(const WebKit::WebIDBKey& key);
+
+ void SetNull();
+ void SetInvalid();
+ void Set(const string16& string);
+ void Set(int32_t number);
+
+ WebKit::WebIDBKey::Type type() const { return type_; }
+ const string16& string() const { return string_; }
+ int32_t number() const { return number_; }
+
+ operator WebKit::WebIDBKey() const;
+
+ private:
+ WebKit::WebIDBKey::Type type_;
+ string16 string_;
+ int32_t number_;
+};
+
+#endif // CHROME_COMMON_INDEXED_DB_KEY_H_
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 96e8a4c..3a419cc2 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -23,12 +23,14 @@
#include "chrome/common/extensions/extension_extent.h"
#include "chrome/common/extensions/url_pattern.h"
#include "chrome/common/font_descriptor_mac.h"
+#include "chrome/common/indexed_db_key.h"
#include "chrome/common/navigation_gesture.h"
#include "chrome/common/page_transition_types.h"
#include "chrome/common/renderer_preferences.h"
#include "chrome/common/resource_response.h"
#include "chrome/common/translate_errors.h"
#include "chrome/common/view_types.h"
+#include "chrome/common/serialized_script_value.h"
#include "chrome/common/webkit_param_traits.h"
#include "chrome/common/window_container_type.h"
#include "gfx/native_widget_types.h"
@@ -569,7 +571,7 @@ struct ViewHostMsg_IDBDatabaseCreateObjectStore_Params {
string16 name_;
// The keyPath of the object store.
- string16 keypath_;
+ NullableString16 key_path_;
// Whether the object store created should have a key generator.
bool auto_increment_;
@@ -587,7 +589,7 @@ struct ViewHostMsg_IDBObjectStoreCreateIndex_Params {
string16 name_;
// The keyPath of the index.
- string16 keypath_;
+ NullableString16 key_path_;
// Whether the index created has unique keys.
bool unique_;
@@ -1586,6 +1588,87 @@ struct ParamTraits<SyncLoadResult> {
}
};
+template <>
+struct ParamTraits<SerializedScriptValue> {
+ typedef SerializedScriptValue param_type;
+ static void Write(Message* m, const param_type& p) {
+ WriteParam(m, p.is_null());
+ WriteParam(m, p.is_invalid());
+ WriteParam(m, p.data());
+ }
+ static bool Read(const Message* m, void** iter, param_type* r) {
+ bool is_null;
+ bool is_invalid;
+ string16 data;
+ bool ok =
+ ReadParam(m, iter, &is_null) &&
+ ReadParam(m, iter, &is_invalid) &&
+ ReadParam(m, iter, &data);
+ if (!ok)
+ return false;
+ r->set_is_null(is_null);
+ r->set_is_invalid(is_invalid);
+ r->set_data(data);
+ return true;
+ }
+ static void Log(const param_type& p, std::wstring* l) {
+ l->append(L"<SerializedScriptValue>(");
+ LogParam(p.is_null(), l);
+ l->append(L", ");
+ LogParam(p.is_invalid(), l);
+ l->append(L", ");
+ LogParam(p.data(), l);
+ l->append(L")");
+ }
+};
+
+template <>
+struct ParamTraits<IndexedDBKey> {
+ typedef IndexedDBKey param_type;
+ static void Write(Message* m, const param_type& p) {
+ WriteParam(m, int(p.type()));
+ // TODO(jorlow): Technically, we only need to pack the type being used.
+ WriteParam(m, p.string());
+ WriteParam(m, p.number());
+ }
+ static bool Read(const Message* m, void** iter, param_type* r) {
+ int type;
+ string16 string;
+ int32 number;
+ bool ok =
+ ReadParam(m, iter, &type) &&
+ ReadParam(m, iter, &string) &&
+ ReadParam(m, iter, &number);
+ if (!ok)
+ return false;
+ switch (type) {
+ case WebKit::WebIDBKey::NullType:
+ r->SetNull();
+ return true;
+ case WebKit::WebIDBKey::StringType:
+ r->Set(string);
+ return true;
+ case WebKit::WebIDBKey::NumberType:
+ r->Set(number);
+ return true;
+ case WebKit::WebIDBKey::InvalidType:
+ r->SetInvalid();
+ return true;
+ }
+ NOTREACHED();
+ return false;
+ }
+ static void Log(const param_type& p, std::wstring* l) {
+ l->append(L"<IndexedDBKey>(");
+ LogParam(int(p.type()), l);
+ l->append(L", ");
+ LogParam(p.string(), l);
+ l->append(L", ");
+ LogParam(p.number(), l);
+ l->append(L")");
+ }
+};
+
// Traits for FormData structure to pack/unpack.
template <>
struct ParamTraits<webkit_glue::FormData> {
@@ -2553,7 +2636,7 @@ struct ParamTraits<ViewHostMsg_IDBDatabaseCreateObjectStore_Params> {
static void Write(Message* m, const param_type& p) {
WriteParam(m, p.response_id_);
WriteParam(m, p.name_);
- WriteParam(m, p.keypath_);
+ WriteParam(m, p.key_path_);
WriteParam(m, p.auto_increment_);
WriteParam(m, p.idb_database_id_);
}
@@ -2561,7 +2644,7 @@ struct ParamTraits<ViewHostMsg_IDBDatabaseCreateObjectStore_Params> {
return
ReadParam(m, iter, &p->response_id_) &&
ReadParam(m, iter, &p->name_) &&
- ReadParam(m, iter, &p->keypath_) &&
+ ReadParam(m, iter, &p->key_path_) &&
ReadParam(m, iter, &p->auto_increment_) &&
ReadParam(m, iter, &p->idb_database_id_);
}
@@ -2571,7 +2654,7 @@ struct ParamTraits<ViewHostMsg_IDBDatabaseCreateObjectStore_Params> {
l->append(L", ");
LogParam(p.name_, l);
l->append(L", ");
- LogParam(p.keypath_, l);
+ LogParam(p.key_path_, l);
l->append(L", ");
LogParam(p.auto_increment_, l);
l->append(L", ");
@@ -2587,7 +2670,7 @@ struct ParamTraits<ViewHostMsg_IDBObjectStoreCreateIndex_Params> {
static void Write(Message* m, const param_type& p) {
WriteParam(m, p.response_id_);
WriteParam(m, p.name_);
- WriteParam(m, p.keypath_);
+ WriteParam(m, p.key_path_);
WriteParam(m, p.unique_);
WriteParam(m, p.idb_object_store_id_);
}
@@ -2595,7 +2678,7 @@ struct ParamTraits<ViewHostMsg_IDBObjectStoreCreateIndex_Params> {
return
ReadParam(m, iter, &p->response_id_) &&
ReadParam(m, iter, &p->name_) &&
- ReadParam(m, iter, &p->keypath_) &&
+ ReadParam(m, iter, &p->key_path_) &&
ReadParam(m, iter, &p->unique_) &&
ReadParam(m, iter, &p->idb_object_store_id_);
}
@@ -2605,7 +2688,7 @@ struct ParamTraits<ViewHostMsg_IDBObjectStoreCreateIndex_Params> {
l->append(L", ");
LogParam(p.name_, l);
l->append(L", ");
- LogParam(p.keypath_, l);
+ LogParam(p.key_path_, l);
l->append(L", ");
LogParam(p.unique_, l);
l->append(L", ");
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 2cb4bed..7b66469 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -842,18 +842,24 @@ IPC_BEGIN_MESSAGES(View)
ViewMsg_DOMStorageEvent_Params)
// IDBCallback message handlers.
- IPC_MESSAGE_CONTROL1(ViewMsg_IDBCallbackSuccessReturnNull,
+ IPC_MESSAGE_CONTROL1(ViewMsg_IDBCallbacksSuccessNull,
int32 /* response_id */)
- IPC_MESSAGE_CONTROL2(ViewMsg_IDBCallbackSuccessCreateIDBDatabase,
+ IPC_MESSAGE_CONTROL2(ViewMsg_IDBCallbacksSuccessIDBDatabase,
int32 /* response_id */,
int32 /* idb_database_id */)
- IPC_MESSAGE_CONTROL2(ViewMsg_IDBCallbackSuccessCreateIDBObjectStore,
+ IPC_MESSAGE_CONTROL2(ViewMsg_IDBCallbacksSuccessIndexedDBKey,
int32 /* response_id */,
- int32 /* idb_callback_id */)
- IPC_MESSAGE_CONTROL2(ViewMsg_IDBCallbackSuccessCreateIDBIndex,
+ IndexedDBKey /* indexed_db_key */)
+ IPC_MESSAGE_CONTROL2(ViewMsg_IDBCallbacksSuccessIDBObjectStore,
+ int32 /* response_id */,
+ int32 /* idb_object_store_id */)
+ IPC_MESSAGE_CONTROL2(ViewMsg_IDBCallbacksSuccessIDBIndex,
int32 /* response_id */,
int32 /* idb_index_id */)
- IPC_MESSAGE_CONTROL3(ViewMsg_IDBCallbackError,
+ IPC_MESSAGE_CONTROL2(ViewMsg_IDBCallbacksSuccessSerializedScriptValue,
+ int32 /* response_id */,
+ SerializedScriptValue /* serialized_script_value */)
+ IPC_MESSAGE_CONTROL3(ViewMsg_IDBCallbacksError,
int32 /* response_id */,
int /* code */,
string16 /* message */)
@@ -2229,7 +2235,7 @@ IPC_BEGIN_MESSAGES(ViewHost)
// WebIDBIndex::keyPath() message.
IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_IDBIndexKeyPath,
int32, /* idb_index_id */
- string16 /* key_path */)
+ NullableString16 /* key_path */)
// WebIDBIndex::unique() message.
IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_IDBIndexUnique,
@@ -2248,13 +2254,33 @@ IPC_BEGIN_MESSAGES(ViewHost)
// WebIDBObjectStore::keyPath() message.
IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_IDBObjectStoreKeyPath,
int32, /* idb_object_store_id */
- string16 /* keyPath */)
+ NullableString16 /* keyPath */)
// WebIDBObjectStore::indexNames() message.
IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_IDBObjectStoreIndexNames,
int32, /* idb_object_store_id */
std::vector<string16> /* index_names */)
+ // WebIDBObjectStore::get() message.
+ IPC_MESSAGE_CONTROL3(ViewHostMsg_IDBObjectStoreGet,
+ int32, /* idb_object_store_id */
+ int32, /* response_id */
+ IndexedDBKey /* key */)
+
+ // WebIDBObjectStore::put() message.
+ IPC_MESSAGE_CONTROL5(ViewHostMsg_IDBObjectStorePut,
+ int32, /* idb_object_store_id */
+ int32, /* response_id */
+ SerializedScriptValue, /* serialized_value */
+ IndexedDBKey, /* key */
+ bool /* add_only */)
+
+ // WebIDBObjectStore::remove() message.
+ IPC_MESSAGE_CONTROL3(ViewHostMsg_IDBObjectStoreRemove,
+ int32, /* idb_object_store_id */
+ int32, /* response_id */
+ IndexedDBKey /* key */)
+
// WebIDBObjectStore::createIndex() message.
IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBObjectStoreCreateIndex,
ViewHostMsg_IDBObjectStoreCreateIndex_Params)
diff --git a/chrome/common/serialized_script_value.cc b/chrome/common/serialized_script_value.cc
new file mode 100644
index 0000000..095f4e6
--- /dev/null
+++ b/chrome/common/serialized_script_value.cc
@@ -0,0 +1,37 @@
+// Copyright (c) 2010 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 "chrome/common/serialized_script_value.h"
+
+#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
+
+using WebKit::WebSerializedScriptValue;
+
+SerializedScriptValue::SerializedScriptValue()
+ : is_null_(true),
+ is_invalid_(false) {
+}
+
+SerializedScriptValue::SerializedScriptValue(
+ bool is_null, bool is_invalid, const string16& data)
+ : is_null_(is_null),
+ is_invalid_(is_invalid),
+ data_(data) {
+}
+
+SerializedScriptValue::SerializedScriptValue(
+ const WebSerializedScriptValue& value)
+ : is_null_(value.isNull()),
+ is_invalid_(value.isNull() ? false : value.toString().isNull()),
+ data_(value.isNull() ? string16()
+ : static_cast<string16>(value.toString())) {
+}
+
+SerializedScriptValue::operator WebSerializedScriptValue() const {
+ if (is_null_)
+ return WebSerializedScriptValue();
+ if (is_invalid_)
+ return WebSerializedScriptValue::createInvalid();
+ return WebSerializedScriptValue::fromString(data_);
+}
diff --git a/chrome/common/serialized_script_value.h b/chrome/common/serialized_script_value.h
new file mode 100644
index 0000000..e464134
--- /dev/null
+++ b/chrome/common/serialized_script_value.h
@@ -0,0 +1,34 @@
+// Copyright (c) 2010 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 CHROME_COMMON_SERIALIZED_SCRIPT_VALUE_H_
+#define CHROME_COMMON_SERIALIZED_SCRIPT_VALUE_H_
+
+#include "base/string16.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebSerializedScriptValue.h"
+
+class SerializedScriptValue {
+ public:
+ SerializedScriptValue();
+ SerializedScriptValue(bool is_null, bool is_invalid, const string16& data);
+ explicit SerializedScriptValue(const WebKit::WebSerializedScriptValue& value);
+
+ void set_is_null(bool is_null) { is_null_ = is_null; }
+ bool is_null() const { return is_null_; }
+
+ void set_is_invalid(bool is_invalid) { is_invalid_ = is_invalid; }
+ bool is_invalid() const { return is_invalid_; }
+
+ void set_data(const string16& data) { data_ = data; }
+ const string16& data() const { return data_; }
+
+ operator WebKit::WebSerializedScriptValue() const;
+
+ private:
+ bool is_null_; // Is this null? If so, none of the other properties are valid.
+ bool is_invalid_; // Is data_ valid?
+ string16 data_; // The wire string format of the serialized script value.
+};
+
+#endif // CHROME_COMMON_SERIALIZED_SCRIPT_VALUE_H_
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,