Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1025)

Unified Diff: chrome/browser/browsing_data/cache_counter.cc

Issue 2860573004: [Offline Pages] Add cached offline page utils and show usage in settings. (Closed)
Patch Set: Tests fixed. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/browsing_data/cache_counter.h ('k') | components/offline_pages/core/offline_page_types.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d131033608d252204bd70105a4bd5a213afe24b4..62b2621f4485332b7d8122f9b8d5bd4f2fc41097 100644
--- a/chrome/browser/browsing_data/cache_counter.cc
+++ b/chrome/browser/browsing_data/cache_counter.cc
@@ -9,6 +9,10 @@
#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_utils.h"
+#endif // OS_ANDROID
+
CacheCounter::CacheResult::CacheResult(const CacheCounter* source,
int64_t cache_size,
bool is_upper_limit)
@@ -43,12 +47,34 @@ void CacheCounter::Count() {
weak_ptr_factory_.GetWeakPtr()));
}
-void CacheCounter::OnCacheSizeCalculated(int64_t result_bytes,
+void CacheCounter::OnCacheSizeCalculated(int64_t cache_bytes,
dewittj 2017/05/09 01:29:54 nit: rename to OnBrowsingDataCacheSizeCalculated
romax 2017/05/09 21:08:45 Done.
bool is_upper_limit) {
// A value less than 0 means a net error code.
- if (result_bytes < 0)
+ if (cache_bytes < 0)
+ return;
dewittj 2017/05/09 01:29:53 It's not clear that we should return here anymore.
romax 2017/05/09 21:08:45 if this value is <0, it means there was an error d
+
+#if defined(OS_ANDROID)
+ if (offline_pages::OfflinePageUtils::GetCachedOfflinePageSizeBetween(
dullweber 2017/05/09 07:56:01 Could you start both cache calculations in paralle
romax 2017/05/09 21:08:45 Done. But in order to reuse the callback I changed
+ profile_,
+ 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)
dewittj 2017/05/09 01:29:53 I'd not make this android-only, and just call it w
romax 2017/05/09 21:08:45 Done.
+void CacheCounter::OnOfflinePageSizeCalculated(
+ int64_t cache_bytes,
dewittj 2017/05/09 01:29:53 rename to cached_browsing_data_bytes
romax 2017/05/09 21:08:45 Done.
+ bool is_upper_limit,
dewittj 2017/05/09 01:29:54 do we need to compute the upper limit? Why is thi
romax 2017/05/09 21:08:45 we don't need to compute it (or it can be always f
+ int64_t cached_offline_page_bytes) {
+ auto result = base::MakeUnique<CacheResult>(
+ this, cached_offline_page_bytes + cache_bytes, is_upper_limit);
ReportResult(std::move(result));
}
+#endif // OS_ANDROID
« no previous file with comments | « chrome/browser/browsing_data/cache_counter.h ('k') | components/offline_pages/core/offline_page_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698