| Index: content/browser/cache_storage/cache_storage_index.cc
|
| diff --git a/content/browser/cache_storage/cache_storage_index.cc b/content/browser/cache_storage/cache_storage_index.cc
|
| index 8993958aa917085989c1faf32c2db991b4446148..a5ddcb33692b53b986a8859949b64c4e3ce19730 100644
|
| --- a/content/browser/cache_storage/cache_storage_index.cc
|
| +++ b/content/browser/cache_storage/cache_storage_index.cc
|
| @@ -9,10 +9,7 @@
|
| namespace content {
|
|
|
| CacheStorageIndex::CacheStorageIndex()
|
| - : doomed_cache_metadata_("",
|
| - CacheStorage::kSizeUnknown,
|
| - CacheStorage::kSizeUnknown,
|
| - "") {
|
| + : doomed_cache_metadata_("", CacheStorage::kSizeUnknown) {
|
| ClearDoomedCache();
|
| }
|
|
|
| @@ -23,9 +20,7 @@
|
| ordered_cache_metadata_ = std::move(rhs.ordered_cache_metadata_);
|
| cache_metadata_map_ = std::move(rhs.cache_metadata_map_);
|
| storage_size_ = rhs.storage_size_;
|
| - storage_padding_ = rhs.storage_padding_;
|
| rhs.storage_size_ = CacheStorage::kSizeUnknown;
|
| - rhs.storage_padding_ = CacheStorage::kSizeUnknown;
|
| return *this;
|
| }
|
|
|
| @@ -36,7 +31,6 @@
|
| ordered_cache_metadata_.push_back(cache_metadata);
|
| cache_metadata_map_[cache_metadata.name] = --ordered_cache_metadata_.end();
|
| storage_size_ = CacheStorage::kSizeUnknown;
|
| - storage_padding_ = CacheStorage::kSizeUnknown;
|
| }
|
|
|
| void CacheStorageIndex::Delete(const std::string& cache_name) {
|
| @@ -46,7 +40,6 @@
|
| ordered_cache_metadata_.erase(it->second);
|
| cache_metadata_map_.erase(it);
|
| storage_size_ = CacheStorage::kSizeUnknown;
|
| - storage_padding_ = CacheStorage::kSizeUnknown;
|
| }
|
|
|
| bool CacheStorageIndex::SetCacheSize(const std::string& cache_name,
|
| @@ -62,53 +55,17 @@
|
| return true;
|
| }
|
|
|
| -const CacheStorageIndex::CacheMetadata* CacheStorageIndex::GetMetadata(
|
| - const std::string& cache_name) const {
|
| - const auto& it = cache_metadata_map_.find(cache_name);
|
| - if (it == cache_metadata_map_.end())
|
| - return nullptr;
|
| - return &*it->second;
|
| -}
|
| -
|
| -int64_t CacheStorageIndex::GetCacheSizeForTesting(
|
| - const std::string& cache_name) const {
|
| +int64_t CacheStorageIndex::GetCacheSize(const std::string& cache_name) const {
|
| const auto& it = cache_metadata_map_.find(cache_name);
|
| if (it == cache_metadata_map_.end())
|
| return CacheStorage::kSizeUnknown;
|
| return it->second->size;
|
| }
|
|
|
| -bool CacheStorageIndex::SetCachePadding(const std::string& cache_name,
|
| - int64_t padding) {
|
| - DCHECK(!has_doomed_cache_ || cache_name == doomed_cache_metadata_.name)
|
| - << cache_name << " != " << doomed_cache_metadata_.name;
|
| - auto it = cache_metadata_map_.find(cache_name);
|
| - DCHECK(it != cache_metadata_map_.end());
|
| - if (it->second->padding == padding)
|
| - return false;
|
| - it->second->padding = padding;
|
| - storage_padding_ = CacheStorage::kSizeUnknown;
|
| - return true;
|
| -}
|
| -
|
| -int64_t CacheStorageIndex::GetCachePaddingForTesting(
|
| - const std::string& cache_name) const {
|
| - const auto& it = cache_metadata_map_.find(cache_name);
|
| - if (it == cache_metadata_map_.end())
|
| - return CacheStorage::kSizeUnknown;
|
| - return it->second->padding;
|
| -}
|
| -
|
| -int64_t CacheStorageIndex::GetPaddedStorageSize() {
|
| +int64_t CacheStorageIndex::GetStorageSize() {
|
| if (storage_size_ == CacheStorage::kSizeUnknown)
|
| UpdateStorageSize();
|
| - if (storage_padding_ == CacheStorage::kSizeUnknown)
|
| - CalculateStoragePadding();
|
| - if (storage_size_ == CacheStorage::kSizeUnknown ||
|
| - storage_padding_ == CacheStorage::kSizeUnknown) {
|
| - return CacheStorage::kSizeUnknown;
|
| - }
|
| - return storage_size_ + storage_padding_;
|
| + return storage_size_;
|
| }
|
|
|
| void CacheStorageIndex::UpdateStorageSize() {
|
| @@ -122,17 +79,6 @@
|
| storage_size_ = storage_size;
|
| }
|
|
|
| -void CacheStorageIndex::CalculateStoragePadding() {
|
| - int64_t storage_padding = 0;
|
| - storage_padding_ = CacheStorage::kSizeUnknown;
|
| - for (const CacheMetadata& info : ordered_cache_metadata_) {
|
| - if (info.padding == CacheStorage::kSizeUnknown)
|
| - return;
|
| - storage_padding += info.padding;
|
| - }
|
| - storage_padding_ = storage_padding;
|
| -}
|
| -
|
| void CacheStorageIndex::DoomCache(const std::string& cache_name) {
|
| DCHECK(!has_doomed_cache_);
|
| auto map_it = cache_metadata_map_.find(cache_name);
|
| @@ -141,7 +87,6 @@
|
| after_doomed_cache_metadata_ = ordered_cache_metadata_.erase(map_it->second);
|
| cache_metadata_map_.erase(map_it);
|
| storage_size_ = CacheStorage::kSizeUnknown;
|
| - storage_padding_ = CacheStorage::kSizeUnknown;
|
| has_doomed_cache_ = true;
|
| }
|
|
|
| @@ -157,7 +102,6 @@
|
| after_doomed_cache_metadata_, std::move(doomed_cache_metadata_));
|
| after_doomed_cache_metadata_ = ordered_cache_metadata_.end();
|
| storage_size_ = CacheStorage::kSizeUnknown;
|
| - storage_padding_ = CacheStorage::kSizeUnknown;
|
| ClearDoomedCache();
|
| }
|
|
|
|
|