Index: chrome/browser/browsing_data/cache_counter.cc |
diff --git a/chrome/browser/browsing_data/cache_counter.cc b/chrome/browser/browsing_data/cache_counter.cc |
index 557be8a39e14d9b52d2036af2657d79b13c30017..7654eeb2babc2423d8ec6ecdb6477c37c80e4159 100644 |
--- a/chrome/browser/browsing_data/cache_counter.cc |
+++ b/chrome/browser/browsing_data/cache_counter.cc |
@@ -9,6 +9,11 @@ |
#include "content/public/browser/browser_thread.h" |
#include "net/base/net_errors.h" |
+#if defined(OS_ANDROID) |
+#include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
+#include "components/offline_pages/core/cached_offline_page_utils.h" |
+#endif // OS_ANDROID |
+ |
CacheCounter::CacheResult::CacheResult(const CacheCounter* source, |
int64_t cache_size, |
bool is_upper_limit) |
@@ -41,12 +46,36 @@ void CacheCounter::Count() { |
weak_ptr_factory_.GetWeakPtr())); |
} |
-void CacheCounter::OnCacheSizeCalculated(int64_t result_bytes, |
+void CacheCounter::OnCacheSizeCalculated(int64_t cache_bytes, |
bool is_upper_limit) { |
// A value less than 0 means a net error code. |
- if (result_bytes < 0) |
+ if (cache_bytes < 0) |
+ return; |
+ |
+#if defined(OS_ANDROID) |
+ offline_pages::OfflinePageModel* offline_page_model = |
+ offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile_); |
+ if (offline_page_model) { |
+ offline_pages::CachedOfflinePageUtils::GetCachedOfflinePageSizeBetween( |
+ offline_page_model, |
+ base::Bind(&CacheCounter::OnOfflinePageSizeCalculated, |
+ weak_ptr_factory_.GetWeakPtr(), cache_bytes, is_upper_limit), |
+ GetPeriodStart(), base::Time::Max()); |
return; |
+ } |
+#endif // OS_ANDROID |
auto result = |
- base::MakeUnique<CacheResult>(this, result_bytes, is_upper_limit); |
+ base::MakeUnique<CacheResult>(this, cache_bytes, is_upper_limit); |
+ ReportResult(std::move(result)); |
+} |
+ |
+#if defined(OS_ANDROID) |
+void CacheCounter::OnOfflinePageSizeCalculated( |
+ int64_t cache_bytes, |
+ bool is_upper_limit, |
+ int64_t cached_offline_page_bytes) { |
+ auto result = base::MakeUnique<CacheResult>( |
+ this, offline_page_cache_bytes + cache_bytes, is_upper_limit); |
ReportResult(std::move(result)); |
} |
+#endif // OS_ANDROID |