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

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

Issue 1683033002: Add a checked_cast for size_t to uint32_t conversion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | 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/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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698