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/shared_memory.h" | 11 #include "base/memory/shared_memory.h" |
11 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
12 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
13 #include "content/child/child_thread_impl.h" | 14 #include "content/child/child_thread_impl.h" |
14 #include "content/child/thread_safe_sender.h" | 15 #include "content/child/thread_safe_sender.h" |
15 #include "content/common/fileapi/webblob_messages.h" | 16 #include "content/common/fileapi/webblob_messages.h" |
16 #include "third_party/WebKit/public/platform/WebBlobData.h" | 17 #include "third_party/WebKit/public/platform/WebBlobData.h" |
17 #include "third_party/WebKit/public/platform/WebString.h" | 18 #include "third_party/WebKit/public/platform/WebString.h" |
18 #include "third_party/WebKit/public/platform/WebThreadSafeData.h" | 19 #include "third_party/WebKit/public/platform/WebThreadSafeData.h" |
19 #include "third_party/WebKit/public/platform/WebURL.h" | 20 #include "third_party/WebKit/public/platform/WebURL.h" |
20 | 21 |
21 using blink::WebBlobData; | 22 using blink::WebBlobData; |
22 using blink::WebString; | 23 using blink::WebString; |
23 using blink::WebThreadSafeData; | 24 using blink::WebThreadSafeData; |
24 using blink::WebURL; | 25 using blink::WebURL; |
26 using blink::WebBlobRegistry; | |
27 using storage::DataElement; | |
25 | 28 |
26 namespace content { | 29 namespace content { |
27 | 30 |
28 namespace { | 31 namespace { |
29 | 32 |
30 const size_t kLargeThresholdBytes = 250 * 1024; | 33 const size_t kLargeThresholdBytes = 250 * 1024; |
31 const size_t kMaxSharedMemoryBytes = 10 * 1024 * 1024; | 34 const size_t kMaxSharedMemoryBytes = 10 * 1024 * 1024; |
32 | 35 |
33 } // namespace | 36 } // namespace |
34 | 37 |
35 WebBlobRegistryImpl::WebBlobRegistryImpl(ThreadSafeSender* sender) | 38 WebBlobRegistryImpl::WebBlobRegistryImpl(ThreadSafeSender* sender) |
36 : sender_(sender) { | 39 : sender_(sender) { |
37 // Record a dummy trace event on startup so the 'Storage' category shows up | 40 // Record a dummy trace event on startup so the 'Storage' category shows up |
38 // in the chrome://tracing viewer. | 41 // in the chrome://tracing viewer. |
39 TRACE_EVENT0("Blob", "Init"); | 42 TRACE_EVENT0("Blob", "Init"); |
40 } | 43 } |
41 | 44 |
42 WebBlobRegistryImpl::~WebBlobRegistryImpl() { | 45 WebBlobRegistryImpl::~WebBlobRegistryImpl() {} |
46 | |
47 blink::WebBlobRegistry::Builder* WebBlobRegistryImpl::createBuilder( | |
48 const blink::WebString& uuid, const blink::WebString& contentType) { | |
49 return new BuilderImpl(uuid, contentType, sender_.get()); | |
43 } | 50 } |
44 | 51 |
45 void WebBlobRegistryImpl::registerBlobData( | 52 void WebBlobRegistryImpl::registerBlobData(const blink::WebString& uuid, |
46 const blink::WebString& uuid, const blink::WebBlobData& data) { | 53 const blink::WebBlobData& data) { |
47 TRACE_EVENT0("Blob", "Registry::RegisterBlob"); | 54 TRACE_EVENT0("Blob", "Registry::RegisterBlob"); |
48 const std::string uuid_str(uuid.utf8()); | 55 scoped_ptr<Builder> builder(createBuilder(uuid, data.contentType())); |
49 | 56 |
50 storage::DataElement data_buffer; | 57 // This is temporary until we move to createBuilder() as our blob creation |
51 data_buffer.SetToEmptyBytes(); | 58 // method. |
52 | |
53 sender_->Send(new BlobHostMsg_StartBuilding(uuid_str)); | |
54 size_t i = 0; | 59 size_t i = 0; |
55 WebBlobData::Item data_item; | 60 WebBlobData::Item data_item; |
56 while (data.itemAt(i++, data_item)) { | 61 while (data.itemAt(i++, data_item)) { |
57 // NOTE: data_item.length == -1 when we want to use the whole file. This | |
58 // only happens when we are creating a file object in Blink, and the file | |
59 // object is the only item in the 'blob'. If we use that file blob to | |
60 // create another blob, it is sent here as a 'file' item and not a blob, | |
61 // and the correct size is populated. | |
62 // static_cast<uint64>(-1) == kuint64max, which is what DataElement uses | |
63 // to specificy "use the whole file". | |
64 if (data_item.length == 0) { | 62 if (data_item.length == 0) { |
65 continue; | 63 continue; |
66 } | 64 } |
67 if (data_item.type != WebBlobData::Item::TypeData && | |
68 data_buffer.length() != 0) { | |
69 FlushBlobItemBuffer(uuid_str, &data_buffer); | |
70 } | |
71 storage::DataElement item; | |
72 switch (data_item.type) { | 65 switch (data_item.type) { |
73 case WebBlobData::Item::TypeData: { | 66 case WebBlobData::Item::TypeData: { |
74 // WebBlobData does not allow partial data items. | 67 // WebBlobData does not allow partial data items. |
75 DCHECK(!data_item.offset && data_item.length == -1); | 68 DCHECK(!data_item.offset && data_item.length == -1); |
76 if (data_item.data.size() == 0) { | 69 builder->appendData(data_item.data); |
77 continue; | |
78 } | |
79 BufferBlobData(uuid_str, data_item.data, &data_buffer); | |
80 break; | 70 break; |
81 } | 71 } |
82 case WebBlobData::Item::TypeFile: | 72 case WebBlobData::Item::TypeFile: |
83 item.SetToFilePathRange( | 73 builder->appendFile(data_item.filePath, |
84 base::FilePath::FromUTF16Unsafe(data_item.filePath), | 74 static_cast<uint64_t>(data_item.offset), |
85 static_cast<uint64>(data_item.offset), | 75 static_cast<uint64_t>(data_item.length), |
86 static_cast<uint64>(data_item.length), | 76 data_item.expectedModificationTime); |
87 base::Time::FromDoubleT(data_item.expectedModificationTime)); | |
88 sender_->Send(new BlobHostMsg_AppendBlobDataItem(uuid_str, item)); | |
89 break; | 77 break; |
90 case WebBlobData::Item::TypeBlob: | 78 case WebBlobData::Item::TypeBlob: |
91 item.SetToBlobRange( | 79 builder->appendBlob(data_item.blobUUID, data_item.offset, |
92 data_item.blobUUID.utf8(), | 80 data_item.length); |
93 static_cast<uint64>(data_item.offset), | |
94 static_cast<uint64>(data_item.length)); | |
95 sender_->Send( | |
96 new BlobHostMsg_AppendBlobDataItem(uuid_str, item)); | |
97 break; | 81 break; |
98 case WebBlobData::Item::TypeFileSystemURL: | 82 case WebBlobData::Item::TypeFileSystemURL: |
99 // We only support filesystem URL as of now. | 83 // We only support filesystem URL as of now. |
100 DCHECK(GURL(data_item.fileSystemURL).SchemeIsFileSystem()); | 84 DCHECK(GURL(data_item.fileSystemURL).SchemeIsFileSystem()); |
101 item.SetToFileSystemUrlRange( | 85 builder->appendFileSystemURL(data_item.fileSystemURL, |
102 data_item.fileSystemURL, | 86 static_cast<uint64>(data_item.offset), |
103 static_cast<uint64>(data_item.offset), | 87 static_cast<uint64>(data_item.length), |
104 static_cast<uint64>(data_item.length), | 88 data_item.expectedModificationTime); |
105 base::Time::FromDoubleT(data_item.expectedModificationTime)); | |
106 sender_->Send( | |
107 new BlobHostMsg_AppendBlobDataItem(uuid_str, item)); | |
108 break; | 89 break; |
109 default: | 90 default: |
110 NOTREACHED(); | 91 NOTREACHED(); |
111 } | 92 } |
112 } | 93 } |
113 if (data_buffer.length() != 0) { | 94 builder->build(); |
114 FlushBlobItemBuffer(uuid_str, &data_buffer); | |
115 } | |
116 sender_->Send(new BlobHostMsg_FinishBuilding( | |
117 uuid_str, data.contentType().utf8().data())); | |
118 } | 95 } |
119 | 96 |
120 void WebBlobRegistryImpl::addBlobDataRef(const WebString& uuid) { | 97 void WebBlobRegistryImpl::addBlobDataRef(const WebString& uuid) { |
121 sender_->Send(new BlobHostMsg_IncrementRefCount(uuid.utf8())); | 98 sender_->Send(new BlobHostMsg_IncrementRefCount(uuid.utf8())); |
122 } | 99 } |
123 | 100 |
124 void WebBlobRegistryImpl::removeBlobDataRef(const WebString& uuid) { | 101 void WebBlobRegistryImpl::removeBlobDataRef(const WebString& uuid) { |
125 sender_->Send(new BlobHostMsg_DecrementRefCount(uuid.utf8())); | 102 sender_->Send(new BlobHostMsg_DecrementRefCount(uuid.utf8())); |
126 } | 103 } |
127 | 104 |
128 void WebBlobRegistryImpl::registerPublicBlobURL( | 105 void WebBlobRegistryImpl::registerPublicBlobURL(const WebURL& url, |
129 const WebURL& url, const WebString& uuid) { | 106 const WebString& uuid) { |
130 sender_->Send(new BlobHostMsg_RegisterPublicURL(url, uuid.utf8())); | 107 sender_->Send(new BlobHostMsg_RegisterPublicURL(url, uuid.utf8())); |
131 } | 108 } |
132 | 109 |
133 void WebBlobRegistryImpl::revokePublicBlobURL(const WebURL& url) { | 110 void WebBlobRegistryImpl::revokePublicBlobURL(const WebURL& url) { |
134 sender_->Send(new BlobHostMsg_RevokePublicURL(url)); | 111 sender_->Send(new BlobHostMsg_RevokePublicURL(url)); |
135 } | 112 } |
136 | 113 |
137 void WebBlobRegistryImpl::FlushBlobItemBuffer( | |
138 const std::string& uuid_str, | |
139 storage::DataElement* data_buffer) const { | |
140 DCHECK_NE(data_buffer->length(), 0ul); | |
141 DCHECK_LT(data_buffer->length(), kLargeThresholdBytes); | |
142 sender_->Send(new BlobHostMsg_AppendBlobDataItem(uuid_str, *data_buffer)); | |
143 data_buffer->SetToEmptyBytes(); | |
144 } | |
145 | |
146 void WebBlobRegistryImpl::BufferBlobData(const std::string& uuid_str, | |
147 const blink::WebThreadSafeData& data, | |
148 storage::DataElement* data_buffer) { | |
149 size_t buffer_size = data_buffer->length(); | |
150 size_t data_size = data.size(); | |
151 DCHECK_NE(data_size, 0ul); | |
152 if (buffer_size != 0 && buffer_size + data_size >= kLargeThresholdBytes) { | |
153 FlushBlobItemBuffer(uuid_str, data_buffer); | |
154 buffer_size = 0; | |
155 } | |
156 if (data_size >= kLargeThresholdBytes) { | |
157 TRACE_EVENT0("Blob", "Registry::SendOversizedBlobData"); | |
158 SendOversizedDataForBlob(uuid_str, data); | |
159 } else { | |
160 DCHECK_LT(buffer_size + data_size, kLargeThresholdBytes); | |
161 data_buffer->AppendBytes(data.data(), data_size); | |
162 } | |
163 } | |
164 | |
165 void WebBlobRegistryImpl::SendOversizedDataForBlob( | |
166 const std::string& uuid_str, | |
167 const blink::WebThreadSafeData& data) { | |
168 DCHECK_GE(data.size(), kLargeThresholdBytes); | |
169 // We handle larger amounts of data via SharedMemory instead of | |
170 // writing it directly to the IPC channel. | |
171 size_t shared_memory_size = std::min(data.size(), kMaxSharedMemoryBytes); | |
172 scoped_ptr<base::SharedMemory> shared_memory( | |
173 ChildThreadImpl::AllocateSharedMemory(shared_memory_size, sender_.get())); | |
174 CHECK(shared_memory.get()); | |
175 if (!shared_memory->Map(shared_memory_size)) | |
176 CHECK(false); | |
177 | |
178 size_t data_size = data.size(); | |
179 const char* data_ptr = data.data(); | |
180 while (data_size) { | |
181 TRACE_EVENT0("Blob", "Registry::SendOversizedBlobItem"); | |
182 size_t chunk_size = std::min(data_size, shared_memory_size); | |
183 memcpy(shared_memory->memory(), data_ptr, chunk_size); | |
184 sender_->Send(new BlobHostMsg_SyncAppendSharedMemory( | |
185 uuid_str, shared_memory->handle(), chunk_size)); | |
186 data_size -= chunk_size; | |
187 data_ptr += chunk_size; | |
188 } | |
189 } | |
190 | |
191 // ------ streams stuff ----- | 114 // ------ streams stuff ----- |
192 | 115 |
193 void WebBlobRegistryImpl::registerStreamURL( | 116 void WebBlobRegistryImpl::registerStreamURL(const WebURL& url, |
194 const WebURL& url, const WebString& content_type) { | 117 const WebString& content_type) { |
195 DCHECK(ChildThreadImpl::current()); | 118 DCHECK(ChildThreadImpl::current()); |
196 sender_->Send(new StreamHostMsg_StartBuilding(url, content_type.utf8())); | 119 sender_->Send(new StreamHostMsg_StartBuilding(url, content_type.utf8())); |
197 } | 120 } |
198 | 121 |
199 void WebBlobRegistryImpl::registerStreamURL( | 122 void WebBlobRegistryImpl::registerStreamURL(const WebURL& url, |
200 const WebURL& url, const WebURL& src_url) { | 123 const WebURL& src_url) { |
201 DCHECK(ChildThreadImpl::current()); | 124 DCHECK(ChildThreadImpl::current()); |
202 sender_->Send(new StreamHostMsg_Clone(url, src_url)); | 125 sender_->Send(new StreamHostMsg_Clone(url, src_url)); |
203 } | 126 } |
204 | 127 |
205 void WebBlobRegistryImpl::addDataToStream(const WebURL& url, | 128 void WebBlobRegistryImpl::addDataToStream(const WebURL& url, const char* data, |
206 const char* data, size_t length) { | 129 size_t length) { |
207 DCHECK(ChildThreadImpl::current()); | 130 DCHECK(ChildThreadImpl::current()); |
208 if (length == 0) | 131 if (length == 0) return; |
209 return; | |
210 if (length < kLargeThresholdBytes) { | 132 if (length < kLargeThresholdBytes) { |
211 storage::DataElement item; | 133 DataElement item; |
212 item.SetToBytes(data, length); | 134 item.SetToBytes(data, length); |
213 sender_->Send(new StreamHostMsg_AppendBlobDataItem(url, item)); | 135 sender_->Send(new StreamHostMsg_AppendBlobDataItem(url, item)); |
214 } else { | 136 } else { |
215 // We handle larger amounts of data via SharedMemory instead of | 137 // We handle larger amounts of data via SharedMemory instead of |
216 // writing it directly to the IPC channel. | 138 // writing it directly to the IPC channel. |
217 size_t shared_memory_size = std::min( | 139 size_t shared_memory_size = std::min(length, kMaxSharedMemoryBytes); |
218 length, kMaxSharedMemoryBytes); | |
219 scoped_ptr<base::SharedMemory> shared_memory( | 140 scoped_ptr<base::SharedMemory> shared_memory( |
220 ChildThreadImpl::AllocateSharedMemory(shared_memory_size, | 141 ChildThreadImpl::AllocateSharedMemory(shared_memory_size, |
221 sender_.get())); | 142 sender_.get())); |
222 CHECK(shared_memory.get()); | 143 CHECK(shared_memory.get()); |
223 if (!shared_memory->Map(shared_memory_size)) | 144 if (!shared_memory->Map(shared_memory_size)) CHECK(false); |
224 CHECK(false); | |
225 | 145 |
226 size_t remaining_bytes = length; | 146 size_t remaining_bytes = length; |
227 const char* current_ptr = data; | 147 const char* current_ptr = data; |
228 while (remaining_bytes) { | 148 while (remaining_bytes) { |
229 size_t chunk_size = std::min(remaining_bytes, shared_memory_size); | 149 size_t chunk_size = std::min(remaining_bytes, shared_memory_size); |
230 memcpy(shared_memory->memory(), current_ptr, chunk_size); | 150 memcpy(shared_memory->memory(), current_ptr, chunk_size); |
231 sender_->Send(new StreamHostMsg_SyncAppendSharedMemory( | 151 sender_->Send(new StreamHostMsg_SyncAppendSharedMemory( |
232 url, shared_memory->handle(), chunk_size)); | 152 url, shared_memory->handle(), chunk_size)); |
233 remaining_bytes -= chunk_size; | 153 remaining_bytes -= chunk_size; |
234 current_ptr += chunk_size; | 154 current_ptr += chunk_size; |
(...skipping 14 matching lines...) Expand all Loading... | |
249 void WebBlobRegistryImpl::abortStream(const WebURL& url) { | 169 void WebBlobRegistryImpl::abortStream(const WebURL& url) { |
250 DCHECK(ChildThreadImpl::current()); | 170 DCHECK(ChildThreadImpl::current()); |
251 sender_->Send(new StreamHostMsg_AbortBuilding(url)); | 171 sender_->Send(new StreamHostMsg_AbortBuilding(url)); |
252 } | 172 } |
253 | 173 |
254 void WebBlobRegistryImpl::unregisterStreamURL(const WebURL& url) { | 174 void WebBlobRegistryImpl::unregisterStreamURL(const WebURL& url) { |
255 DCHECK(ChildThreadImpl::current()); | 175 DCHECK(ChildThreadImpl::current()); |
256 sender_->Send(new StreamHostMsg_Remove(url)); | 176 sender_->Send(new StreamHostMsg_Remove(url)); |
257 } | 177 } |
258 | 178 |
179 WebBlobRegistryImpl::BuilderImpl::BuilderImpl( | |
180 const blink::WebString& uuid, const blink::WebString& contentType, | |
181 ThreadSafeSender* sender) | |
182 : uuid_(uuid.utf8()), content_type_(contentType.utf8()), sender_(sender) { | |
kinuko
2015/06/25 05:04:19
nit: contentType -> content_type
dmurph
2015/06/25 23:38:55
Done.
| |
183 } | |
184 | |
185 WebBlobRegistryImpl::BuilderImpl::~BuilderImpl() {} | |
186 | |
187 void WebBlobRegistryImpl::BuilderImpl::appendData( | |
188 const WebThreadSafeData& data) { | |
189 consolidation_.AddDataItem(data); | |
190 } | |
191 | |
192 void WebBlobRegistryImpl::BuilderImpl::appendBlob(const WebString& uuid, | |
193 uint64_t offset, | |
194 uint64_t length) { | |
195 consolidation_.AddBlobItem(uuid.utf8(), offset, length); | |
196 } | |
197 | |
198 void WebBlobRegistryImpl::BuilderImpl::appendFile( | |
199 const WebString& path, uint64_t offset, uint64_t length, | |
200 double expectedModificationTime) { | |
201 consolidation_.AddFileItem( | |
202 base::FilePath::FromUTF16Unsafe(base::string16(path)), offset, length, | |
203 expectedModificationTime); | |
kinuko
2015/06/25 05:04:19
nit: expectedModificationTime -> expected_modi...
dmurph
2015/06/25 23:38:55
Done.
| |
204 } | |
205 | |
206 void WebBlobRegistryImpl::BuilderImpl::appendFileSystemURL( | |
207 const WebURL& fileSystemURL, uint64_t offset, uint64_t length, | |
208 double expectedModificationTime) { | |
209 DCHECK(GURL(fileSystemURL).SchemeIsFileSystem()); | |
210 consolidation_.AddFileSystemItem(GURL(fileSystemURL), offset, length, | |
211 expectedModificationTime); | |
kinuko
2015/06/25 05:04:19
ditto
dmurph
2015/06/25 23:38:55
Done.
| |
212 } | |
213 | |
214 void WebBlobRegistryImpl::BuilderImpl::build() { | |
215 sender_->Send(new BlobHostMsg_StartBuilding(uuid_)); | |
216 const auto& items = consolidation_.consolidated_items(); | |
217 | |
218 // We still need a buffer to hold the continuous block of data so the | |
219 // DataElement can hold it. | |
220 size_t buffer_size = 0; | |
221 scoped_ptr<char[]> buffer; | |
222 for (size_t i = 0; i < items.size(); i++) { | |
223 const BlobConsolidation::ConsolidatedItem& item = items[i]; | |
224 DataElement element; | |
225 // NOTE: length == -1 when we want to use the whole file. This | |
226 // only happens when we are creating a file object in Blink, and the file | |
227 // object is the only item in the 'blob'. If we use that file blob to | |
228 // create another blob, it is sent here as a 'file' item and not a blob, | |
229 // and the correct size is populated. | |
230 // static_cast<uint64>(-1) == kuint64max, which is what DataElement uses | |
231 // to specificy "use the whole file". | |
232 switch (item.type) { | |
233 case DataElement::TYPE_BYTES: | |
234 if (item.length > kLargeThresholdBytes) { | |
235 SendOversizedDataForBlob(i); | |
236 break; | |
237 } | |
238 if (buffer_size < item.length) { | |
239 buffer.reset(new char[item.length]); | |
240 buffer_size = item.length; | |
241 } | |
242 consolidation_.ReadMemory(i, 0, item.length, buffer.get()); | |
243 element.SetToSharedBytes(buffer.get(), item.length); | |
244 sender_->Send(new BlobHostMsg_AppendBlobDataItem(uuid_, element)); | |
245 break; | |
246 case DataElement::TYPE_FILE: | |
247 element.SetToFilePathRange( | |
248 item.path, item.offset, item.length, | |
249 base::Time::FromDoubleT(item.expected_modification_time)); | |
250 sender_->Send(new BlobHostMsg_AppendBlobDataItem(uuid_, element)); | |
251 break; | |
252 case DataElement::TYPE_BLOB: | |
253 element.SetToBlobRange(item.blob_uuid, item.offset, item.length); | |
254 sender_->Send(new BlobHostMsg_AppendBlobDataItem(uuid_, element)); | |
255 break; | |
256 case DataElement::TYPE_FILE_FILESYSTEM: | |
257 element.SetToFileSystemUrlRange( | |
258 item.filesystem_url, item.offset, item.length, | |
259 base::Time::FromDoubleT(item.expected_modification_time)); | |
260 sender_->Send(new BlobHostMsg_AppendBlobDataItem(uuid_, element)); | |
261 break; | |
262 default: | |
263 NOTREACHED(); | |
264 } | |
265 } | |
266 sender_->Send(new BlobHostMsg_FinishBuilding(uuid_, content_type_)); | |
kinuko
2015/06/25 05:04:19
Hmm ok build() sends all the IPC messages, so it m
| |
267 } | |
268 | |
269 void WebBlobRegistryImpl::BuilderImpl::SendOversizedDataForBlob( | |
270 size_t consolidated_item_index) { | |
271 TRACE_EVENT0("Blob", "Registry::SendOversizedBlobData"); | |
272 const BlobConsolidation::ConsolidatedItem& item = | |
273 consolidation_.consolidated_items()[consolidated_item_index]; | |
274 // We handle larger amounts of data via SharedMemory instead of | |
275 // writing it directly to the IPC channel. | |
276 | |
277 size_t data_size = item.length; | |
278 size_t shared_memory_size = std::min(data_size, kMaxSharedMemoryBytes); | |
279 scoped_ptr<base::SharedMemory> shared_memory( | |
280 ChildThreadImpl::AllocateSharedMemory(shared_memory_size, sender_.get())); | |
281 CHECK(shared_memory.get()); | |
282 CHECK(shared_memory->Map(shared_memory_size)); | |
kinuko
2015/06/25 05:04:19
On the second thought doing something that has sid
dmurph
2015/06/25 23:38:55
Done.
| |
283 | |
284 size_t offset = 0; | |
285 while (data_size) { | |
286 TRACE_EVENT0("Blob", "Registry::SendOversizedBlobItem"); | |
287 size_t chunk_size = std::min(data_size, shared_memory_size); | |
288 consolidation_.ReadMemory(consolidated_item_index, offset, chunk_size, | |
289 shared_memory->memory()); | |
290 sender_->Send(new BlobHostMsg_SyncAppendSharedMemory( | |
291 uuid_, shared_memory->handle(), chunk_size)); | |
292 data_size -= chunk_size; | |
293 offset += chunk_size; | |
294 } | |
295 } | |
296 | |
259 } // namespace content | 297 } // namespace content |
OLD | NEW |