| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/child/blob_storage/webblobregistry_impl.h" | 5 #include "content/child/blob_storage/webblobregistry_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/guid.h" | 9 #include "base/guid.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 DataElement item; | 143 DataElement item; |
| 144 item.SetToBytes(data, length); | 144 item.SetToBytes(data, length); |
| 145 sender_->Send(new StreamHostMsg_AppendBlobDataItem(url, item)); | 145 sender_->Send(new StreamHostMsg_AppendBlobDataItem(url, item)); |
| 146 } else { | 146 } else { |
| 147 // We handle larger amounts of data via SharedMemory instead of | 147 // We handle larger amounts of data via SharedMemory instead of |
| 148 // writing it directly to the IPC channel. | 148 // writing it directly to the IPC channel. |
| 149 size_t shared_memory_size = | 149 size_t shared_memory_size = |
| 150 std::min(length, storage::kBlobStorageMaxSharedMemoryBytes); | 150 std::min(length, storage::kBlobStorageMaxSharedMemoryBytes); |
| 151 std::unique_ptr<base::SharedMemory> shared_memory( | 151 std::unique_ptr<base::SharedMemory> shared_memory( |
| 152 ChildThreadImpl::AllocateSharedMemory(shared_memory_size, | 152 ChildThreadImpl::AllocateSharedMemory(shared_memory_size, |
| 153 sender_.get())); | 153 sender_.get(), nullptr)); |
| 154 CHECK(shared_memory.get()); | 154 CHECK(shared_memory.get()); |
| 155 if (!shared_memory->Map(shared_memory_size)) | 155 if (!shared_memory->Map(shared_memory_size)) |
| 156 CHECK(false); | 156 CHECK(false); |
| 157 | 157 |
| 158 size_t remaining_bytes = length; | 158 size_t remaining_bytes = length; |
| 159 const char* current_ptr = data; | 159 const char* current_ptr = data; |
| 160 while (remaining_bytes) { | 160 while (remaining_bytes) { |
| 161 size_t chunk_size = std::min(remaining_bytes, shared_memory_size); | 161 size_t chunk_size = std::min(remaining_bytes, shared_memory_size); |
| 162 memcpy(shared_memory->memory(), current_ptr, chunk_size); | 162 memcpy(shared_memory->memory(), current_ptr, chunk_size); |
| 163 sender_->Send(new StreamHostMsg_SyncAppendSharedMemory( | 163 sender_->Send(new StreamHostMsg_SyncAppendSharedMemory( |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 expected_modification_time); | 235 expected_modification_time); |
| 236 } | 236 } |
| 237 | 237 |
| 238 void WebBlobRegistryImpl::BuilderImpl::build() { | 238 void WebBlobRegistryImpl::BuilderImpl::build() { |
| 239 BlobTransportController::InitiateBlobTransfer( | 239 BlobTransportController::InitiateBlobTransfer( |
| 240 uuid_, content_type_, std::move(consolidation_), sender_, | 240 uuid_, content_type_, std::move(consolidation_), sender_, |
| 241 io_runner_.get(), main_runner_); | 241 io_runner_.get(), main_runner_); |
| 242 } | 242 } |
| 243 | 243 |
| 244 } // namespace content | 244 } // namespace content |
| OLD | NEW |