OLD | NEW |
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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 if (DecrementBlobDataUsage(found->second.get())) | 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.get() : NULL; |
177 } | 177 } |
178 | 178 |
179 void BlobStorageController::AppendStorageItems( | 179 void BlobStorageController::AppendStorageItems( |
180 BlobData* target_blob_data, BlobData* src_blob_data, | 180 BlobData* target_blob_data, BlobData* src_blob_data, |
181 uint64 offset, uint64 length) { | 181 uint64 offset, uint64 length) { |
182 DCHECK(target_blob_data && src_blob_data && | 182 DCHECK(target_blob_data && src_blob_data && |
183 length != static_cast<uint64>(-1)); | 183 length != static_cast<uint64>(-1)); |
184 | 184 |
185 std::vector<BlobData::Item>::const_iterator iter = | 185 std::vector<BlobData::Item>::const_iterator iter = |
186 src_blob_data->items().begin(); | 186 src_blob_data->items().begin(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |