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

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

Issue 2153863002: Move counters for passwords, history and autofill to components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@separate_build_targets_in_components_bd
Patch Set: Fixed dependencies Created 4 years, 5 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/storage_partition_http_cache_data_rem over.h" 7 #include "components/browsing_data/content/storage_partition_http_cache_data_rem over.h"
8 #include "components/browsing_data/core/pref_names.h" 8 #include "components/browsing_data/core/pref_names.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 10
11 CacheCounter::CacheCounter(Profile* profile) 11 CacheCounter::CacheCounter(Profile* profile)
12 : BrowsingDataCounter(browsing_data::prefs::kDeleteCache), 12 : pref_name_(browsing_data::prefs::kDeleteCache),
13 profile_(profile), 13 profile_(profile),
14 pending_(false), 14 pending_(false),
15 weak_ptr_factory_(this) {} 15 weak_ptr_factory_(this) {}
16 16
17 CacheCounter::~CacheCounter() { 17 CacheCounter::~CacheCounter() {
18 } 18 }
19 19
20 const std::string& CacheCounter::GetPrefName() const {
21 return pref_name_;
22 }
23
20 void CacheCounter::Count() { 24 void CacheCounter::Count() {
21 // TODO(msramek): StoragePartitionHttpCacheDataRemover currently does not 25 // TODO(msramek): StoragePartitionHttpCacheDataRemover currently does not
22 // implement counting for subsets of cache, only for the entire cache. Thus, 26 // implement counting for subsets of cache, only for the entire cache. Thus,
23 // we ignore the time period setting and always request counting for 27 // we ignore the time period setting and always request counting for
24 // the unbounded time interval. It is up to the UI to interpret the results 28 // the unbounded time interval. It is up to the UI to interpret the results
25 // for finite time intervals as upper estimates. 29 // for finite time intervals as upper estimates.
26 browsing_data::StoragePartitionHttpCacheDataRemover::CreateForRange( 30 browsing_data::StoragePartitionHttpCacheDataRemover::CreateForRange(
27 content::BrowserContext::GetDefaultStoragePartition(profile_), 31 content::BrowserContext::GetDefaultStoragePartition(profile_),
28 base::Time(), base::Time::Max()) 32 base::Time(), base::Time::Max())
29 ->Count(base::Bind(&CacheCounter::OnCacheSizeCalculated, 33 ->Count(base::Bind(&CacheCounter::OnCacheSizeCalculated,
30 weak_ptr_factory_.GetWeakPtr())); 34 weak_ptr_factory_.GetWeakPtr()));
31 pending_ = true; 35 pending_ = true;
32 } 36 }
33 37
34 void CacheCounter::OnCacheSizeCalculated(int64_t result_bytes) { 38 void CacheCounter::OnCacheSizeCalculated(int64_t result_bytes) {
35 pending_ = false; 39 pending_ = false;
36 40
37 // A value less than 0 means a net error code. 41 // A value less than 0 means a net error code.
38 if (result_bytes < 0) 42 if (result_bytes < 0)
39 return; 43 return;
40 44
41 ReportResult(result_bytes); 45 ReportResult(result_bytes);
42 } 46 }
43 47
44 bool CacheCounter::Pending() { 48 bool CacheCounter::Pending() {
45 return pending_; 49 return pending_;
46 } 50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698