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

Unified Diff: content/child/webblobregistry_impl.cc

Issue 610333002: [WebBlobRegistry] Use char* than WebThreadSafeData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 2 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
« no previous file with comments | « content/child/webblobregistry_impl.h ('k') | content/test/mock_webblob_registry_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/webblobregistry_impl.cc
diff --git a/content/child/webblobregistry_impl.cc b/content/child/webblobregistry_impl.cc
index 5a97593afcefb4bb4d690d46a9efbc628f119b35..d22266d8375bf218901a34a807a2aaf6ab4714ad 100644
--- a/content/child/webblobregistry_impl.cc
+++ b/content/child/webblobregistry_impl.cc
@@ -164,32 +164,37 @@ void WebBlobRegistryImpl::registerStreamURL(
void WebBlobRegistryImpl::addDataToStream(const WebURL& url,
WebThreadSafeData& data) {
+ addDataToStream(url, data.data(), data.size());
+}
+
+void WebBlobRegistryImpl::addDataToStream(const WebURL& url,
+ const char* data, size_t length) {
DCHECK(ChildThread::current());
- if (data.size() == 0)
+ if (length == 0)
return;
- if (data.size() < kLargeThresholdBytes) {
+ if (length < kLargeThresholdBytes) {
storage::BlobData::Item item;
- item.SetToBytes(data.data(), data.size());
+ item.SetToBytes(data, length);
sender_->Send(new StreamHostMsg_AppendBlobDataItem(url, item));
} else {
// We handle larger amounts of data via SharedMemory instead of
// writing it directly to the IPC channel.
size_t shared_memory_size = std::min(
- data.size(), kMaxSharedMemoryBytes);
+ length, kMaxSharedMemoryBytes);
scoped_ptr<base::SharedMemory> shared_memory(
ChildThread::AllocateSharedMemory(shared_memory_size,
sender_.get()));
CHECK(shared_memory.get());
- size_t data_size = data.size();
- const char* data_ptr = data.data();
- while (data_size) {
- size_t chunk_size = std::min(data_size, shared_memory_size);
- memcpy(shared_memory->memory(), data_ptr, chunk_size);
+ size_t remaining_bytes = length;
+ const char* current_ptr = data;
+ while (remaining_bytes) {
+ size_t chunk_size = std::min(remaining_bytes, shared_memory_size);
+ memcpy(shared_memory->memory(), current_ptr, chunk_size);
sender_->Send(new StreamHostMsg_SyncAppendSharedMemory(
url, shared_memory->handle(), chunk_size));
- data_size -= chunk_size;
- data_ptr += chunk_size;
+ remaining_bytes -= chunk_size;
+ current_ptr += chunk_size;
}
}
}
« no previous file with comments | « content/child/webblobregistry_impl.h ('k') | content/test/mock_webblob_registry_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698