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

Side by Side Diff: chrome/browser/browsing_data/cache_counter.cc

Issue 2626223002: Show the exact cache size for time ranges if supported (Closed)
Patch Set: fix chromeos build Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/browsing_data/cache_counter.h" 5 #include "chrome/browser/browsing_data/cache_counter.h"
6 #include "chrome/browser/profiles/profile.h" 6 #include "chrome/browser/profiles/profile.h"
7 #include "components/browsing_data/content/conditional_cache_counting_helper.h" 7 #include "components/browsing_data/content/conditional_cache_counting_helper.h"
8 #include "components/browsing_data/core/pref_names.h" 8 #include "components/browsing_data/core/pref_names.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 13 matching lines...) Expand all
24 weak_ptr_factory_(this) {} 24 weak_ptr_factory_(this) {}
25 25
26 CacheCounter::~CacheCounter() { 26 CacheCounter::~CacheCounter() {
27 } 27 }
28 28
29 const char* CacheCounter::GetPrefName() const { 29 const char* CacheCounter::GetPrefName() const {
30 return browsing_data::prefs::kDeleteCache; 30 return browsing_data::prefs::kDeleteCache;
31 } 31 }
32 32
33 void CacheCounter::Count() { 33 void CacheCounter::Count() {
34 bool is_upper_limit = !GetPeriodStart().is_null();
35 base::WeakPtr<browsing_data::ConditionalCacheCountingHelper> counter = 34 base::WeakPtr<browsing_data::ConditionalCacheCountingHelper> counter =
36 browsing_data::ConditionalCacheCountingHelper::CreateForRange( 35 browsing_data::ConditionalCacheCountingHelper::CreateForRange(
37 content::BrowserContext::GetDefaultStoragePartition(profile_), 36 content::BrowserContext::GetDefaultStoragePartition(profile_),
38 base::Time(), base::Time::Max()) 37 GetPeriodStart(), base::Time::Max())
39 ->CountAndDestroySelfWhenFinished( 38 ->CountAndDestroySelfWhenFinished(
40 base::Bind(&CacheCounter::OnCacheSizeCalculated, 39 base::Bind(&CacheCounter::OnCacheSizeCalculated,
41 weak_ptr_factory_.GetWeakPtr(), is_upper_limit)); 40 weak_ptr_factory_.GetWeakPtr()));
42 pending_ = true; 41 pending_ = true;
43 } 42 }
44 43
45 void CacheCounter::OnCacheSizeCalculated(bool is_upper_limit, 44 void CacheCounter::OnCacheSizeCalculated(int64_t result_bytes,
46 int64_t result_bytes) { 45 bool is_upper_limit) {
47 pending_ = false; 46 pending_ = false;
48 47
49 // A value less than 0 means a net error code. 48 // A value less than 0 means a net error code.
50 if (result_bytes < 0) 49 if (result_bytes < 0)
51 return; 50 return;
52 auto result = 51 auto result =
53 base::MakeUnique<CacheResult>(this, result_bytes, is_upper_limit); 52 base::MakeUnique<CacheResult>(this, result_bytes, is_upper_limit);
54 ReportResult(std::move(result)); 53 ReportResult(std::move(result));
55 } 54 }
56 55
57 bool CacheCounter::Pending() { 56 bool CacheCounter::Pending() {
58 return pending_; 57 return pending_;
59 } 58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698