Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(945)

Side by Side Diff: webkit/browser/blob/blob_storage_context.cc

Issue 46303005: Fix chrome upload with content uri (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "webkit/browser/blob/blob_storage_context.h" 5 #include "webkit/browser/blob/blob_storage_context.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 break; 167 break;
168 case BlobData::Item::TYPE_BLOB: { 168 case BlobData::Item::TYPE_BLOB: {
169 scoped_ptr<BlobDataHandle> src = GetBlobDataFromUUID(item.blob_uuid()); 169 scoped_ptr<BlobDataHandle> src = GetBlobDataFromUUID(item.blob_uuid());
170 if (src) 170 if (src)
171 exceeded_memory = !ExpandStorageItems(target_blob_data, 171 exceeded_memory = !ExpandStorageItems(target_blob_data,
172 src->data(), 172 src->data(),
173 item.offset(), 173 item.offset(),
174 item.length()); 174 item.length());
175 break; 175 break;
176 } 176 }
177 #if defined(OS_ANDROID)
178 case BlobData::Item::TYPE_CONTENT_URL:
179 AppendContentUrlItem(target_blob_data,
180 item.content_url(),
181 item.offset(),
182 item.length(),
183 item.expected_modification_time());
184 break;
185 #endif
177 default: 186 default:
178 NOTREACHED(); 187 NOTREACHED();
179 break; 188 break;
180 } 189 }
181 190
182 // If we're using too much memory, drop this blob's data. 191 // If we're using too much memory, drop this blob's data.
183 // TODO(michaeln): Blob memory storage does not yet spill over to disk, 192 // TODO(michaeln): Blob memory storage does not yet spill over to disk,
184 // as a stop gap, we'll prevent memory usage over a max amount. 193 // as a stop gap, we'll prevent memory usage over a max amount.
185 if (exceeded_memory) { 194 if (exceeded_memory) {
186 memory_usage_ -= target_blob_data->GetMemoryUsage(); 195 memory_usage_ -= target_blob_data->GetMemoryUsage();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 iter->bytes() + static_cast<size_t>(iter->offset() + offset), 260 iter->bytes() + static_cast<size_t>(iter->offset() + offset),
252 static_cast<int64>(new_length))) { 261 static_cast<int64>(new_length))) {
253 return false; // exceeded memory 262 return false; // exceeded memory
254 } 263 }
255 } else if (iter->type() == BlobData::Item::TYPE_FILE) { 264 } else if (iter->type() == BlobData::Item::TYPE_FILE) {
256 AppendFileItem(target_blob_data, 265 AppendFileItem(target_blob_data,
257 iter->path(), 266 iter->path(),
258 iter->offset() + offset, 267 iter->offset() + offset,
259 new_length, 268 new_length,
260 iter->expected_modification_time()); 269 iter->expected_modification_time());
270 #if defined(OS_ANDROID)
271 } else if (iter->type() == BlobData::Item::TYPE_CONTENT_URL) {
272 AppendContentUrlItem(target_blob_data,
273 iter->content_url(),
274 iter->offset() + offset,
275 new_length,
276 iter->expected_modification_time());
277 #endif
261 } else { 278 } else {
262 DCHECK(iter->type() == BlobData::Item::TYPE_FILE_FILESYSTEM); 279 DCHECK(iter->type() == BlobData::Item::TYPE_FILE_FILESYSTEM);
263 AppendFileSystemFileItem(target_blob_data, 280 AppendFileSystemFileItem(target_blob_data,
264 iter->filesystem_url(), 281 iter->filesystem_url(),
265 iter->offset() + offset, 282 iter->offset() + offset,
266 new_length, 283 new_length,
267 iter->expected_modification_time()); 284 iter->expected_modification_time());
268 } 285 }
269 length -= new_length; 286 length -= new_length;
270 offset = 0; 287 offset = 0;
(...skipping 29 matching lines...) Expand all
300 } 317 }
301 318
302 void BlobStorageContext::AppendFileSystemFileItem( 319 void BlobStorageContext::AppendFileSystemFileItem(
303 BlobData* target_blob_data, 320 BlobData* target_blob_data,
304 const GURL& filesystem_url, uint64 offset, uint64 length, 321 const GURL& filesystem_url, uint64 offset, uint64 length,
305 const base::Time& expected_modification_time) { 322 const base::Time& expected_modification_time) {
306 target_blob_data->AppendFileSystemFile(filesystem_url, offset, length, 323 target_blob_data->AppendFileSystemFile(filesystem_url, offset, length,
307 expected_modification_time); 324 expected_modification_time);
308 } 325 }
309 326
327 #if defined(OS_ANDROID)
328 void BlobStorageContext::AppendContentUrlItem(
329 BlobData* target_blob_data,
330 const GURL& content_url, uint64 offset, uint64 length,
331 const base::Time& expected_modification_time) {
332 target_blob_data->AppendContentUrlFile(content_url, offset, length,
333 expected_modification_time);
334 }
335 #endif
336
310 bool BlobStorageContext::IsInUse(const std::string& uuid) { 337 bool BlobStorageContext::IsInUse(const std::string& uuid) {
311 return blob_map_.find(uuid) != blob_map_.end(); 338 return blob_map_.find(uuid) != blob_map_.end();
312 } 339 }
313 340
314 bool BlobStorageContext::IsBeingBuilt(const std::string& uuid) { 341 bool BlobStorageContext::IsBeingBuilt(const std::string& uuid) {
315 BlobMap::iterator found = blob_map_.find(uuid); 342 BlobMap::iterator found = blob_map_.find(uuid);
316 if (found == blob_map_.end()) 343 if (found == blob_map_.end())
317 return false; 344 return false;
318 return found->second.flags & BEING_BUILT; 345 return found->second.flags & BEING_BUILT;
319 } 346 }
320 347
321 bool BlobStorageContext::IsUrlRegistered(const GURL& blob_url) { 348 bool BlobStorageContext::IsUrlRegistered(const GURL& blob_url) {
322 return public_blob_urls_.find(blob_url) != public_blob_urls_.end(); 349 return public_blob_urls_.find(blob_url) != public_blob_urls_.end();
323 } 350 }
324 351
325 } // namespace webkit_blob 352 } // namespace webkit_blob
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698