diff options
author | alecflett@chromium.org <alecflett@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-11 00:03:15 +0000 |
---|---|---|
committer | alecflett@chromium.org <alecflett@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-11 00:03:15 +0000 |
commit | 704e73381ab65bb0650649d38831cf17c9937166 (patch) | |
tree | d031f833f643e65329e220a4a1ab5e8cf67813ab /content | |
parent | f91ba81ad5fc38f5a9f4980d7d652c64d85193eb (diff) | |
download | chromium_src-704e73381ab65bb0650649d38831cf17c9937166.zip chromium_src-704e73381ab65bb0650649d38831cf17c9937166.tar.gz chromium_src-704e73381ab65bb0650649d38831cf17c9937166.tar.bz2 |
Chromium side of plumbing for passing renderer-generated keys through IPC
BUG=129471
TEST=
Review URL: https://chromiumcodereview.appspot.com/10759012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145998 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
7 files changed, 71 insertions, 11 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 bf9ebf7..d534692 100644 --- a/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc +++ b/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc @@ -711,6 +711,7 @@ void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnPut( scoped_ptr<WebIDBCallbacks> callbacks( new IndexedDBCallbacks<WebIDBKey>(parent_, params.thread_id, params.response_id)); + // TODO(alecflett): switch to putWithIndexKeys when available. idb_object_store->put(params.serialized_value, params.key, params.put_mode, callbacks.release(), *idb_transaction, *ec); if (*ec) diff --git a/content/common/indexed_db/indexed_db_dispatcher.cc b/content/common/indexed_db/indexed_db_dispatcher.cc index c51574e..e308357 100644 --- a/content/common/indexed_db/indexed_db_dispatcher.cc +++ b/content/common/indexed_db/indexed_db_dispatcher.cc @@ -421,6 +421,8 @@ void IndexedDBDispatcher::RequestIDBObjectStorePut( WebIDBCallbacks* callbacks_ptr, int32 idb_object_store_id, const WebIDBTransaction& transaction, + const WebKit::WebVector<WebKit::WebString>& index_names, + const WebKit::WebVector<WebKit::WebVector<WebKit::WebIDBKey> >& index_keys, WebExceptionCode* ec) { ResetCursorPrefetchCaches(); scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); @@ -437,6 +439,18 @@ void IndexedDBDispatcher::RequestIDBObjectStorePut( params.key = key; params.put_mode = put_mode; params.transaction_id = TransactionId(transaction); + params.index_names.resize(index_names.size()); + for (size_t i = 0; i < index_names.size(); ++i) { + params.index_names[i] = index_names[i]; + } + + params.index_keys.resize(index_keys.size()); + for (size_t i = 0; i < index_keys.size(); ++i) { + params.index_keys[i].resize(index_keys[i].size()); + for (size_t j = 0; j < index_keys[i].size(); ++j) { + params.index_keys[i][j] = content::IndexedDBKey(index_keys[i][j]); + } + } Send(new IndexedDBHostMsg_ObjectStorePut(params, ec)); if (*ec) pending_callbacks_.Remove(params.response_id); diff --git a/content/common/indexed_db/indexed_db_dispatcher.h b/content/common/indexed_db/indexed_db_dispatcher.h index 5df5161..915fa81 100644 --- a/content/common/indexed_db/indexed_db_dispatcher.h +++ b/content/common/indexed_db/indexed_db_dispatcher.h @@ -169,13 +169,16 @@ class CONTENT_EXPORT IndexedDBDispatcher const WebKit::WebIDBTransaction& transaction, WebKit::WebExceptionCode* ec); - void RequestIDBObjectStorePut(const content::SerializedScriptValue& value, - const content::IndexedDBKey& key, - WebKit::WebIDBObjectStore::PutMode putMode, - WebKit::WebIDBCallbacks* callbacks, - int32 idb_object_store_id, - const WebKit::WebIDBTransaction& transaction, - WebKit::WebExceptionCode* ec); + void RequestIDBObjectStorePut( + const content::SerializedScriptValue& value, + const content::IndexedDBKey& key, + WebKit::WebIDBObjectStore::PutMode putMode, + WebKit::WebIDBCallbacks* callbacks, + int32 idb_object_store_id, + const WebKit::WebIDBTransaction& transaction, + const WebKit::WebVector<WebKit::WebString>& indexNames, + const WebKit::WebVector<WebKit::WebVector<WebKit::WebIDBKey> >& indexKeys, + WebKit::WebExceptionCode* ec); void RequestIDBObjectStoreDelete( const content::IndexedDBKeyRange& key_range, diff --git a/content/common/indexed_db/indexed_db_dispatcher_unittest.cc b/content/common/indexed_db/indexed_db_dispatcher_unittest.cc index fa77f29..db5ab25 100644 --- a/content/common/indexed_db/indexed_db_dispatcher_unittest.cc +++ b/content/common/indexed_db/indexed_db_dispatcher_unittest.cc @@ -14,6 +14,8 @@ using content::IndexedDBKey; using content::SerializedScriptValue; +using WebKit::WebVector; +using WebKit::WebString; class FakeWebIDBTransaction : public WebKit::WebIDBTransaction { public: @@ -40,6 +42,8 @@ TEST(IndexedDBDispatcherTest, ValueSizeTest) { static_cast<WebKit::WebIDBCallbacks*>(NULL), dummy_id, FakeWebIDBTransaction(), + WebVector<WebString>(), + WebVector<WebVector<WebKit::WebIDBKey> >(), &ec); EXPECT_NE(ec, 0); } diff --git a/content/common/indexed_db/indexed_db_messages.h b/content/common/indexed_db/indexed_db_messages.h index 5ed579e..7a75037 100644 --- a/content/common/indexed_db/indexed_db_messages.h +++ b/content/common/indexed_db/indexed_db_messages.h @@ -110,6 +110,12 @@ IPC_STRUCT_BEGIN(IndexedDBHostMsg_ObjectStorePut_Params) IPC_STRUCT_MEMBER(content::IndexedDBKey, key) // Whether this is an add or a put. IPC_STRUCT_MEMBER(WebKit::WebIDBObjectStore::PutMode, put_mode) + // The names of the indexes used below. + IPC_STRUCT_MEMBER(std::vector<string16>, index_names) + // The keys for each index, such that each inner vector corresponds + // to each index named in index_names, respectively. + IPC_STRUCT_MEMBER(std::vector<std::vector<content::IndexedDBKey> >, + index_keys) // The transaction it's associated with. IPC_STRUCT_MEMBER(int, transaction_id) IPC_STRUCT_END() diff --git a/content/common/indexed_db/proxy_webidbobjectstore_impl.cc b/content/common/indexed_db/proxy_webidbobjectstore_impl.cc index 85a5838..4e34db5 100644 --- a/content/common/indexed_db/proxy_webidbobjectstore_impl.cc +++ b/content/common/indexed_db/proxy_webidbobjectstore_impl.cc @@ -18,7 +18,9 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerializedScriptValue.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" +using content::IndexedDBKey; using content::IndexedDBKeyPath; +using content::IndexedDBKeyRange; using content::SerializedScriptValue; using WebKit::WebDOMStringList; using WebKit::WebExceptionCode; @@ -31,6 +33,7 @@ using WebKit::WebIDBKey; using WebKit::WebIDBTransaction; using WebKit::WebSerializedScriptValue; using WebKit::WebString; +using WebKit::WebVector; RendererWebIDBObjectStoreImpl::RendererWebIDBObjectStoreImpl( int32 idb_object_store_id) @@ -54,7 +57,7 @@ void RendererWebIDBObjectStoreImpl::get( IndexedDBDispatcher* dispatcher = IndexedDBDispatcher::ThreadSpecificInstance(); dispatcher->RequestIDBObjectStoreGet( - content::IndexedDBKeyRange(key_range), callbacks, + IndexedDBKeyRange(key_range), callbacks, idb_object_store_id_, transaction, &ec); } @@ -67,9 +70,29 @@ void RendererWebIDBObjectStoreImpl::put( WebExceptionCode& ec) { IndexedDBDispatcher* dispatcher = IndexedDBDispatcher::ThreadSpecificInstance(); + WebVector<WebString> emptyIndexNames; + WebVector<WebVector<WebIDBKey> > emptyIndexKeys; dispatcher->RequestIDBObjectStorePut( - SerializedScriptValue(value), content::IndexedDBKey(key), - put_mode, callbacks, idb_object_store_id_, transaction, &ec); + SerializedScriptValue(value), IndexedDBKey(key), + put_mode, callbacks, idb_object_store_id_, transaction, + emptyIndexNames, emptyIndexKeys, &ec); +} + +void RendererWebIDBObjectStoreImpl::putWithIndexKeys( + const WebSerializedScriptValue& value, + const WebIDBKey& key, + PutMode put_mode, + WebIDBCallbacks* callbacks, + const WebIDBTransaction& transaction, + const WebVector<WebString>& indexNames, + const WebVector<WebVector<WebIDBKey> >& indexKeys, + WebExceptionCode& ec) { + IndexedDBDispatcher* dispatcher = + IndexedDBDispatcher::ThreadSpecificInstance(); + dispatcher->RequestIDBObjectStorePut( + SerializedScriptValue(value), IndexedDBKey(key), + put_mode, callbacks, idb_object_store_id_, transaction, + indexNames, indexKeys, &ec); } void RendererWebIDBObjectStoreImpl::deleteFunction( @@ -80,7 +103,7 @@ void RendererWebIDBObjectStoreImpl::deleteFunction( IndexedDBDispatcher* dispatcher = IndexedDBDispatcher::ThreadSpecificInstance(); dispatcher->RequestIDBObjectStoreDelete( - content::IndexedDBKeyRange(key_range), callbacks, idb_object_store_id_, + IndexedDBKeyRange(key_range), callbacks, idb_object_store_id_, transaction, &ec); } diff --git a/content/common/indexed_db/proxy_webidbobjectstore_impl.h b/content/common/indexed_db/proxy_webidbobjectstore_impl.h index c9e6659..8e0e6e4 100644 --- a/content/common/indexed_db/proxy_webidbobjectstore_impl.h +++ b/content/common/indexed_db/proxy_webidbobjectstore_impl.h @@ -34,6 +34,15 @@ class RendererWebIDBObjectStoreImpl : public WebKit::WebIDBObjectStore { WebKit::WebIDBCallbacks* callbacks, const WebKit::WebIDBTransaction& transaction, WebKit::WebExceptionCode& ec); + virtual void putWithIndexKeys( + const WebKit::WebSerializedScriptValue&, + const WebKit::WebIDBKey&, + PutMode, + WebKit::WebIDBCallbacks*, + const WebKit::WebIDBTransaction&, + const WebKit::WebVector<WebKit::WebString>&, + const WebKit::WebVector<WebKit::WebVector<WebKit::WebIDBKey> >&, + WebKit::WebExceptionCode&); virtual void deleteFunction(const WebKit::WebIDBKeyRange& key_range, WebKit::WebIDBCallbacks* callbacks, const WebKit::WebIDBTransaction& transaction, |