summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chromium/content/browser/cache_storage/legacy/legacy_cache_storage.cc13
-rw-r--r--chromium/content/browser/cache_storage/legacy/legacy_cache_storage_cache.h8
2 files changed, 14 insertions, 7 deletions
diff --git a/chromium/content/browser/cache_storage/legacy/legacy_cache_storage.cc b/chromium/content/browser/cache_storage/legacy/legacy_cache_storage.cc
index 6915a3b34cf..28a928b65f6 100644
--- a/chromium/content/browser/cache_storage/legacy/legacy_cache_storage.cc
+++ b/chromium/content/browser/cache_storage/legacy/legacy_cache_storage.cc
@@ -1380,9 +1380,11 @@ void LegacyCacheStorage::SizeRetrievedFromCache(
int64_t* accumulator,
int64_t size) {
auto* impl = LegacyCacheStorageCache::From(cache_handle);
- if (doomed_caches_.find(impl) == doomed_caches_.end())
- cache_index_->SetCacheSize(impl->cache_name(), size);
- *accumulator += size;
+ if (doomed_caches_.find(impl) == doomed_caches_.end()) {
+ cache_index_->SetCacheSize(impl->cache_name(), impl->cache_size());
+ cache_index_->SetCachePadding(impl->cache_name(), impl->cache_padding());
+ }
+ *accumulator += (impl->cache_size() + impl->cache_padding());
std::move(closure).Run();
}
@@ -1435,8 +1437,9 @@ void LegacyCacheStorage::SizeImpl(SizeCallback callback) {
std::move(callback)));
for (const auto& cache_metadata : cache_index_->ordered_cache_metadata()) {
- if (cache_metadata.size != LegacyCacheStorage::kSizeUnknown) {
- *accumulator_ptr += cache_metadata.size;
+ if (cache_metadata.size != LegacyCacheStorage::kSizeUnknown &&
+ cache_metadata.padding != LegacyCacheStorage::kSizeUnknown) {
+ *accumulator_ptr += (cache_metadata.size + cache_metadata.padding);
barrier_closure.Run();
continue;
}
diff --git a/chromium/content/browser/cache_storage/legacy/legacy_cache_storage_cache.h b/chromium/content/browser/cache_storage/legacy/legacy_cache_storage_cache.h
index a2b541a5293..099b9c49e36 100644
--- a/chromium/content/browser/cache_storage/legacy/legacy_cache_storage_cache.h
+++ b/chromium/content/browser/cache_storage/legacy/legacy_cache_storage_cache.h
@@ -147,11 +147,15 @@ class CONTENT_EXPORT LegacyCacheStorageCache : public CacheStorageCache {
// will exit early. Close should only be called once per CacheStorageCache.
void Close(base::OnceClosure callback);
- // The size of the cache's contents.
+ // The size of the cache's contents. The callback reports the padded
+ // size. If you want the unpadded size you may call the cache_size()
+ // getter method on the cache object when the callback is invoked; the
+ // getter will have an up-to-date value at that point.
void Size(SizeCallback callback);
// Gets the cache's size, closes the backend, and then runs |callback| with
- // the cache's size.
+ // the cache's size. As per the comment for Size(), this also returns the
+ // padded size.
void GetSizeThenClose(SizeCallback callback);
void Put(blink::mojom::FetchAPIRequestPtr request,