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

Side by Side Diff: webkit/browser/blob/blob_storage_controller.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_controller.h" 5 #include "webkit/browser/blob/blob_storage_controller.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "googleurl/src/gurl.h" 8 #include "googleurl/src/gurl.h"
9 #include "webkit/common/blob/blob_data.h" 9 #include "webkit/common/blob/blob_data.h"
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 IncrementBlobDataUsage(blob_data); 47 IncrementBlobDataUsage(blob_data);
48 } 48 }
49 49
50 void BlobStorageController::AppendBlobDataItem( 50 void BlobStorageController::AppendBlobDataItem(
51 const GURL& url, const BlobData::Item& item) { 51 const GURL& url, const BlobData::Item& item) {
52 DCHECK(url.SchemeIs("blob")); 52 DCHECK(url.SchemeIs("blob"));
53 DCHECK(!BlobUrlHasRef(url)); 53 DCHECK(!BlobUrlHasRef(url));
54 BlobMap::iterator found = unfinalized_blob_map_.find(url.spec()); 54 BlobMap::iterator found = unfinalized_blob_map_.find(url.spec());
55 if (found == unfinalized_blob_map_.end()) 55 if (found == unfinalized_blob_map_.end())
56 return; 56 return;
57 BlobData* target_blob_data = found->second; 57 BlobData* target_blob_data = found->second.get();
58 DCHECK(target_blob_data); 58 DCHECK(target_blob_data);
59 59
60 memory_usage_ -= target_blob_data->GetMemoryUsage(); 60 memory_usage_ -= target_blob_data->GetMemoryUsage();
61 61
62 // The blob data is stored in the "canonical" way. That is, it only contains a 62 // The blob data is stored in the "canonical" way. That is, it only contains a
63 // list of Data and File items. 63 // list of Data and File items.
64 // 1) The Data item is denoted by the raw data and the range. 64 // 1) The Data item is denoted by the raw data and the range.
65 // 2) The File item is denoted by the file path, the range and the expected 65 // 2) The File item is denoted by the file path, the range and the expected
66 // modification time. 66 // modification time.
67 // 3) The FileSystem File item is denoted by the FileSystem URL, the range 67 // 3) The FileSystem File item is denoted by the FileSystem URL, the range
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 156
157 if (!RemoveFromMapHelper(&unfinalized_blob_map_, url)) 157 if (!RemoveFromMapHelper(&unfinalized_blob_map_, url))
158 RemoveFromMapHelper(&blob_map_, url); 158 RemoveFromMapHelper(&blob_map_, url);
159 } 159 }
160 160
161 bool BlobStorageController::RemoveFromMapHelper( 161 bool BlobStorageController::RemoveFromMapHelper(
162 BlobMap* map, const GURL& url) { 162 BlobMap* map, const GURL& url) {
163 BlobMap::iterator found = map->find(url.spec()); 163 BlobMap::iterator found = map->find(url.spec());
164 if (found == map->end()) 164 if (found == map->end())
165 return false; 165 return false;
166 if (DecrementBlobDataUsage(found->second)) 166 if (DecrementBlobDataUsage(found->second.get()))
167 memory_usage_ -= found->second->GetMemoryUsage(); 167 memory_usage_ -= found->second->GetMemoryUsage();
168 map->erase(found); 168 map->erase(found);
169 return true; 169 return true;
170 } 170 }
171 171
172 172
173 BlobData* BlobStorageController::GetBlobDataFromUrl(const GURL& url) { 173 BlobData* BlobStorageController::GetBlobDataFromUrl(const GURL& url) {
174 BlobMap::iterator found = blob_map_.find( 174 BlobMap::iterator found = blob_map_.find(
175 BlobUrlHasRef(url) ? ClearBlobUrlRef(url).spec() : url.spec()); 175 BlobUrlHasRef(url) ? ClearBlobUrlRef(url).spec() : url.spec());
176 return (found != blob_map_.end()) ? found->second : NULL; 176 return (found != blob_map_.end()) ? found->second : NULL;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 void BlobStorageController::AppendFileItem( 222 void BlobStorageController::AppendFileItem(
223 BlobData* target_blob_data, 223 BlobData* target_blob_data,
224 const base::FilePath& file_path, uint64 offset, uint64 length, 224 const base::FilePath& file_path, uint64 offset, uint64 length,
225 const base::Time& expected_modification_time) { 225 const base::Time& expected_modification_time) {
226 target_blob_data->AppendFile(file_path, offset, length, 226 target_blob_data->AppendFile(file_path, offset, length,
227 expected_modification_time); 227 expected_modification_time);
228 228
229 // It may be a temporary file that should be deleted when no longer needed. 229 // It may be a temporary file that should be deleted when no longer needed.
230 scoped_refptr<ShareableFileReference> shareable_file = 230 scoped_refptr<ShareableFileReference> shareable_file =
231 ShareableFileReference::Get(file_path); 231 ShareableFileReference::Get(file_path);
232 if (shareable_file) 232 if (shareable_file.get())
233 target_blob_data->AttachShareableFileReference(shareable_file); 233 target_blob_data->AttachShareableFileReference(shareable_file.get());
234 } 234 }
235 235
236 void BlobStorageController::AppendFileSystemFileItem( 236 void BlobStorageController::AppendFileSystemFileItem(
237 BlobData* target_blob_data, 237 BlobData* target_blob_data,
238 const GURL& url, uint64 offset, uint64 length, 238 const GURL& url, uint64 offset, uint64 length,
239 const base::Time& expected_modification_time) { 239 const base::Time& expected_modification_time) {
240 target_blob_data->AppendFileSystemFile(url, offset, length, 240 target_blob_data->AppendFileSystemFile(url, offset, length,
241 expected_modification_time); 241 expected_modification_time);
242 } 242 }
243 243
244 void BlobStorageController::IncrementBlobDataUsage(BlobData* blob_data) { 244 void BlobStorageController::IncrementBlobDataUsage(BlobData* blob_data) {
245 blob_data_usage_count_[blob_data] += 1; 245 blob_data_usage_count_[blob_data] += 1;
246 } 246 }
247 247
248 bool BlobStorageController::DecrementBlobDataUsage(BlobData* blob_data) { 248 bool BlobStorageController::DecrementBlobDataUsage(BlobData* blob_data) {
249 BlobDataUsageMap::iterator found = blob_data_usage_count_.find(blob_data); 249 BlobDataUsageMap::iterator found = blob_data_usage_count_.find(blob_data);
250 DCHECK(found != blob_data_usage_count_.end()); 250 DCHECK(found != blob_data_usage_count_.end());
251 if (--(found->second)) 251 if (--(found->second))
252 return false; // Still in use 252 return false; // Still in use
253 blob_data_usage_count_.erase(found); 253 blob_data_usage_count_.erase(found);
254 return true; 254 return true;
255 } 255 }
256 256
257 } // namespace webkit_blob 257 } // namespace webkit_blob
OLDNEW
« no previous file with comments | « webkit/browser/blob/blob_storage_context_unittest.cc ('k') | webkit/browser/blob/blob_storage_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698