| 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/blob/blob_storage_controller.h" | 5 #include "webkit/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 "net/base/upload_data.h" | 9 #include "net/base/upload_data.h" |
| 10 #include "webkit/blob/blob_data.h" | 10 #include "webkit/blob/blob_data.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 BlobData* BlobStorageController::GetBlobDataFromUrl(const GURL& url) { | 166 BlobData* BlobStorageController::GetBlobDataFromUrl(const GURL& url) { |
| 167 BlobMap::iterator found = blob_map_.find( | 167 BlobMap::iterator found = blob_map_.find( |
| 168 BlobUrlHasRef(url) ? ClearBlobUrlRef(url).spec() : url.spec()); | 168 BlobUrlHasRef(url) ? ClearBlobUrlRef(url).spec() : url.spec()); |
| 169 return (found != blob_map_.end()) ? found->second : NULL; | 169 return (found != blob_map_.end()) ? found->second : NULL; |
| 170 } | 170 } |
| 171 | 171 |
| 172 void BlobStorageController::ResolveBlobReferencesInUploadData( | 172 void BlobStorageController::ResolveBlobReferencesInUploadData( |
| 173 net::UploadData* upload_data) { | 173 net::UploadData* upload_data) { |
| 174 DCHECK(upload_data); | 174 DCHECK(upload_data); |
| 175 | 175 |
| 176 std::vector<net::UploadData::Element>* uploads = upload_data->elements(); | 176 std::vector<net::UploadData::Element>* uploads = |
| 177 upload_data->elements_mutable(); |
| 177 std::vector<net::UploadData::Element>::iterator iter; | 178 std::vector<net::UploadData::Element>::iterator iter; |
| 178 for (iter = uploads->begin(); iter != uploads->end();) { | 179 for (iter = uploads->begin(); iter != uploads->end();) { |
| 179 if (iter->type() != net::UploadData::TYPE_BLOB) { | 180 if (iter->type() != net::UploadData::TYPE_BLOB) { |
| 180 iter++; | 181 iter++; |
| 181 continue; | 182 continue; |
| 182 } | 183 } |
| 183 | 184 |
| 184 // Find the referred blob data. | 185 // Find the referred blob data. |
| 185 BlobData* blob_data = GetBlobDataFromUrl(iter->blob_url()); | 186 BlobData* blob_data = GetBlobDataFromUrl(iter->blob_url()); |
| 186 DCHECK(blob_data); | 187 DCHECK(blob_data); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 bool BlobStorageController::DecrementBlobDataUsage(BlobData* blob_data) { | 294 bool BlobStorageController::DecrementBlobDataUsage(BlobData* blob_data) { |
| 294 BlobDataUsageMap::iterator found = blob_data_usage_count_.find(blob_data); | 295 BlobDataUsageMap::iterator found = blob_data_usage_count_.find(blob_data); |
| 295 DCHECK(found != blob_data_usage_count_.end()); | 296 DCHECK(found != blob_data_usage_count_.end()); |
| 296 if (--(found->second)) | 297 if (--(found->second)) |
| 297 return false; // Still in use | 298 return false; // Still in use |
| 298 blob_data_usage_count_.erase(found); | 299 blob_data_usage_count_.erase(found); |
| 299 return true; | 300 return true; |
| 300 } | 301 } |
| 301 | 302 |
| 302 } // namespace webkit_blob | 303 } // namespace webkit_blob |
| OLD | NEW |