| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 memory_usage_ -= target_blob_data->GetMemoryUsage(); | 61 memory_usage_ -= target_blob_data->GetMemoryUsage(); |
| 62 | 62 |
| 63 // The blob data is stored in the "canonical" way. That is, it only contains a | 63 // The blob data is stored in the "canonical" way. That is, it only contains a |
| 64 // list of Data and File items. | 64 // list of Data and File items. |
| 65 // 1) The Data item is denoted by the raw data and the range. | 65 // 1) The Data item is denoted by the raw data and the range. |
| 66 // 2) The File item is denoted by the file path, the range and the expected | 66 // 2) The File item is denoted by the file path, the range and the expected |
| 67 // modification time. | 67 // modification time. |
| 68 // All the Blob items in the passing blob data are resolved and expanded into | 68 // All the Blob items in the passing blob data are resolved and expanded into |
| 69 // a set of Data and File items. | 69 // a set of Data and File items. |
| 70 | 70 |
| 71 DCHECK(item.length > 0); | |
| 72 switch (item.type) { | 71 switch (item.type) { |
| 73 case BlobData::TYPE_DATA: | 72 case BlobData::TYPE_DATA: |
| 74 // WebBlobData does not allow partial data. | 73 // WebBlobData does not allow partial data. |
| 75 DCHECK(!(item.offset) && item.length == item.data.size()); | 74 DCHECK(!(item.offset) && item.length == item.data.size()); |
| 76 target_blob_data->AppendData(item.data.c_str(), item.data.size()); | 75 target_blob_data->AppendData(item.data.c_str(), item.data.size()); |
| 77 break; | 76 break; |
| 78 case BlobData::TYPE_DATA_EXTERNAL: | 77 case BlobData::TYPE_DATA_EXTERNAL: |
| 79 DCHECK(!item.offset); | 78 DCHECK(!item.offset); |
| 80 target_blob_data->AppendData(item.data_external, item.length); | 79 target_blob_data->AppendData(item.data_external, item.length); |
| 81 break; | 80 break; |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 bool BlobStorageController::DecrementBlobDataUsage(BlobData* blob_data) { | 292 bool BlobStorageController::DecrementBlobDataUsage(BlobData* blob_data) { |
| 294 BlobDataUsageMap::iterator found = blob_data_usage_count_.find(blob_data); | 293 BlobDataUsageMap::iterator found = blob_data_usage_count_.find(blob_data); |
| 295 DCHECK(found != blob_data_usage_count_.end()); | 294 DCHECK(found != blob_data_usage_count_.end()); |
| 296 if (--(found->second)) | 295 if (--(found->second)) |
| 297 return false; // Still in use | 296 return false; // Still in use |
| 298 blob_data_usage_count_.erase(found); | 297 blob_data_usage_count_.erase(found); |
| 299 return true; | 298 return true; |
| 300 } | 299 } |
| 301 | 300 |
| 302 } // namespace webkit_blob | 301 } // namespace webkit_blob |
| OLD | NEW |