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

Unified Diff: content/child/webblobregistry_impl.cc

Issue 15817013: Add Stream support to WebBlobRegistry and FileAPIMessageFilter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Resolve Created 7 years, 5 months 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/webblobregistry_impl.cc
diff --git a/content/child/webblobregistry_impl.cc b/content/child/webblobregistry_impl.cc
index fc5cfab18e33ff083ed1af0839b7be7ea33dab10..cea524c2b0b559db7806efa7dea505ab4efd3bfc 100644
--- a/content/child/webblobregistry_impl.cc
+++ b/content/child/webblobregistry_impl.cc
@@ -32,16 +32,16 @@ WebBlobRegistryImpl::~WebBlobRegistryImpl() {
}
void WebBlobRegistryImpl::SendData(const WebURL& url,
- const WebThreadSafeData& data,
- webkit_blob::BlobData::Item* item) {
+ const WebThreadSafeData& data) {
const size_t kLargeThresholdBytes = 250 * 1024;
const size_t kMaxSharedMemoryBytes = 10 * 1024 * 1024;
if (data.size() == 0)
return;
if (data.size() < kLargeThresholdBytes) {
- item->SetToBytes(data.data(), data.size());
- sender_->Send(new BlobHostMsg_AppendBlobDataItem(url, *item));
+ webkit_blob::BlobData::Item item;
+ item.SetToBytes(data.data(), data.size());
+ sender_->Send(new BlobHostMsg_AppendBlobDataItemToBlobOrStream(url, item));
} else {
// We handle larger amounts of data via SharedMemory instead of
// writing it directly to the IPC channel.
@@ -56,7 +56,7 @@ void WebBlobRegistryImpl::SendData(const WebURL& url,
while (data_size) {
size_t chunk_size = std::min(data_size, shared_memory_size);
memcpy(shared_memory->memory(), data_ptr, chunk_size);
- sender_->Send(new BlobHostMsg_SyncAppendSharedMemory(
+ sender_->Send(new BlobHostMsg_SyncAppendSharedMemoryToBlobOrStream(
url, shared_memory->handle(), chunk_size));
data_size -= chunk_size;
data_ptr += chunk_size;
@@ -72,43 +72,48 @@ void WebBlobRegistryImpl::registerBlobURL(
size_t i = 0;
WebBlobData::Item data_item;
while (data.itemAt(i++, data_item)) {
- webkit_blob::BlobData::Item item;
switch (data_item.type) {
case WebBlobData::Item::TypeData: {
// WebBlobData does not allow partial data items.
DCHECK(!data_item.offset && data_item.length == -1);
- SendData(url, data_item.data, &item);
+ SendData(url, data_item.data);
break;
}
case WebBlobData::Item::TypeFile:
if (data_item.length) {
+ webkit_blob::BlobData::Item item;
item.SetToFilePathRange(
base::FilePath::FromUTF16Unsafe(data_item.filePath),
static_cast<uint64>(data_item.offset),
static_cast<uint64>(data_item.length),
base::Time::FromDoubleT(data_item.expectedModificationTime));
- sender_->Send(new BlobHostMsg_AppendBlobDataItem(url, item));
+ sender_->Send(
+ new BlobHostMsg_AppendBlobDataItemToBlobOrStream(url, item));
}
break;
case WebBlobData::Item::TypeBlob:
if (data_item.length) {
+ webkit_blob::BlobData::Item item;
item.SetToBlobUrlRange(
data_item.blobURL,
static_cast<uint64>(data_item.offset),
static_cast<uint64>(data_item.length));
- sender_->Send(new BlobHostMsg_AppendBlobDataItem(url, item));
+ sender_->Send(
+ new BlobHostMsg_AppendBlobDataItemToBlobOrStream(url, item));
}
break;
case WebBlobData::Item::TypeURL:
if (data_item.length) {
// We only support filesystem URL as of now.
DCHECK(GURL(data_item.url).SchemeIsFileSystem());
+ webkit_blob::BlobData::Item item;
item.SetToFileSystemUrlRange(
data_item.url,
static_cast<uint64>(data_item.offset),
static_cast<uint64>(data_item.length),
base::Time::FromDoubleT(data_item.expectedModificationTime));
- sender_->Send(new BlobHostMsg_AppendBlobDataItem(url, item));
+ sender_->Send(
+ new BlobHostMsg_AppendBlobDataItemToBlobOrStream(url, item));
}
break;
default:
@@ -119,17 +124,37 @@ void WebBlobRegistryImpl::registerBlobURL(
url, data.contentType().utf8().data()));
}
+void WebBlobRegistryImpl::registerStreamURL(
+ const WebURL& url, const WebString& content_type) {
+ DCHECK(ChildThread::current()->message_loop() ==
jam 2013/07/23 15:52:36 nit: here and in the rest of the file, ChildThread
tyoshino (SeeGerritForStatus) 2013/07/24 12:14:20 oh. Done.
+ base::MessageLoop::current());
+ sender_->Send(new BlobHostMsg_StartBuildingStream(url, content_type.utf8()));
+}
+
void WebBlobRegistryImpl::registerBlobURL(
const WebURL& url, const WebURL& src_url) {
DCHECK(ChildThread::current()->message_loop() ==
base::MessageLoop::current());
- sender_->Send(new BlobHostMsg_CloneBlob(url, src_url));
+ sender_->Send(new BlobHostMsg_CloneBlobOrStream(url, src_url));
+}
+
+void WebBlobRegistryImpl::addDataToStream(const WebKit::WebURL& url,
+ WebKit::WebThreadSafeData& data) {
+ DCHECK(ChildThread::current()->message_loop() ==
+ base::MessageLoop::current());
+ SendData(url, data);
+}
+
+void WebBlobRegistryImpl::finalizeStream(const WebURL& url) {
+ DCHECK(ChildThread::current()->message_loop() ==
+ base::MessageLoop::current());
+ sender_->Send(new BlobHostMsg_FinishBuildingStream(url));
}
void WebBlobRegistryImpl::unregisterBlobURL(const WebURL& url) {
DCHECK(ChildThread::current()->message_loop() ==
base::MessageLoop::current());
- sender_->Send(new BlobHostMsg_RemoveBlob(url));
+ sender_->Send(new BlobHostMsg_RemoveBlobOrStream(url));
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698