| Index: content/child/indexed_db/indexed_db_dispatcher.cc
|
| diff --git a/content/child/indexed_db/indexed_db_dispatcher.cc b/content/child/indexed_db/indexed_db_dispatcher.cc
|
| index a4b7666835ccd124f747b7a46fa5819db390e6a4..9f56e9fbea7bee525692c2d9bb0e2021f850d92f 100644
|
| --- a/content/child/indexed_db/indexed_db_dispatcher.cc
|
| +++ b/content/child/indexed_db/indexed_db_dispatcher.cc
|
| @@ -520,33 +520,66 @@ void IndexedDBDispatcher::OnSuccessStringList(
|
| pending_callbacks_.Remove(ipc_callbacks_id);
|
| }
|
|
|
| +static void PrepareWebValueAndBlobInfo(
|
| + const std::string& value,
|
| + const std::vector<IndexedDBMsg_BlobOrFileInfo>& blob_info,
|
| + WebData* web_value,
|
| + blink::WebVector<WebBlobInfo>* web_blob_info) {
|
| +
|
| + if (value.empty())
|
| + return;
|
| +
|
| + web_value->assign(&*value.begin(), value.size());
|
| + blink::WebVector<WebBlobInfo> local_blob_info(blob_info.size());
|
| + for (size_t i = 0; i < blob_info.size(); ++i) {
|
| + const IndexedDBMsg_BlobOrFileInfo& info = blob_info[i];
|
| + if (info.is_file) {
|
| + local_blob_info[i] = WebBlobInfo(WebString::fromUTF8(info.uuid.c_str()),
|
| + info.file_path,
|
| + info.file_name,
|
| + info.mime_type,
|
| + info.last_modified,
|
| + info.size);
|
| + } else {
|
| + local_blob_info[i] = WebBlobInfo(
|
| + WebString::fromUTF8(info.uuid.c_str()), info.mime_type, info.size);
|
| + }
|
| + }
|
| + web_blob_info->swap(local_blob_info);
|
| +}
|
| +
|
| void IndexedDBDispatcher::OnSuccessValue(
|
| - const IndexedDBMsg_CallbacksSuccessValue_Params& p) {
|
| - DCHECK_EQ(p.ipc_thread_id, CurrentWorkerId());
|
| - WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(p.ipc_callbacks_id);
|
| + const IndexedDBMsg_CallbacksSuccessValue_Params& params) {
|
| + DCHECK_EQ(params.ipc_thread_id, CurrentWorkerId());
|
| + WebIDBCallbacks* callbacks =
|
| + pending_callbacks_.Lookup(params.ipc_callbacks_id);
|
| if (!callbacks)
|
| return;
|
| WebData web_value;
|
| - if (!p.value.empty())
|
| - web_value.assign(&*p.value.begin(), p.value.size());
|
| - callbacks->onSuccess(web_value);
|
| - pending_callbacks_.Remove(p.ipc_callbacks_id);
|
| - cursor_transaction_ids_.erase(p.ipc_callbacks_id);
|
| + WebVector<WebBlobInfo> web_blob_info;
|
| + PrepareWebValueAndBlobInfo(
|
| + params.value, params.blob_or_file_info, &web_value, &web_blob_info);
|
| + callbacks->onSuccess(web_value, web_blob_info);
|
| + pending_callbacks_.Remove(params.ipc_callbacks_id);
|
| + cursor_transaction_ids_.erase(params.ipc_callbacks_id);
|
| }
|
|
|
| void IndexedDBDispatcher::OnSuccessValueWithKey(
|
| - const IndexedDBMsg_CallbacksSuccessValueWithKey_Params& p) {
|
| - DCHECK_EQ(p.ipc_thread_id, CurrentWorkerId());
|
| - WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(p.ipc_callbacks_id);
|
| + const IndexedDBMsg_CallbacksSuccessValueWithKey_Params& params) {
|
| + DCHECK_EQ(params.ipc_thread_id, CurrentWorkerId());
|
| + WebIDBCallbacks* callbacks =
|
| + pending_callbacks_.Lookup(params.ipc_callbacks_id);
|
| if (!callbacks)
|
| return;
|
| WebData web_value;
|
| - if (p.value.size())
|
| - web_value.assign(&*p.value.begin(), p.value.size());
|
| + WebVector<WebBlobInfo> web_blob_info;
|
| + PrepareWebValueAndBlobInfo(
|
| + params.value, params.blob_or_file_info, &web_value, &web_blob_info);
|
| callbacks->onSuccess(web_value,
|
| - WebIDBKeyBuilder::Build(p.primary_key),
|
| - WebIDBKeyPathBuilder::Build(p.key_path));
|
| - pending_callbacks_.Remove(p.ipc_callbacks_id);
|
| + web_blob_info,
|
| + WebIDBKeyBuilder::Build(params.primary_key),
|
| + WebIDBKeyPathBuilder::Build(params.key_path));
|
| + pending_callbacks_.Remove(params.ipc_callbacks_id);
|
| }
|
|
|
| void IndexedDBDispatcher::OnSuccessInteger(int32 ipc_thread_id,
|
| @@ -578,8 +611,9 @@ void IndexedDBDispatcher::OnSuccessOpenCursor(
|
| const IndexedDBKey& key = p.key;
|
| const IndexedDBKey& primary_key = p.primary_key;
|
| WebData web_value;
|
| - if (p.value.size())
|
| - web_value.assign(&*p.value.begin(), p.value.size());
|
| + WebVector<WebBlobInfo> web_blob_info;
|
| + PrepareWebValueAndBlobInfo(
|
| + p.value, p.blob_or_file_info, &web_value, &web_blob_info);
|
|
|
| DCHECK(cursor_transaction_ids_.find(ipc_callbacks_id) !=
|
| cursor_transaction_ids_.end());
|
| @@ -593,8 +627,11 @@ void IndexedDBDispatcher::OnSuccessOpenCursor(
|
| WebIDBCursorImpl* cursor = new WebIDBCursorImpl(
|
| ipc_object_id, transaction_id, thread_safe_sender_.get());
|
| cursors_[ipc_object_id] = cursor;
|
| - callbacks->onSuccess(cursor, WebIDBKeyBuilder::Build(key),
|
| - WebIDBKeyBuilder::Build(primary_key), web_value);
|
| + callbacks->onSuccess(cursor,
|
| + WebIDBKeyBuilder::Build(key),
|
| + WebIDBKeyBuilder::Build(primary_key),
|
| + web_value,
|
| + web_blob_info);
|
|
|
| pending_callbacks_.Remove(ipc_callbacks_id);
|
| }
|
| @@ -616,10 +653,13 @@ void IndexedDBDispatcher::OnSuccessCursorContinue(
|
| return;
|
|
|
| WebData web_value;
|
| - if (value.size())
|
| - web_value.assign(&*value.begin(), value.size());
|
| + WebVector<WebBlobInfo> web_blob_info;
|
| + PrepareWebValueAndBlobInfo(
|
| + value, p.blob_or_file_info, &web_value, &web_blob_info);
|
| callbacks->onSuccess(WebIDBKeyBuilder::Build(key),
|
| - WebIDBKeyBuilder::Build(primary_key), web_value);
|
| + WebIDBKeyBuilder::Build(primary_key),
|
| + web_value,
|
| + web_blob_info);
|
|
|
| pending_callbacks_.Remove(ipc_callbacks_id);
|
| }
|
| @@ -632,13 +672,15 @@ void IndexedDBDispatcher::OnSuccessCursorPrefetch(
|
| const std::vector<IndexedDBKey>& keys = p.keys;
|
| const std::vector<IndexedDBKey>& primary_keys = p.primary_keys;
|
| std::vector<WebData> values(p.values.size());
|
| + DCHECK_EQ(p.values.size(), p.blob_or_file_infos.size());
|
| + std::vector<WebVector<WebBlobInfo> > blob_infos(p.blob_or_file_infos.size());
|
| for (size_t i = 0; i < p.values.size(); ++i) {
|
| - if (p.values[i].size())
|
| - values[i].assign(&*p.values[i].begin(), p.values[i].size());
|
| + PrepareWebValueAndBlobInfo(
|
| + p.values[i], p.blob_or_file_infos[i], &values[i], &blob_infos[i]);
|
| }
|
| WebIDBCursorImpl* cursor = cursors_[ipc_cursor_id];
|
| DCHECK(cursor);
|
| - cursor->SetPrefetchData(keys, primary_keys, values);
|
| + cursor->SetPrefetchData(keys, primary_keys, values, blob_infos);
|
|
|
| WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id);
|
| DCHECK(callbacks);
|
|
|