| 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 "content/child/child_thread.h" | 12 #include "content/child/child_thread.h" |
| 13 #include "content/child/thread_safe_sender.h" | 13 #include "content/child/thread_safe_sender.h" |
| 14 #include "content/common/fileapi/webblob_messages.h" | 14 #include "content/common/fileapi/webblob_messages.h" |
| 15 #include "third_party/WebKit/public/platform/WebBlobData.h" | 15 #include "third_party/WebKit/public/platform/WebBlobData.h" |
| 16 #include "third_party/WebKit/public/platform/WebString.h" | 16 #include "third_party/WebKit/public/platform/WebString.h" |
| 17 #include "third_party/WebKit/public/platform/WebThreadSafeData.h" | 17 #include "third_party/WebKit/public/platform/WebThreadSafeData.h" |
| 18 #include "third_party/WebKit/public/platform/WebURL.h" | 18 #include "third_party/WebKit/public/platform/WebURL.h" |
| 19 #include "webkit/common/blob/blob_data.h" | 19 #include "webkit/common/blob/blob_data.h" |
| 20 | 20 |
| 21 using WebKit::WebBlobData; | 21 using blink::WebBlobData; |
| 22 using WebKit::WebString; | 22 using blink::WebString; |
| 23 using WebKit::WebThreadSafeData; | 23 using blink::WebThreadSafeData; |
| 24 using WebKit::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 } | 37 } |
| 38 | 38 |
| 39 WebBlobRegistryImpl::~WebBlobRegistryImpl() { | 39 WebBlobRegistryImpl::~WebBlobRegistryImpl() { |
| 40 } | 40 } |
| 41 | 41 |
| 42 void WebBlobRegistryImpl::registerBlobData( | 42 void WebBlobRegistryImpl::registerBlobData( |
| 43 const WebKit::WebString& uuid, const WebKit::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 sender_->Send(new BlobHostMsg_StartBuilding(uuid_str)); | 46 sender_->Send(new BlobHostMsg_StartBuilding(uuid_str)); |
| 47 size_t i = 0; | 47 size_t i = 0; |
| 48 WebBlobData::Item data_item; | 48 WebBlobData::Item data_item; |
| 49 while (data.itemAt(i++, data_item)) { | 49 while (data.itemAt(i++, data_item)) { |
| 50 switch (data_item.type) { | 50 switch (data_item.type) { |
| 51 case WebBlobData::Item::TypeData: { | 51 case WebBlobData::Item::TypeData: { |
| 52 // WebBlobData does not allow partial data items. | 52 // WebBlobData does not allow partial data items. |
| 53 DCHECK(!data_item.offset && data_item.length == -1); | 53 DCHECK(!data_item.offset && data_item.length == -1); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 DCHECK(ChildThread::current()); | 203 DCHECK(ChildThread::current()); |
| 204 sender_->Send(new StreamHostMsg_AbortBuilding(url)); | 204 sender_->Send(new StreamHostMsg_AbortBuilding(url)); |
| 205 } | 205 } |
| 206 | 206 |
| 207 void WebBlobRegistryImpl::unregisterStreamURL(const WebURL& url) { | 207 void WebBlobRegistryImpl::unregisterStreamURL(const WebURL& url) { |
| 208 DCHECK(ChildThread::current()); | 208 DCHECK(ChildThread::current()); |
| 209 sender_->Send(new StreamHostMsg_Remove(url)); | 209 sender_->Send(new StreamHostMsg_Remove(url)); |
| 210 } | 210 } |
| 211 | 211 |
| 212 } // namespace content | 212 } // namespace content |
| OLD | NEW |