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

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

Issue 2671743002: Separate state of basic and advanced tab in CBD dialog (Closed)
Patch Set: rebase and fix compilation Created 3 years, 9 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"
11 11
12 CacheCounter::CacheResult::CacheResult(const CacheCounter* source, 12 CacheCounter::CacheResult::CacheResult(const CacheCounter* source,
13 int64_t cache_size, 13 int64_t cache_size,
14 bool is_upper_limit) 14 bool is_upper_limit)
15 : FinishedResult(source, cache_size), 15 : FinishedResult(source, cache_size),
16 cache_size_(cache_size), 16 cache_size_(cache_size),
17 is_upper_limit_(is_upper_limit) {} 17 is_upper_limit_(is_upper_limit) {}
18 18
19 CacheCounter::CacheResult::~CacheResult() {} 19 CacheCounter::CacheResult::~CacheResult() {}
20 20
21 CacheCounter::CacheCounter(Profile* profile) 21 CacheCounter::CacheCounter(Profile* profile)
22 : profile_(profile), 22 : profile_(profile),
23 weak_ptr_factory_(this) {} 23 weak_ptr_factory_(this) {}
24 24
25 CacheCounter::~CacheCounter() { 25 CacheCounter::~CacheCounter() {
26 } 26 }
27 27
28 const char* CacheCounter::GetPrefName() const { 28 const char* CacheCounter::GetPrefName() const {
29 return browsing_data::prefs::kDeleteCache; 29 return GetTab() == browsing_data::ClearBrowsingDataTab::BASIC
30 ? browsing_data::prefs::kDeleteCacheBasic
31 : browsing_data::prefs::kDeleteCache;
30 } 32 }
31 33
32 void CacheCounter::Count() { 34 void CacheCounter::Count() {
33 base::WeakPtr<browsing_data::ConditionalCacheCountingHelper> counter = 35 base::WeakPtr<browsing_data::ConditionalCacheCountingHelper> counter =
34 browsing_data::ConditionalCacheCountingHelper::CreateForRange( 36 browsing_data::ConditionalCacheCountingHelper::CreateForRange(
35 content::BrowserContext::GetDefaultStoragePartition(profile_), 37 content::BrowserContext::GetDefaultStoragePartition(profile_),
36 GetPeriodStart(), base::Time::Max()) 38 GetPeriodStart(), base::Time::Max())
37 ->CountAndDestroySelfWhenFinished( 39 ->CountAndDestroySelfWhenFinished(
38 base::Bind(&CacheCounter::OnCacheSizeCalculated, 40 base::Bind(&CacheCounter::OnCacheSizeCalculated,
39 weak_ptr_factory_.GetWeakPtr())); 41 weak_ptr_factory_.GetWeakPtr()));
40 } 42 }
41 43
42 void CacheCounter::OnCacheSizeCalculated(int64_t result_bytes, 44 void CacheCounter::OnCacheSizeCalculated(int64_t result_bytes,
43 bool is_upper_limit) { 45 bool is_upper_limit) {
44 // A value less than 0 means a net error code. 46 // A value less than 0 means a net error code.
45 if (result_bytes < 0) 47 if (result_bytes < 0)
46 return; 48 return;
47 auto result = 49 auto result =
48 base::MakeUnique<CacheResult>(this, result_bytes, is_upper_limit); 50 base::MakeUnique<CacheResult>(this, result_bytes, is_upper_limit);
49 ReportResult(std::move(result)); 51 ReportResult(std::move(result));
50 } 52 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698