Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1155)

Unified Diff: content/child/indexed_db/indexed_db_dispatcher.cc

Issue 18023022: Blob support for IDB [Chromium] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Handle the rest of Josh's feedback. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 2b97b4a8b2f6e1e062ff55bc96eb8a0e52231c50..a7c7a5b399be8244220b7349150f8b35c307c9ea 100644
--- a/content/child/indexed_db/indexed_db_dispatcher.cc
+++ b/content/child/indexed_db/indexed_db_dispatcher.cc
@@ -19,6 +19,7 @@
#include "third_party/WebKit/public/platform/WebIDBDatabaseError.h"
#include "third_party/WebKit/public/platform/WebIDBDatabaseException.h"
+using blink::WebBlobInfo;
using blink::WebData;
using blink::WebIDBCallbacks;
using blink::WebIDBDatabase;
@@ -322,6 +323,7 @@ void IndexedDBDispatcher::RequestIDBDatabasePut(
int64 transaction_id,
int64 object_store_id,
const WebData& value,
+ const blink::WebVector<WebBlobInfo>& webBlobInfo,
const IndexedDBKey& key,
WebIDBDatabase::PutMode put_mode,
WebIDBCallbacks* callbacks,
@@ -363,6 +365,22 @@ void IndexedDBDispatcher::RequestIDBDatabasePut(
IndexedDBKey(IndexedDBKeyBuilder::Build(index_keys[i][j]));
}
}
+
+ params.blob_or_file_info.resize(webBlobInfo.size());
+ for (size_t i = 0; i < webBlobInfo.size(); ++i) {
+ const WebBlobInfo& info = webBlobInfo[i];
+ params.blob_or_file_info[i].is_file = info.isFile();
+ if (info.isFile()) {
+ params.blob_or_file_info[i].file_path = info.filePath();
+ params.blob_or_file_info[i].file_name = info.fileName();
+ } else {
+ params.blob_or_file_info[i].size = info.size();
+ }
+ params.blob_or_file_info[i].uuid = info.uuid().latin1();
+ DCHECK(params.blob_or_file_info[i].uuid.size());
+ params.blob_or_file_info[i].mime_type = info.type();
+ }
+
Send(new IndexedDBHostMsg_DatabasePut(params));
}
@@ -496,37 +514,64 @@ void IndexedDBDispatcher::OnSuccessStringList(
pending_callbacks_.Remove(ipc_callbacks_id);
}
-void IndexedDBDispatcher::OnSuccessValue(int32 ipc_thread_id,
- int32 ipc_callbacks_id,
- const std::string& value) {
- DCHECK_EQ(ipc_thread_id, CurrentWorkerId());
- WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id);
+static void LoadBlobInfo(
+ WebData* web_value,
+ const std::string& value,
+ const std::vector<IndexedDBMsg_BlobOrFileInfo>& blob_info,
+ blink::WebVector<WebBlobInfo>* web_blob_info) {
+
+ if (value.size()) {
+ 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& params) {
+ DCHECK_EQ(params.ipc_thread_id, CurrentWorkerId());
+ WebIDBCallbacks* callbacks =
+ pending_callbacks_.Lookup(params.ipc_callbacks_id);
if (!callbacks)
return;
WebData web_value;
- if (value.size())
- web_value.assign(&*value.begin(), value.size());
- callbacks->onSuccess(web_value);
- pending_callbacks_.Remove(ipc_callbacks_id);
+ WebVector<WebBlobInfo> web_blob_info;
+ LoadBlobInfo(
jsbell 2013/12/20 00:44:20 Is there a good reason to have LoadBlobInfo do the
ericu 2014/02/20 00:50:29 Yeah, it started out just doing the blob info, and
+ &web_value, params.value, params.blob_or_file_info, &web_blob_info);
+ callbacks->onSuccess(web_value, web_blob_info);
+ pending_callbacks_.Remove(params.ipc_callbacks_id);
}
void IndexedDBDispatcher::OnSuccessValueWithKey(
- int32 ipc_thread_id,
- int32 ipc_callbacks_id,
- const std::string& value,
- const IndexedDBKey& primary_key,
- const IndexedDBKeyPath& key_path) {
- DCHECK_EQ(ipc_thread_id, CurrentWorkerId());
- WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(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 (value.size())
- web_value.assign(&*value.begin(), value.size());
+ WebVector<WebBlobInfo> web_blob_info;
+ LoadBlobInfo(
+ &web_value, params.value, params.blob_or_file_info, &web_blob_info);
callbacks->onSuccess(web_value,
- WebIDBKeyBuilder::Build(primary_key),
- WebIDBKeyPathBuilder::Build(key_path));
- pending_callbacks_.Remove(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,
@@ -558,8 +603,8 @@ 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;
+ LoadBlobInfo(&web_value, p.value, p.blob_or_file_info, &web_blob_info);
WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id);
if (!callbacks)
@@ -568,8 +613,11 @@ void IndexedDBDispatcher::OnSuccessOpenCursor(
RendererWebIDBCursorImpl* cursor =
new RendererWebIDBCursorImpl(ipc_object_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);
}
@@ -591,10 +639,12 @@ void IndexedDBDispatcher::OnSuccessCursorContinue(
return;
WebData web_value;
- if (value.size())
- web_value.assign(&*value.begin(), value.size());
+ WebVector<WebBlobInfo> web_blob_info;
+ LoadBlobInfo(&web_value, value, p.blob_or_file_info, &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);
}
@@ -607,13 +657,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());
+ LoadBlobInfo(
+ &values[i], p.values[i], p.blob_or_file_infos[i], &blob_infos[i]);
}
RendererWebIDBCursorImpl* 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);

Powered by Google App Engine
This is Rietveld 408576698