diff options
author | alecflett@chromium.org <alecflett@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-14 05:14:41 +0000 |
---|---|---|
committer | alecflett@chromium.org <alecflett@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-14 05:14:41 +0000 |
commit | 037ae84b5eb6e80715b5f9e261dcf44a4fd346dd (patch) | |
tree | 228108afa38c1cff93ff59e00f5203752b722073 /content | |
parent | 09f7812bd45aecee8785621e45a40852e273e9d1 (diff) | |
download | chromium_src-037ae84b5eb6e80715b5f9e261dcf44a4fd346dd.zip chromium_src-037ae84b5eb6e80715b5f9e261dcf44a4fd346dd.tar.gz chromium_src-037ae84b5eb6e80715b5f9e261dcf44a4fd346dd.tar.bz2 |
Proxy WebData-based WebIDBDatabase::put
BUG=
Review URL: https://chromiumcodereview.appspot.com/12217049
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182392 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
8 files changed, 149 insertions, 14 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 b5dd4c4..4933986 100644 --- a/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc +++ b/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc @@ -21,6 +21,7 @@ #include "content/public/common/content_switches.h" #include "content/public/common/result_codes.h" #include "googleurl/src/gurl.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebData.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMStringList.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h" @@ -36,6 +37,7 @@ using webkit_database::DatabaseUtil; using WebKit::WebDOMStringList; +using WebKit::WebData; using WebKit::WebExceptionCode; using WebKit::WebIDBCallbacks; using WebKit::WebIDBCursor; @@ -346,6 +348,7 @@ bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived( IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGet, OnGet) + IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePutOld, OnPutOld) IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePut, OnPut) IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexKeys, OnSetIndexKeys) @@ -464,8 +467,8 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnGet( params.key_range, params.key_only, callbacks.release()); } -void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPut( - const IndexedDBHostMsg_DatabasePut_Params& params) { +void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPutOld( + const IndexedDBHostMsg_DatabasePutOld_Params& params) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); WebIDBDatabase* database = parent_->GetOrTerminateProcess( @@ -497,6 +500,35 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPut( (*map)[host_transaction_id] += params.value.size(); } +void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPut( + const IndexedDBHostMsg_DatabasePut_Params& params) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); + + WebIDBDatabase* database = parent_->GetOrTerminateProcess( + &map_, params.ipc_database_id); + if (!database) + return; + scoped_ptr<WebIDBCallbacks> callbacks( + new IndexedDBCallbacks<WebIDBKey>(parent_, params.ipc_thread_id, + params.ipc_response_id)); + // Be careful with empty vectors. + WebData value; + if (params.value.size()) + value.assign(¶ms.value.front(), params.value.size()); + int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); + database->put(host_transaction_id, + params.object_store_id, + value, params.key, + params.put_mode, callbacks.release(), + params.index_ids, + params.index_keys); + TransactionIDToSizeMap* map = + &parent_->database_dispatcher_host_->transaction_size_map_; + // Size can't be big enough to overflow because it represents the + // actual bytes passed through IPC. + (*map)[host_transaction_id] += params.value.size(); +} + void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexKeys( const IndexedDBHostMsg_DatabaseSetIndexKeys_Params& params) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 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 1ed7771..ef6c478 100644 --- a/content/browser/in_process_webkit/indexed_db_dispatcher_host.h +++ b/content/browser/in_process_webkit/indexed_db_dispatcher_host.h @@ -23,17 +23,12 @@ struct IndexedDBHostMsg_DatabaseCreateTransaction_Params; struct IndexedDBHostMsg_DatabaseDeleteRange_Params; struct IndexedDBHostMsg_DatabaseGet_Params; struct IndexedDBHostMsg_DatabaseOpenCursor_Params; +struct IndexedDBHostMsg_DatabasePutOld_Params; struct IndexedDBHostMsg_DatabasePut_Params; struct IndexedDBHostMsg_DatabaseSetIndexKeys_Params; struct IndexedDBHostMsg_FactoryDeleteDatabase_Params; struct IndexedDBHostMsg_FactoryGetDatabaseNames_Params; struct IndexedDBHostMsg_FactoryOpen_Params; -struct IndexedDBHostMsg_IndexCount_Params; -struct IndexedDBHostMsg_IndexOpenCursor_Params; -struct IndexedDBHostMsg_ObjectStoreCount_Params; -struct IndexedDBHostMsg_ObjectStoreCreateIndex_Params; -struct IndexedDBHostMsg_ObjectStoreOpenCursor_Params; -struct IndexedDBHostMsg_ObjectStorePut_Params; namespace WebKit { class WebIDBCursor; @@ -136,6 +131,7 @@ class IndexedDBDispatcherHost : public BrowserMessageFilter { void OnDestroyed(int32 ipc_database_id); void OnGet(const IndexedDBHostMsg_DatabaseGet_Params& params); + void OnPutOld(const IndexedDBHostMsg_DatabasePutOld_Params& params); void OnPut(const IndexedDBHostMsg_DatabasePut_Params& params); void OnSetIndexKeys( const IndexedDBHostMsg_DatabaseSetIndexKeys_Params& params); diff --git a/content/common/indexed_db/indexed_db_dispatcher.cc b/content/common/indexed_db/indexed_db_dispatcher.cc index 67c85b8..d3231e7 100644 --- a/content/common/indexed_db/indexed_db_dispatcher.cc +++ b/content/common/indexed_db/indexed_db_dispatcher.cc @@ -18,6 +18,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyRange.h" using WebKit::WebDOMStringList; +using WebKit::WebData; using WebKit::WebExceptionCode; using WebKit::WebFrame; using WebKit::WebIDBCallbacks; @@ -387,7 +388,7 @@ void IndexedDBDispatcher::RequestIDBDatabaseGet( } -void IndexedDBDispatcher::RequestIDBDatabasePut( +void IndexedDBDispatcher::RequestIDBDatabasePutOld( int32 ipc_database_id, int64 transaction_id, int64 object_store_id, @@ -399,7 +400,7 @@ void IndexedDBDispatcher::RequestIDBDatabasePut( const WebKit::WebVector<WebKit::WebVector< WebKit::WebIDBKey> >& index_keys) { ResetCursorPrefetchCaches(); - IndexedDBHostMsg_DatabasePut_Params params; + IndexedDBHostMsg_DatabasePutOld_Params params; init_params(params, callbacks); params.ipc_database_id = ipc_database_id; params.transaction_id = transaction_id; @@ -422,6 +423,43 @@ void IndexedDBDispatcher::RequestIDBDatabasePut( params.index_keys[i][j] = IndexedDBKey(index_keys[i][j]); } } + Send(new IndexedDBHostMsg_DatabasePutOld(params)); +} + +void IndexedDBDispatcher::RequestIDBDatabasePut( + int32 ipc_database_id, + int64 transaction_id, + int64 object_store_id, + const WebData& value, + const IndexedDBKey& key, + WebIDBDatabase::PutMode put_mode, + WebIDBCallbacks* callbacks, + const WebVector<long long>& index_ids, + const WebVector<WebKit::WebVector< + WebIDBKey> >& index_keys) { + ResetCursorPrefetchCaches(); + IndexedDBHostMsg_DatabasePut_Params params; + init_params(params, callbacks); + params.ipc_database_id = ipc_database_id; + params.transaction_id = transaction_id; + params.object_store_id = object_store_id; + + params.value.assign(value.data(), value.data() + value.size()); + params.key = key; + params.put_mode = put_mode; + + COMPILE_ASSERT(sizeof(params.index_ids[0]) == + sizeof(index_ids[0]), Cant_copy); + params.index_ids.assign(index_ids.data(), + index_ids.data() + index_ids.size()); + + 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] = IndexedDBKey(index_keys[i][j]); + } + } Send(new IndexedDBHostMsg_DatabasePut(params)); } diff --git a/content/common/indexed_db/indexed_db_dispatcher.h b/content/common/indexed_db/indexed_db_dispatcher.h index 9651930..7fa5dab 100644 --- a/content/common/indexed_db/indexed_db_dispatcher.h +++ b/content/common/indexed_db/indexed_db_dispatcher.h @@ -134,7 +134,7 @@ class CONTENT_EXPORT IndexedDBDispatcher bool key_only, WebKit::WebIDBCallbacks* callbacks); - void RequestIDBDatabasePut( + void RequestIDBDatabasePutOld( int32 ipc_database_id, int64 transaction_id, int64 object_store_id, @@ -146,6 +146,18 @@ class CONTENT_EXPORT IndexedDBDispatcher const WebKit::WebVector<WebKit::WebVector< WebKit::WebIDBKey> >& index_keys); + void RequestIDBDatabasePut( + int32 ipc_database_id, + int64 transaction_id, + int64 object_store_id, + const WebKit::WebData& value, + const IndexedDBKey& key, + WebKit::WebIDBDatabase::PutMode put_mode, + WebKit::WebIDBCallbacks* callbacks, + const WebKit::WebVector<long long>& index_ids, + const WebKit::WebVector<WebKit::WebVector< + WebKit::WebIDBKey> >& index_keys); + void RequestIDBDatabaseOpenCursor( int32 ipc_database_id, int64 transaction_id, diff --git a/content/common/indexed_db/indexed_db_dispatcher_unittest.cc b/content/common/indexed_db/indexed_db_dispatcher_unittest.cc index 0e193f8..f8d8008 100644 --- a/content/common/indexed_db/indexed_db_dispatcher_unittest.cc +++ b/content/common/indexed_db/indexed_db_dispatcher_unittest.cc @@ -8,6 +8,7 @@ #include "content/common/indexed_db/indexed_db_key.h" #include "content/public/common/serialized_script_value.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebData.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebExceptionCode.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h" @@ -21,7 +22,7 @@ namespace content { TEST(IndexedDBDispatcherTest, DISABLED_ValueSizeTest) { string16 data; data.resize(kMaxIDBValueSizeInBytes / sizeof(char16) + 1, 'x'); - WebKit::WebVector<unsigned char> value; + const WebKit::WebData value; const int32 ipc_dummy_id = -1; const int64 transaction_id = 1; const int64 object_store_id = 2; @@ -34,7 +35,7 @@ TEST(IndexedDBDispatcherTest, DISABLED_ValueSizeTest) { ipc_dummy_id, transaction_id, object_store_id, - &value, + value, key, WebKit::WebIDBDatabase::AddOrUpdate, static_cast<WebKit::WebIDBCallbacks*>(NULL), diff --git a/content/common/indexed_db/indexed_db_messages.h b/content/common/indexed_db/indexed_db_messages.h index 16b4d51..c490d3a 100644 --- a/content/common/indexed_db/indexed_db_messages.h +++ b/content/common/indexed_db/indexed_db_messages.h @@ -113,6 +113,33 @@ IPC_STRUCT_BEGIN(IndexedDBHostMsg_DatabaseGet_Params) IPC_STRUCT_END() // Used to set a value in an object store. +IPC_STRUCT_BEGIN(IndexedDBHostMsg_DatabasePutOld_Params) + // The id any response should contain. + IPC_STRUCT_MEMBER(int32, ipc_thread_id) + IPC_STRUCT_MEMBER(int32, ipc_response_id) + // The database the object store belongs to. + IPC_STRUCT_MEMBER(int32, ipc_database_id) + // The transaction it's associated with. + IPC_STRUCT_MEMBER(int64, transaction_id) + // The object store's id. + IPC_STRUCT_MEMBER(int64, object_store_id) + // The index's id. + IPC_STRUCT_MEMBER(int64, index_id) + // The value to set. + IPC_STRUCT_MEMBER(std::vector<char>, value) + // The key to set it on (may not be "valid"/set in some cases). + IPC_STRUCT_MEMBER(content::IndexedDBKey, key) + // Whether this is an add or a put. + IPC_STRUCT_MEMBER(WebKit::WebIDBDatabase::PutMode, put_mode) + // The names of the indexes used below. + IPC_STRUCT_MEMBER(std::vector<int64>, index_ids) + // 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) +IPC_STRUCT_END() + +// Used to set a value in an object store. IPC_STRUCT_BEGIN(IndexedDBHostMsg_DatabasePut_Params) // The id any response should contain. IPC_STRUCT_MEMBER(int32, ipc_thread_id) @@ -126,7 +153,7 @@ IPC_STRUCT_BEGIN(IndexedDBHostMsg_DatabasePut_Params) // The index's id. IPC_STRUCT_MEMBER(int64, index_id) // The value to set. - IPC_STRUCT_MEMBER(std::vector<uint8>, value) + IPC_STRUCT_MEMBER(std::vector<char>, value) // The key to set it on (may not be "valid"/set in some cases). IPC_STRUCT_MEMBER(content::IndexedDBKey, key) // Whether this is an add or a put. @@ -450,6 +477,10 @@ IPC_MESSAGE_CONTROL1(IndexedDBHostMsg_DatabaseGet, IndexedDBHostMsg_DatabaseGet_Params) // WebIDBDatabase::put() message. +IPC_MESSAGE_CONTROL1(IndexedDBHostMsg_DatabasePutOld, + IndexedDBHostMsg_DatabasePutOld_Params) + +// WebIDBDatabase::put() message. IPC_MESSAGE_CONTROL1(IndexedDBHostMsg_DatabasePut, IndexedDBHostMsg_DatabasePut_Params) diff --git a/content/common/indexed_db/proxy_webidbdatabase_impl.cc b/content/common/indexed_db/proxy_webidbdatabase_impl.cc index bde27a8..d9074dc 100644 --- a/content/common/indexed_db/proxy_webidbdatabase_impl.cc +++ b/content/common/indexed_db/proxy_webidbdatabase_impl.cc @@ -118,6 +118,23 @@ void RendererWebIDBDatabaseImpl::put( const WebVector<WebIndexKeys>& web_index_keys) { IndexedDBDispatcher* dispatcher = IndexedDBDispatcher::ThreadSpecificInstance(); + dispatcher->RequestIDBDatabasePutOld( + ipc_database_id_, transaction_id, object_store_id, + value, IndexedDBKey(key), put_mode, callbacks, + web_index_ids, web_index_keys); +} + +void RendererWebIDBDatabaseImpl::put( + long long transaction_id, + long long object_store_id, + const WebKit::WebData& value, + const WebKit::WebIDBKey& key, + PutMode put_mode, + WebIDBCallbacks* callbacks, + const WebVector<long long>& web_index_ids, + const WebVector<WebIndexKeys>& web_index_keys) { + IndexedDBDispatcher* dispatcher = + IndexedDBDispatcher::ThreadSpecificInstance(); dispatcher->RequestIDBDatabasePut( ipc_database_id_, transaction_id, object_store_id, value, IndexedDBKey(key), put_mode, callbacks, diff --git a/content/common/indexed_db/proxy_webidbdatabase_impl.h b/content/common/indexed_db/proxy_webidbdatabase_impl.h index 06834c7..61bebe1 100644 --- a/content/common/indexed_db/proxy_webidbdatabase_impl.h +++ b/content/common/indexed_db/proxy_webidbdatabase_impl.h @@ -51,6 +51,14 @@ class RendererWebIDBDatabaseImpl : public WebKit::WebIDBDatabase { WebKit::WebIDBCallbacks*, const WebKit::WebVector<long long>& indexIds, const WebKit::WebVector<WebIndexKeys>&); + virtual void put(long long transactionId, + long long objectStoreId, + const WebKit::WebData& value, + const WebKit::WebIDBKey&, + PutMode, + WebKit::WebIDBCallbacks*, + const WebKit::WebVector<long long>& indexIds, + const WebKit::WebVector<WebIndexKeys>&); virtual void setIndexKeys(long long transactionId, long long objectStoreId, const WebKit::WebIDBKey&, |