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/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 const blink::WebString& uuid, const blink::WebBlobData& data) { | 43 const blink::WebString& uuid, const blink::WebBlobData& data) { |
44 const std::string uuid_str(uuid.utf8()); | 44 const std::string uuid_str(uuid.utf8()); |
45 | 45 |
46 storage::DataElement data_buffer; | 46 storage::DataElement data_buffer; |
47 data_buffer.SetToEmptyBytes(); | 47 data_buffer.SetToEmptyBytes(); |
48 | 48 |
49 sender_->Send(new BlobHostMsg_StartBuilding(uuid_str)); | 49 sender_->Send(new BlobHostMsg_StartBuilding(uuid_str)); |
50 size_t i = 0; | 50 size_t i = 0; |
51 WebBlobData::Item data_item; | 51 WebBlobData::Item data_item; |
52 while (data.itemAt(i++, data_item)) { | 52 while (data.itemAt(i++, data_item)) { |
| 53 // NOTE: data_item.length == -1 when we want to use the whole file. This |
| 54 // only happens when we are creating a file object in Blink, and the file |
| 55 // object is the only item in the 'blob'. If we use that file blob to |
| 56 // create another blob, it is sent here as a 'file' item and not a blob, |
| 57 // and the correct size is populated. |
| 58 // static_cast<uint64>(-1) == kuint64max, which is what DataElement uses |
| 59 // to specificy "use the whole file". |
53 if (data_item.length == 0) { | 60 if (data_item.length == 0) { |
54 continue; | 61 continue; |
55 } | 62 } |
56 if (data_item.type != WebBlobData::Item::TypeData && | 63 if (data_item.type != WebBlobData::Item::TypeData && |
57 data_buffer.length() != 0) { | 64 data_buffer.length() != 0) { |
58 FlushBlobItemBuffer(uuid_str, &data_buffer); | 65 FlushBlobItemBuffer(uuid_str, &data_buffer); |
59 } | 66 } |
60 storage::DataElement item; | 67 storage::DataElement item; |
61 switch (data_item.type) { | 68 switch (data_item.type) { |
62 case WebBlobData::Item::TypeData: { | 69 case WebBlobData::Item::TypeData: { |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 DCHECK(ChildThreadImpl::current()); | 244 DCHECK(ChildThreadImpl::current()); |
238 sender_->Send(new StreamHostMsg_AbortBuilding(url)); | 245 sender_->Send(new StreamHostMsg_AbortBuilding(url)); |
239 } | 246 } |
240 | 247 |
241 void WebBlobRegistryImpl::unregisterStreamURL(const WebURL& url) { | 248 void WebBlobRegistryImpl::unregisterStreamURL(const WebURL& url) { |
242 DCHECK(ChildThreadImpl::current()); | 249 DCHECK(ChildThreadImpl::current()); |
243 sender_->Send(new StreamHostMsg_Remove(url)); | 250 sender_->Send(new StreamHostMsg_Remove(url)); |
244 } | 251 } |
245 | 252 |
246 } // namespace content | 253 } // namespace content |
OLD | NEW |