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

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

Issue 16155009: Update webkit/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months 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_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 scoped_ptr<BlobDataHandle> BlobStorageContext::GetBlobDataFromUUID( 60 scoped_ptr<BlobDataHandle> BlobStorageContext::GetBlobDataFromUUID(
61 const std::string& uuid) { 61 const std::string& uuid) {
62 scoped_ptr<BlobDataHandle> result; 62 scoped_ptr<BlobDataHandle> result;
63 BlobMap::iterator found = blob_map_.find(uuid); 63 BlobMap::iterator found = blob_map_.find(uuid);
64 if (found == blob_map_.end()) 64 if (found == blob_map_.end())
65 return result.Pass(); 65 return result.Pass();
66 if (found->second.flags & EXCEEDED_MEMORY) 66 if (found->second.flags & EXCEEDED_MEMORY)
67 return result.Pass(); 67 return result.Pass();
68 DCHECK(!(found->second.flags & BEING_BUILT)); 68 DCHECK(!(found->second.flags & BEING_BUILT));
69 result.reset(new BlobDataHandle(found->second.data, this, 69 result.reset(new BlobDataHandle(
70 base::MessageLoopProxy::current())); 70 found->second.data.get(), this, base::MessageLoopProxy::current()));
71 return result.Pass(); 71 return result.Pass();
72 } 72 }
73 73
74 scoped_ptr<BlobDataHandle> BlobStorageContext::GetBlobDataFromPublicURL( 74 scoped_ptr<BlobDataHandle> BlobStorageContext::GetBlobDataFromPublicURL(
75 const GURL& url) { 75 const GURL& url) {
76 BlobURLMap::iterator found = public_blob_urls_.find( 76 BlobURLMap::iterator found = public_blob_urls_.find(
77 BlobUrlHasRef(url) ? ClearBlobUrlRef(url) : url); 77 BlobUrlHasRef(url) ? ClearBlobUrlRef(url) : url);
78 if (found == public_blob_urls_.end()) 78 if (found == public_blob_urls_.end())
79 return scoped_ptr<BlobDataHandle>(); 79 return scoped_ptr<BlobDataHandle>();
80 return GetBlobDataFromUUID(found->second); 80 return GetBlobDataFromUUID(found->second);
(...skipping 19 matching lines...) Expand all
100 } 100 }
101 101
102 void BlobStorageContext::AppendBlobDataItem( 102 void BlobStorageContext::AppendBlobDataItem(
103 const std::string& uuid, const BlobData::Item& item) { 103 const std::string& uuid, const BlobData::Item& item) {
104 DCHECK(IsBeingBuilt(uuid)); 104 DCHECK(IsBeingBuilt(uuid));
105 BlobMap::iterator found = blob_map_.find(uuid); 105 BlobMap::iterator found = blob_map_.find(uuid);
106 if (found == blob_map_.end()) 106 if (found == blob_map_.end())
107 return; 107 return;
108 if (found->second.flags & EXCEEDED_MEMORY) 108 if (found->second.flags & EXCEEDED_MEMORY)
109 return; 109 return;
110 BlobData* target_blob_data = found->second.data; 110 BlobData* target_blob_data = found->second.data.get();
111 DCHECK(target_blob_data); 111 DCHECK(target_blob_data);
112 112
113 bool exceeded_memory = false; 113 bool exceeded_memory = false;
114 114
115 // The blob data is stored in the canonical way which only contains a 115 // The blob data is stored in the canonical way which only contains a
116 // list of Data, File, and FileSystem items. Aggregated TYPE_BLOB items 116 // list of Data, File, and FileSystem items. Aggregated TYPE_BLOB items
117 // are expanded into the primitive constituent types. 117 // are expanded into the primitive constituent types.
118 // 1) The Data item is denoted by the raw data and length. 118 // 1) The Data item is denoted by the raw data and length.
119 // 2) The File item is denoted by the file path, the range and the expected 119 // 2) The File item is denoted by the file path, the range and the expected
120 // modification time. 120 // modification time.
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 void BlobStorageContext::AppendFileItem( 285 void BlobStorageContext::AppendFileItem(
286 BlobData* target_blob_data, 286 BlobData* target_blob_data,
287 const base::FilePath& file_path, uint64 offset, uint64 length, 287 const base::FilePath& file_path, uint64 offset, uint64 length,
288 const base::Time& expected_modification_time) { 288 const base::Time& expected_modification_time) {
289 target_blob_data->AppendFile(file_path, offset, length, 289 target_blob_data->AppendFile(file_path, offset, length,
290 expected_modification_time); 290 expected_modification_time);
291 291
292 // It may be a temporary file that should be deleted when no longer needed. 292 // It may be a temporary file that should be deleted when no longer needed.
293 scoped_refptr<ShareableFileReference> shareable_file = 293 scoped_refptr<ShareableFileReference> shareable_file =
294 ShareableFileReference::Get(file_path); 294 ShareableFileReference::Get(file_path);
295 if (shareable_file) 295 if (shareable_file.get())
296 target_blob_data->AttachShareableFileReference(shareable_file); 296 target_blob_data->AttachShareableFileReference(shareable_file.get());
297 } 297 }
298 298
299 void BlobStorageContext::AppendFileSystemFileItem( 299 void BlobStorageContext::AppendFileSystemFileItem(
300 BlobData* target_blob_data, 300 BlobData* target_blob_data,
301 const GURL& filesystem_url, uint64 offset, uint64 length, 301 const GURL& filesystem_url, uint64 offset, uint64 length,
302 const base::Time& expected_modification_time) { 302 const base::Time& expected_modification_time) {
303 target_blob_data->AppendFileSystemFile(filesystem_url, offset, length, 303 target_blob_data->AppendFileSystemFile(filesystem_url, offset, length,
304 expected_modification_time); 304 expected_modification_time);
305 } 305 }
306 306
307 bool BlobStorageContext::IsInUse(const std::string& uuid) { 307 bool BlobStorageContext::IsInUse(const std::string& uuid) {
308 return blob_map_.find(uuid) != blob_map_.end(); 308 return blob_map_.find(uuid) != blob_map_.end();
309 } 309 }
310 310
311 bool BlobStorageContext::IsBeingBuilt(const std::string& uuid) { 311 bool BlobStorageContext::IsBeingBuilt(const std::string& uuid) {
312 BlobMap::iterator found = blob_map_.find(uuid); 312 BlobMap::iterator found = blob_map_.find(uuid);
313 if (found == blob_map_.end()) 313 if (found == blob_map_.end())
314 return false; 314 return false;
315 return found->second.flags & BEING_BUILT; 315 return found->second.flags & BEING_BUILT;
316 } 316 }
317 317
318 bool BlobStorageContext::IsUrlRegistered(const GURL& blob_url) { 318 bool BlobStorageContext::IsUrlRegistered(const GURL& blob_url) {
319 return public_blob_urls_.find(blob_url) != public_blob_urls_.end(); 319 return public_blob_urls_.find(blob_url) != public_blob_urls_.end();
320 } 320 }
321 321
322 } // namespace webkit_blob 322 } // namespace webkit_blob
OLDNEW
« no previous file with comments | « webkit/appcache/view_appcache_internals_job.cc ('k') | webkit/browser/blob/blob_storage_context_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698