Chromium Code Reviews| 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" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/shared_memory.h" | 13 #include "base/memory/shared_memory.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
| 16 #include "base/numerics/safe_conversions.h" | 16 #include "base/numerics/safe_conversions.h" |
| 17 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
| 18 #include "components/display_compositor/child/child_shared_bitmap_manager.h" | |
| 18 #include "content/child/blob_storage/blob_consolidation.h" | 19 #include "content/child/blob_storage/blob_consolidation.h" |
| 19 #include "content/child/blob_storage/blob_transport_controller.h" | 20 #include "content/child/blob_storage/blob_transport_controller.h" |
| 20 #include "content/child/child_thread_impl.h" | 21 #include "content/child/child_thread_impl.h" |
| 21 #include "content/child/thread_safe_sender.h" | 22 #include "content/child/thread_safe_sender.h" |
| 22 #include "content/common/fileapi/webblob_messages.h" | 23 #include "content/common/fileapi/webblob_messages.h" |
| 23 #include "third_party/WebKit/public/platform/FilePathConversion.h" | 24 #include "third_party/WebKit/public/platform/FilePathConversion.h" |
| 24 #include "third_party/WebKit/public/platform/WebBlobData.h" | 25 #include "third_party/WebKit/public/platform/WebBlobData.h" |
| 25 #include "third_party/WebKit/public/platform/WebString.h" | 26 #include "third_party/WebKit/public/platform/WebString.h" |
| 26 #include "third_party/WebKit/public/platform/WebThreadSafeData.h" | 27 #include "third_party/WebKit/public/platform/WebThreadSafeData.h" |
| 27 #include "third_party/WebKit/public/platform/WebURL.h" | 28 #include "third_party/WebKit/public/platform/WebURL.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 if (length <= limits_.max_ipc_memory_size) { | 146 if (length <= limits_.max_ipc_memory_size) { |
| 146 DataElement item; | 147 DataElement item; |
| 147 item.SetToBytes(data, length); | 148 item.SetToBytes(data, length); |
| 148 sender_->Send(new StreamHostMsg_AppendBlobDataItem(url, item)); | 149 sender_->Send(new StreamHostMsg_AppendBlobDataItem(url, item)); |
| 149 } else { | 150 } else { |
| 150 // We handle larger amounts of data via SharedMemory instead of | 151 // We handle larger amounts of data via SharedMemory instead of |
| 151 // writing it directly to the IPC channel. | 152 // writing it directly to the IPC channel. |
| 152 size_t shared_memory_size = | 153 size_t shared_memory_size = |
| 153 std::min(length, limits_.max_shared_memory_size); | 154 std::min(length, limits_.max_shared_memory_size); |
| 154 std::unique_ptr<base::SharedMemory> shared_memory( | 155 std::unique_ptr<base::SharedMemory> shared_memory( |
| 155 ChildThreadImpl::AllocateSharedMemory(shared_memory_size)); | 156 display_compositor::ChildSharedBitmapManager::AllocateSharedMemory( |
|
danakj
2017/02/28 20:34:57
I don't think this is right, because this method h
xlai (Olivia)
2017/03/01 20:02:45
This AllocateSharedMemory is currently attached in
danakj
2017/03/03 19:21:55
I don't think either is the right final state. cc/
| |
| 157 shared_memory_size)); | |
| 156 CHECK(shared_memory.get()); | 158 CHECK(shared_memory.get()); |
| 157 if (!shared_memory->Map(shared_memory_size)) | 159 if (!shared_memory->Map(shared_memory_size)) |
| 158 CHECK(false); | 160 CHECK(false); |
| 159 | 161 |
| 160 size_t remaining_bytes = length; | 162 size_t remaining_bytes = length; |
| 161 const char* current_ptr = data; | 163 const char* current_ptr = data; |
| 162 while (remaining_bytes) { | 164 while (remaining_bytes) { |
| 163 size_t chunk_size = std::min(remaining_bytes, shared_memory_size); | 165 size_t chunk_size = std::min(remaining_bytes, shared_memory_size); |
| 164 memcpy(shared_memory->memory(), current_ptr, chunk_size); | 166 memcpy(shared_memory->memory(), current_ptr, chunk_size); |
| 165 sender_->Send(new StreamHostMsg_SyncAppendSharedMemory( | 167 sender_->Send(new StreamHostMsg_SyncAppendSharedMemory( |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 expected_modification_time); | 239 expected_modification_time); |
| 238 } | 240 } |
| 239 | 241 |
| 240 void WebBlobRegistryImpl::BuilderImpl::build() { | 242 void WebBlobRegistryImpl::BuilderImpl::build() { |
| 241 BlobTransportController::InitiateBlobTransfer( | 243 BlobTransportController::InitiateBlobTransfer( |
| 242 uuid_, content_type_, std::move(consolidation_), sender_, | 244 uuid_, content_type_, std::move(consolidation_), sender_, |
| 243 io_runner_.get(), main_runner_); | 245 io_runner_.get(), main_runner_); |
| 244 } | 246 } |
| 245 | 247 |
| 246 } // namespace content | 248 } // namespace content |
| OLD | NEW |