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" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 data_item.expectedModificationTime); | 78 data_item.expectedModificationTime); |
79 break; | 79 break; |
80 case WebBlobData::Item::TypeBlob: | 80 case WebBlobData::Item::TypeBlob: |
81 builder->appendBlob(data_item.blobUUID, data_item.offset, | 81 builder->appendBlob(data_item.blobUUID, data_item.offset, |
82 data_item.length); | 82 data_item.length); |
83 break; | 83 break; |
84 case WebBlobData::Item::TypeFileSystemURL: | 84 case WebBlobData::Item::TypeFileSystemURL: |
85 // We only support filesystem URL as of now. | 85 // We only support filesystem URL as of now. |
86 DCHECK(GURL(data_item.fileSystemURL).SchemeIsFileSystem()); | 86 DCHECK(GURL(data_item.fileSystemURL).SchemeIsFileSystem()); |
87 builder->appendFileSystemURL(data_item.fileSystemURL, | 87 builder->appendFileSystemURL(data_item.fileSystemURL, |
88 static_cast<uint64>(data_item.offset), | 88 static_cast<uint64_t>(data_item.offset), |
89 static_cast<uint64>(data_item.length), | 89 static_cast<uint64_t>(data_item.length), |
90 data_item.expectedModificationTime); | 90 data_item.expectedModificationTime); |
91 break; | 91 break; |
92 default: | 92 default: |
93 NOTREACHED(); | 93 NOTREACHED(); |
94 } | 94 } |
95 } | 95 } |
96 builder->build(); | 96 builder->build(); |
97 } | 97 } |
98 | 98 |
99 void WebBlobRegistryImpl::addBlobDataRef(const WebString& uuid) { | 99 void WebBlobRegistryImpl::addBlobDataRef(const WebString& uuid) { |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 size_t buffer_size = 0; | 231 size_t buffer_size = 0; |
232 scoped_ptr<char[]> buffer; | 232 scoped_ptr<char[]> buffer; |
233 for (size_t i = 0; i < items.size(); i++) { | 233 for (size_t i = 0; i < items.size(); i++) { |
234 const BlobConsolidation::ConsolidatedItem& item = items[i]; | 234 const BlobConsolidation::ConsolidatedItem& item = items[i]; |
235 DataElement element; | 235 DataElement element; |
236 // NOTE: length == -1 when we want to use the whole file. This | 236 // NOTE: length == -1 when we want to use the whole file. This |
237 // only happens when we are creating a file object in Blink, and the file | 237 // only happens when we are creating a file object in Blink, and the file |
238 // object is the only item in the 'blob'. If we use that file blob to | 238 // object is the only item in the 'blob'. If we use that file blob to |
239 // create another blob, it is sent here as a 'file' item and not a blob, | 239 // create another blob, it is sent here as a 'file' item and not a blob, |
240 // and the correct size is populated. | 240 // and the correct size is populated. |
241 // static_cast<uint64>(-1) == kuint64max, which is what DataElement uses | 241 // static_cast<uint64_t>(-1) == kuint64max, which is what DataElement uses |
242 // to specificy "use the whole file". | 242 // to specificy "use the whole file". |
243 switch (item.type) { | 243 switch (item.type) { |
244 case DataElement::TYPE_BYTES: | 244 case DataElement::TYPE_BYTES: |
245 if (item.length > kLargeThresholdBytes) { | 245 if (item.length > kLargeThresholdBytes) { |
246 SendOversizedDataForBlob(i); | 246 SendOversizedDataForBlob(i); |
247 break; | 247 break; |
248 } | 248 } |
249 if (buffer_size < item.length) { | 249 if (buffer_size < item.length) { |
250 buffer.reset(new char[item.length]); | 250 buffer.reset(new char[item.length]); |
251 buffer_size = item.length; | 251 buffer_size = item.length; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 consolidation_.ReadMemory(consolidated_item_index, offset, chunk_size, | 300 consolidation_.ReadMemory(consolidated_item_index, offset, chunk_size, |
301 shared_memory->memory()); | 301 shared_memory->memory()); |
302 sender_->Send(new BlobHostMsg_SyncAppendSharedMemory( | 302 sender_->Send(new BlobHostMsg_SyncAppendSharedMemory( |
303 uuid_, shared_memory->handle(), chunk_size)); | 303 uuid_, shared_memory->handle(), chunk_size)); |
304 data_size -= chunk_size; | 304 data_size -= chunk_size; |
305 offset += chunk_size; | 305 offset += chunk_size; |
306 } | 306 } |
307 } | 307 } |
308 | 308 |
309 } // namespace content | 309 } // namespace content |
OLD | NEW |