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

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

Issue 2556363003: Refactor cache counting into a separate helper class (Closed)
Patch Set: cleanup Created 4 years 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
Index: chrome/browser/browsing_data/browsing_data_counter_utils.cc
diff --git a/chrome/browser/browsing_data/browsing_data_counter_utils.cc b/chrome/browser/browsing_data/browsing_data_counter_utils.cc
index 6aa25a91c4dde9b5b2c74984cfea03c47526017b..c28cceaf1e829e9086bc8a0faf6fdc48feb31ff7 100644
--- a/chrome/browser/browsing_data/browsing_data_counter_utils.cc
+++ b/chrome/browser/browsing_data/browsing_data_counter_utils.cc
@@ -63,22 +63,17 @@ base::string16 GetChromeCounterTextFromResult(
if (pref_name == browsing_data::prefs::kDeleteCache) {
// Cache counter.
- browsing_data::BrowsingDataCounter::ResultInt cache_size_bytes =
- static_cast<const browsing_data::BrowsingDataCounter::FinishedResult*>(
- result)
- ->Value();
-
- PrefService* prefs = result->source()->GetPrefs();
- browsing_data::TimePeriod time_period =
- static_cast<browsing_data::TimePeriod>(
- prefs->GetInteger(browsing_data::prefs::kDeleteTimePeriod));
+ const auto* cache_result =
+ static_cast<const CacheCounter::CacheResult*>(result);
+ int64_t cache_size_bytes = cache_result->cache_size();
+ bool is_upper_limit = cache_result->is_upper_limit();
// Three cases: Nonzero result for the entire cache, nonzero result for
// a subset of cache (i.e. a finite time interval), and almost zero (< 1MB).
static const int kBytesInAMegabyte = 1024 * 1024;
if (cache_size_bytes >= kBytesInAMegabyte) {
base::string16 formatted_size = FormatBytesMBOrHigher(cache_size_bytes);
- return time_period == browsing_data::ALL_TIME
+ return !is_upper_limit
? formatted_size
: l10n_util::GetStringFUTF16(
IDS_DEL_CACHE_COUNTER_UPPER_ESTIMATE, formatted_size);
« no previous file with comments | « no previous file | chrome/browser/browsing_data/cache_counter.h » ('j') | chrome/browser/browsing_data/cache_counter.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698