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/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" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/trace_event/trace_event.h" | |
| 12 #include "content/child/child_thread_impl.h" | 13 #include "content/child/child_thread_impl.h" |
| 13 #include "content/child/thread_safe_sender.h" | 14 #include "content/child/thread_safe_sender.h" |
| 14 #include "content/common/fileapi/webblob_messages.h" | 15 #include "content/common/fileapi/webblob_messages.h" |
| 15 #include "storage/common/data_element.h" | |
| 16 #include "third_party/WebKit/public/platform/WebBlobData.h" | 16 #include "third_party/WebKit/public/platform/WebBlobData.h" |
| 17 #include "third_party/WebKit/public/platform/WebString.h" | 17 #include "third_party/WebKit/public/platform/WebString.h" |
| 18 #include "third_party/WebKit/public/platform/WebThreadSafeData.h" | 18 #include "third_party/WebKit/public/platform/WebThreadSafeData.h" |
| 19 #include "third_party/WebKit/public/platform/WebURL.h" | 19 #include "third_party/WebKit/public/platform/WebURL.h" |
| 20 | 20 |
| 21 using blink::WebBlobData; | 21 using blink::WebBlobData; |
| 22 using blink::WebString; | 22 using blink::WebString; |
| 23 using blink::WebThreadSafeData; | 23 using blink::WebThreadSafeData; |
| 24 using blink::WebURL; | 24 using blink::WebURL; |
| 25 | 25 |
| 26 namespace content { | 26 namespace content { |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 const size_t kLargeThresholdBytes = 250 * 1024; | 30 const size_t kLargeThresholdBytes = 250 * 1024; |
| 31 const size_t kMaxSharedMemoryBytes = 10 * 1024 * 1024; | 31 const size_t kMaxSharedMemoryBytes = 10 * 1024 * 1024; |
| 32 | 32 |
| 33 } // namespace | 33 } // namespace |
| 34 | 34 |
| 35 WebBlobRegistryImpl::WebBlobRegistryImpl(ThreadSafeSender* sender) | 35 WebBlobRegistryImpl::WebBlobRegistryImpl(ThreadSafeSender* sender) |
| 36 : sender_(sender) { | 36 : sender_(sender) { |
| 37 TRACE_EVENT0("Storage.Blob", "Init"); | |
|
michaeln
2015/03/09 21:22:02
this one is probably not so interesting, it happen
dmurph
2015/03/10 00:39:09
This is to get the category to show up in the trac
| |
| 37 } | 38 } |
| 38 | 39 |
| 39 WebBlobRegistryImpl::~WebBlobRegistryImpl() { | 40 WebBlobRegistryImpl::~WebBlobRegistryImpl() { |
| 40 } | 41 } |
| 41 | 42 |
| 42 void WebBlobRegistryImpl::registerBlobData( | 43 void WebBlobRegistryImpl::registerBlobData( |
| 43 const blink::WebString& uuid, const blink::WebBlobData& data) { | 44 const blink::WebString& uuid, const blink::WebBlobData& data) { |
| 45 TRACE_EVENT0("Storage.Blob", "RegisterBlobData"); | |
| 44 const std::string uuid_str(uuid.utf8()); | 46 const std::string uuid_str(uuid.utf8()); |
| 45 | 47 |
| 46 storage::DataElement data_buffer; | 48 storage::DataElement data_buffer; |
| 47 data_buffer.SetToEmptyBytes(); | 49 data_buffer.SetToEmptyBytes(); |
| 48 | 50 |
| 49 sender_->Send(new BlobHostMsg_StartBuilding(uuid_str)); | 51 sender_->Send(new BlobHostMsg_StartBuilding(uuid_str)); |
| 50 size_t i = 0; | 52 size_t i = 0; |
| 51 WebBlobData::Item data_item; | 53 WebBlobData::Item data_item; |
| 52 while (data.itemAt(i++, data_item)) { | 54 while (data.itemAt(i++, data_item)) { |
| 53 // NOTE: data_item.length == -1 when we want to use the whole file. This | 55 // NOTE: data_item.length == -1 when we want to use the whole file. This |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 | 125 |
| 124 void WebBlobRegistryImpl::registerPublicBlobURL( | 126 void WebBlobRegistryImpl::registerPublicBlobURL( |
| 125 const WebURL& url, const WebString& uuid) { | 127 const WebURL& url, const WebString& uuid) { |
| 126 sender_->Send(new BlobHostMsg_RegisterPublicURL(url, uuid.utf8())); | 128 sender_->Send(new BlobHostMsg_RegisterPublicURL(url, uuid.utf8())); |
| 127 } | 129 } |
| 128 | 130 |
| 129 void WebBlobRegistryImpl::revokePublicBlobURL(const WebURL& url) { | 131 void WebBlobRegistryImpl::revokePublicBlobURL(const WebURL& url) { |
| 130 sender_->Send(new BlobHostMsg_RevokePublicURL(url)); | 132 sender_->Send(new BlobHostMsg_RevokePublicURL(url)); |
| 131 } | 133 } |
| 132 | 134 |
| 133 void WebBlobRegistryImpl::FlushBlobItemBuffer( | 135 void WebBlobRegistryImpl::FlushBlobItemBuffer( |
|
michaeln
2015/03/09 21:22:02
Wdyt about tracking FlushBlobItemBuffer BufferBlob
dmurph
2015/03/10 00:39:09
I like info about sending the oversized data, but
| |
| 134 const std::string& uuid_str, | 136 const std::string& uuid_str, |
| 135 storage::DataElement* data_buffer) const { | 137 storage::DataElement* data_buffer) const { |
| 136 DCHECK_NE(data_buffer->length(), 0ul); | 138 DCHECK_NE(data_buffer->length(), 0ul); |
| 137 DCHECK_LT(data_buffer->length(), kLargeThresholdBytes); | 139 DCHECK_LT(data_buffer->length(), kLargeThresholdBytes); |
| 138 sender_->Send(new BlobHostMsg_AppendBlobDataItem(uuid_str, *data_buffer)); | 140 sender_->Send(new BlobHostMsg_AppendBlobDataItem(uuid_str, *data_buffer)); |
| 139 data_buffer->SetToEmptyBytes(); | 141 data_buffer->SetToEmptyBytes(); |
| 140 } | 142 } |
| 141 | 143 |
| 142 void WebBlobRegistryImpl::BufferBlobData(const std::string& uuid_str, | 144 void WebBlobRegistryImpl::BufferBlobData(const std::string& uuid_str, |
| 143 const blink::WebThreadSafeData& data, | 145 const blink::WebThreadSafeData& data, |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 DCHECK(ChildThreadImpl::current()); | 246 DCHECK(ChildThreadImpl::current()); |
| 245 sender_->Send(new StreamHostMsg_AbortBuilding(url)); | 247 sender_->Send(new StreamHostMsg_AbortBuilding(url)); |
| 246 } | 248 } |
| 247 | 249 |
| 248 void WebBlobRegistryImpl::unregisterStreamURL(const WebURL& url) { | 250 void WebBlobRegistryImpl::unregisterStreamURL(const WebURL& url) { |
| 249 DCHECK(ChildThreadImpl::current()); | 251 DCHECK(ChildThreadImpl::current()); |
| 250 sender_->Send(new StreamHostMsg_Remove(url)); | 252 sender_->Send(new StreamHostMsg_Remove(url)); |
| 251 } | 253 } |
| 252 | 254 |
| 253 } // namespace content | 255 } // namespace content |
| OLD | NEW |