| 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/webblobregistry_impl.h" | 5 #include "content/child/webblobregistry_impl.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/guid.h" | 8 #include "base/guid.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/shared_memory.h" | 11 #include "base/memory/shared_memory.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/numerics/safe_conversions.h" |
| 13 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 14 #include "content/child/child_thread_impl.h" | 15 #include "content/child/child_thread_impl.h" |
| 15 #include "content/child/thread_safe_sender.h" | 16 #include "content/child/thread_safe_sender.h" |
| 16 #include "content/common/fileapi/webblob_messages.h" | 17 #include "content/common/fileapi/webblob_messages.h" |
| 17 #include "third_party/WebKit/public/platform/WebBlobData.h" | 18 #include "third_party/WebKit/public/platform/WebBlobData.h" |
| 18 #include "third_party/WebKit/public/platform/WebString.h" | 19 #include "third_party/WebKit/public/platform/WebString.h" |
| 19 #include "third_party/WebKit/public/platform/WebThreadSafeData.h" | 20 #include "third_party/WebKit/public/platform/WebThreadSafeData.h" |
| 20 #include "third_party/WebKit/public/platform/WebURL.h" | 21 #include "third_party/WebKit/public/platform/WebURL.h" |
| 21 | 22 |
| 22 using blink::WebBlobData; | 23 using blink::WebBlobData; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 CHECK(shared_memory.get()); | 148 CHECK(shared_memory.get()); |
| 148 if (!shared_memory->Map(shared_memory_size)) | 149 if (!shared_memory->Map(shared_memory_size)) |
| 149 CHECK(false); | 150 CHECK(false); |
| 150 | 151 |
| 151 size_t remaining_bytes = length; | 152 size_t remaining_bytes = length; |
| 152 const char* current_ptr = data; | 153 const char* current_ptr = data; |
| 153 while (remaining_bytes) { | 154 while (remaining_bytes) { |
| 154 size_t chunk_size = std::min(remaining_bytes, shared_memory_size); | 155 size_t chunk_size = std::min(remaining_bytes, shared_memory_size); |
| 155 memcpy(shared_memory->memory(), current_ptr, chunk_size); | 156 memcpy(shared_memory->memory(), current_ptr, chunk_size); |
| 156 sender_->Send(new StreamHostMsg_SyncAppendSharedMemory( | 157 sender_->Send(new StreamHostMsg_SyncAppendSharedMemory( |
| 157 url, shared_memory->handle(), chunk_size)); | 158 url, shared_memory->handle(), |
| 159 base::checked_cast<uint32_t>(chunk_size))); |
| 158 remaining_bytes -= chunk_size; | 160 remaining_bytes -= chunk_size; |
| 159 current_ptr += chunk_size; | 161 current_ptr += chunk_size; |
| 160 } | 162 } |
| 161 } | 163 } |
| 162 } | 164 } |
| 163 | 165 |
| 164 void WebBlobRegistryImpl::flushStream(const WebURL& url) { | 166 void WebBlobRegistryImpl::flushStream(const WebURL& url) { |
| 165 DCHECK(ChildThreadImpl::current()); | 167 DCHECK(ChildThreadImpl::current()); |
| 166 sender_->Send(new StreamHostMsg_Flush(url)); | 168 sender_->Send(new StreamHostMsg_Flush(url)); |
| 167 } | 169 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 consolidation_.ReadMemory(consolidated_item_index, offset, chunk_size, | 302 consolidation_.ReadMemory(consolidated_item_index, offset, chunk_size, |
| 301 shared_memory->memory()); | 303 shared_memory->memory()); |
| 302 sender_->Send(new BlobHostMsg_SyncAppendSharedMemory( | 304 sender_->Send(new BlobHostMsg_SyncAppendSharedMemory( |
| 303 uuid_, shared_memory->handle(), static_cast<uint32_t>(chunk_size))); | 305 uuid_, shared_memory->handle(), static_cast<uint32_t>(chunk_size))); |
| 304 data_size -= chunk_size; | 306 data_size -= chunk_size; |
| 305 offset += chunk_size; | 307 offset += chunk_size; |
| 306 } | 308 } |
| 307 } | 309 } |
| 308 | 310 |
| 309 } // namespace content | 311 } // namespace content |
| OLD | NEW |