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

Side by Side Diff: content/child/blob_storage/webblobregistry_impl.cc

Issue 2544953002: content: Some code cleanup related to shared memory allocation. (Closed)
Patch Set: . Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/child/child_shared_bitmap_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 if (length <= limits_.max_ipc_memory_size) { 141 if (length <= limits_.max_ipc_memory_size) {
142 DataElement item; 142 DataElement item;
143 item.SetToBytes(data, length); 143 item.SetToBytes(data, length);
144 sender_->Send(new StreamHostMsg_AppendBlobDataItem(url, item)); 144 sender_->Send(new StreamHostMsg_AppendBlobDataItem(url, item));
145 } else { 145 } else {
146 // We handle larger amounts of data via SharedMemory instead of 146 // We handle larger amounts of data via SharedMemory instead of
147 // writing it directly to the IPC channel. 147 // writing it directly to the IPC channel.
148 size_t shared_memory_size = 148 size_t shared_memory_size =
149 std::min(length, limits_.max_shared_memory_size); 149 std::min(length, limits_.max_shared_memory_size);
150 std::unique_ptr<base::SharedMemory> shared_memory( 150 std::unique_ptr<base::SharedMemory> shared_memory(
151 ChildThreadImpl::AllocateSharedMemory(shared_memory_size, 151 ChildThreadImpl::AllocateSharedMemory(shared_memory_size));
152 sender_.get(), nullptr));
153 CHECK(shared_memory.get()); 152 CHECK(shared_memory.get());
154 if (!shared_memory->Map(shared_memory_size)) 153 if (!shared_memory->Map(shared_memory_size))
155 CHECK(false); 154 CHECK(false);
156 155
157 size_t remaining_bytes = length; 156 size_t remaining_bytes = length;
158 const char* current_ptr = data; 157 const char* current_ptr = data;
159 while (remaining_bytes) { 158 while (remaining_bytes) {
160 size_t chunk_size = std::min(remaining_bytes, shared_memory_size); 159 size_t chunk_size = std::min(remaining_bytes, shared_memory_size);
161 memcpy(shared_memory->memory(), current_ptr, chunk_size); 160 memcpy(shared_memory->memory(), current_ptr, chunk_size);
162 sender_->Send(new StreamHostMsg_SyncAppendSharedMemory( 161 sender_->Send(new StreamHostMsg_SyncAppendSharedMemory(
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 expected_modification_time); 233 expected_modification_time);
235 } 234 }
236 235
237 void WebBlobRegistryImpl::BuilderImpl::build() { 236 void WebBlobRegistryImpl::BuilderImpl::build() {
238 BlobTransportController::InitiateBlobTransfer( 237 BlobTransportController::InitiateBlobTransfer(
239 uuid_, content_type_, std::move(consolidation_), sender_, 238 uuid_, content_type_, std::move(consolidation_), sender_,
240 io_runner_.get(), main_runner_); 239 io_runner_.get(), main_runner_);
241 } 240 }
242 241
243 } // namespace content 242 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/child/child_shared_bitmap_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698