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/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/shared_memory.h" | 9 #include "base/shared_memory.h" |
10 #include "content/child/child_thread.h" | 10 #include "content/child/child_thread.h" |
(...skipping 15 matching lines...) Expand all Loading... | |
26 | 26 |
27 WebBlobRegistryImpl::WebBlobRegistryImpl(ThreadSafeSender* sender) | 27 WebBlobRegistryImpl::WebBlobRegistryImpl(ThreadSafeSender* sender) |
28 : sender_(sender) { | 28 : sender_(sender) { |
29 } | 29 } |
30 | 30 |
31 WebBlobRegistryImpl::~WebBlobRegistryImpl() { | 31 WebBlobRegistryImpl::~WebBlobRegistryImpl() { |
32 } | 32 } |
33 | 33 |
34 void WebBlobRegistryImpl::SendData(const WebURL& url, | 34 void WebBlobRegistryImpl::SendData(const WebURL& url, |
35 const WebThreadSafeData& data, | 35 const WebThreadSafeData& data, |
36 webkit_blob::BlobData::Item* item) { | 36 webkit_blob::BlobData::Item* item) { |
michaeln
2013/06/24 20:48:17
Do callers of this method use in any way the modif
tyoshino (SeeGerritForStatus)
2013/06/25 08:38:00
One Item instance is shared between code for each
| |
37 const size_t kLargeThresholdBytes = 250 * 1024; | 37 const size_t kLargeThresholdBytes = 250 * 1024; |
38 const size_t kMaxSharedMemoryBytes = 10 * 1024 * 1024; | 38 const size_t kMaxSharedMemoryBytes = 10 * 1024 * 1024; |
39 | 39 |
40 if (data.size() == 0) | 40 if (data.size() == 0) |
41 return; | 41 return; |
42 if (data.size() < kLargeThresholdBytes) { | 42 if (data.size() < kLargeThresholdBytes) { |
43 item->SetToBytes(data.data(), data.size()); | 43 item->SetToBytes(data.data(), data.size()); |
44 sender_->Send(new BlobHostMsg_AppendBlobDataItem(url, *item)); | 44 sender_->Send(new BlobHostMsg_AppendBlobDataItem(url, *item)); |
45 } else { | 45 } else { |
46 // We handle larger amounts of data via SharedMemory instead of | 46 // We handle larger amounts of data via SharedMemory instead of |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 } | 112 } |
113 break; | 113 break; |
114 default: | 114 default: |
115 NOTREACHED(); | 115 NOTREACHED(); |
116 } | 116 } |
117 } | 117 } |
118 sender_->Send(new BlobHostMsg_FinishBuildingBlob( | 118 sender_->Send(new BlobHostMsg_FinishBuildingBlob( |
119 url, data.contentType().utf8().data())); | 119 url, data.contentType().utf8().data())); |
120 } | 120 } |
121 | 121 |
122 void WebBlobRegistryImpl::registerStreamURL( | |
123 const WebURL& url, const WebString& content_type) { | |
124 DCHECK(ChildThread::current()->message_loop() == | |
125 base::MessageLoop::current()); | |
126 sender_->Send(new BlobHostMsg_StartBuildingStream(url, type.utf8())); | |
127 } | |
128 | |
122 void WebBlobRegistryImpl::registerBlobURL( | 129 void WebBlobRegistryImpl::registerBlobURL( |
123 const WebURL& url, const WebURL& src_url) { | 130 const WebURL& url, const WebURL& src_url) { |
124 DCHECK(ChildThread::current()->message_loop() == | 131 DCHECK(ChildThread::current()->message_loop() == |
125 base::MessageLoop::current()); | 132 base::MessageLoop::current()); |
126 sender_->Send(new BlobHostMsg_CloneBlob(url, src_url)); | 133 sender_->Send(new BlobHostMsg_CloneBlob(url, src_url)); |
127 } | 134 } |
128 | 135 |
136 void WebBlobRegistryImpl::addDataToStream(const WebKit::WebURL& url, | |
137 WebKit::WebThreadSafeData& data) { | |
138 DCHECK(ChildThread::current()->message_loop() == | |
139 base::MessageLoop::current()); | |
140 webkit_blob::BlobData::Item item; | |
141 SendData(url, data, &item); | |
142 } | |
143 | |
144 void WebBlobRegistryImpl::finalizeStream(const WebURL& url) { | |
145 DCHECK(ChildThread::current()->message_loop() == | |
146 base::MessageLoop::current()); | |
147 sender_->Send(new BlobHostMsg_FinishBuildingBlob(url, "")); | |
148 } | |
149 | |
129 void WebBlobRegistryImpl::unregisterBlobURL(const WebURL& url) { | 150 void WebBlobRegistryImpl::unregisterBlobURL(const WebURL& url) { |
130 DCHECK(ChildThread::current()->message_loop() == | 151 DCHECK(ChildThread::current()->message_loop() == |
131 base::MessageLoop::current()); | 152 base::MessageLoop::current()); |
132 sender_->Send(new BlobHostMsg_RemoveBlob(url)); | 153 sender_->Send(new BlobHostMsg_RemoveBlob(url)); |
133 } | 154 } |
134 | 155 |
135 } // namespace content | 156 } // namespace content |
OLD | NEW |