Index: content/common/fileapi/webblobregistry_impl.cc |
=================================================================== |
--- content/common/fileapi/webblobregistry_impl.cc (revision 171309) |
+++ content/common/fileapi/webblobregistry_impl.cc (working copy) |
@@ -5,9 +5,11 @@ |
#include "content/common/fileapi/webblobregistry_impl.h" |
#include "base/memory/ref_counted.h" |
+#include "base/message_loop.h" |
#include "base/shared_memory.h" |
#include "content/common/child_thread.h" |
#include "content/common/fileapi/webblob_messages.h" |
+#include "ipc/ipc_sync_message_filter.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebBlobData.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
@@ -27,12 +29,14 @@ |
WebBlobRegistryImpl::~WebBlobRegistryImpl() { |
} |
-void WebBlobRegistryImpl::registerBlobURL( |
- const WebURL& url, WebBlobData& data) { |
+void WebBlobRegistryImpl::registerBlobData( |
+ const WebString& uuid, const WebBlobData& data) { |
const size_t kLargeThresholdBytes = 250 * 1024; |
const size_t kMaxSharedMemoryBytes = 10 * 1024 * 1024; |
- child_thread_->Send(new BlobHostMsg_StartBuildingBlob(url)); |
+ const std::string uuid_str(uuid.utf8()); |
+ |
+ SendFromAnyThread(new BlobHostMsg_StartBuildingBlob2(uuid_str)); |
size_t i = 0; |
WebBlobData::Item data_item; |
while (data.itemAt(i++, data_item)) { |
@@ -45,7 +49,8 @@ |
break; |
if (data_item.data.size() < kLargeThresholdBytes) { |
item.SetToBytes(data_item.data.data(), data_item.data.size()); |
- child_thread_->Send(new BlobHostMsg_AppendBlobDataItem(url, item)); |
+ SendFromAnyThread( |
+ new BlobHostMsg_AppendBlobDataItem2(uuid_str, item)); |
} else { |
// We handle larger amounts of data via SharedMemory instead of |
// writing it directly to the IPC channel. |
@@ -59,8 +64,8 @@ |
while (data_size) { |
size_t chunk_size = std::min(data_size, shared_memory_size); |
memcpy(shared_memory->memory(), data_ptr, chunk_size); |
- child_thread_->Send(new BlobHostMsg_SyncAppendSharedMemory( |
- url, shared_memory->handle(), chunk_size)); |
+ SendFromAnyThread(new BlobHostMsg_AppendSharedMemory2( |
+ uuid_str, shared_memory->handle(), chunk_size)); |
data_size -= chunk_size; |
data_ptr += chunk_size; |
} |
@@ -74,45 +79,64 @@ |
static_cast<uint64>(data_item.offset), |
static_cast<uint64>(data_item.length), |
base::Time::FromDoubleT(data_item.expectedModificationTime)); |
- child_thread_->Send(new BlobHostMsg_AppendBlobDataItem(url, item)); |
+ SendFromAnyThread( |
+ new BlobHostMsg_AppendBlobDataItem2(uuid_str, item)); |
} |
break; |
case WebBlobData::Item::TypeBlob: |
if (data_item.length) { |
- item.SetToBlobUrlRange( |
- data_item.blobURL, |
+ item.SetToBlobRange( |
+ data_item.blobUUID.utf8(), |
static_cast<uint64>(data_item.offset), |
static_cast<uint64>(data_item.length)); |
- child_thread_->Send(new BlobHostMsg_AppendBlobDataItem(url, item)); |
+ SendFromAnyThread( |
+ new BlobHostMsg_AppendBlobDataItem2(uuid_str, item)); |
} |
break; |
- case WebBlobData::Item::TypeURL: |
+ case WebBlobData::Item::TypeFileSystemURL: |
if (data_item.length) { |
// We only support filesystem URL as of now. |
- DCHECK(GURL(data_item.url).SchemeIsFileSystem()); |
+ DCHECK(GURL(data_item.fileSystemURL).SchemeIsFileSystem()); |
item.SetToFileSystemUrlRange( |
- data_item.url, |
+ data_item.fileSystemURL, |
static_cast<uint64>(data_item.offset), |
static_cast<uint64>(data_item.length), |
base::Time::FromDoubleT(data_item.expectedModificationTime)); |
- child_thread_->Send(new BlobHostMsg_AppendBlobDataItem(url, item)); |
+ SendFromAnyThread( |
+ new BlobHostMsg_AppendBlobDataItem2(uuid_str, item)); |
} |
break; |
default: |
NOTREACHED(); |
} |
} |
- child_thread_->Send(new BlobHostMsg_FinishBuildingBlob( |
- url, data.contentType().utf8().data())); |
+ SendFromAnyThread(new BlobHostMsg_FinishBuildingBlob2( |
+ uuid_str, data.contentType().utf8())); |
} |
-void WebBlobRegistryImpl::registerBlobURL( |
- const WebURL& url, const WebURL& src_url) { |
- child_thread_->Send(new BlobHostMsg_CloneBlob(url, src_url)); |
+void WebBlobRegistryImpl::addBlobDataRef(const WebString& uuid) { |
+ SendFromAnyThread(new BlobHostMsg_IncrementBlobRefCount(uuid.utf8())); |
} |
-void WebBlobRegistryImpl::unregisterBlobURL(const WebURL& url) { |
- child_thread_->Send(new BlobHostMsg_RemoveBlob(url)); |
+void WebBlobRegistryImpl::removeBlobDataRef(const WebString& uuid) { |
+ SendFromAnyThread(new BlobHostMsg_DecrementBlobRefCount(uuid.utf8())); |
} |
+void WebBlobRegistryImpl::registerPublicBlobURL( |
+ const WebURL& url, const WebString& uuid) { |
+ SendFromAnyThread(new BlobHostMsg_RegisterPublicBlobURL(url, uuid.utf8())); |
+} |
+ |
+void WebBlobRegistryImpl::revokePublicBlobURL(const WebURL& url) { |
+ SendFromAnyThread(new BlobHostMsg_RevokePublicBlobURL(url)); |
+} |
+ |
+void WebBlobRegistryImpl::SendFromAnyThread(IPC::Message* msg) { |
+ ChildThread* child_thread = ChildThread::current(); |
+ if (child_thread->message_loop() == MessageLoop::current()) |
+ child_thread->Send(msg); |
+ else |
+ child_thread->sync_message_filter()->Send(msg); |
+} |
+ |
} // namespace content |