OLD | NEW |
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 #ifndef CHROME_BROWSER_BROWSING_DATA_CACHE_COUNTER_H_ | 5 #ifndef CHROME_BROWSER_BROWSING_DATA_CACHE_COUNTER_H_ |
6 #define CHROME_BROWSER_BROWSING_DATA_CACHE_COUNTER_H_ | 6 #define CHROME_BROWSER_BROWSING_DATA_CACHE_COUNTER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "components/browsing_data/core/counters/browsing_data_counter.h" | 11 #include "components/browsing_data/core/counters/browsing_data_counter.h" |
12 | 12 |
13 class Profile; | 13 class Profile; |
14 | 14 |
| 15 namespace browsing_data { |
| 16 class ConditionalCacheCountingHelper; |
| 17 } |
| 18 |
15 class CacheCounter : public browsing_data::BrowsingDataCounter { | 19 class CacheCounter : public browsing_data::BrowsingDataCounter { |
16 public: | 20 public: |
| 21 class CacheResult : public FinishedResult { |
| 22 public: |
| 23 CacheResult(const CacheCounter* source, |
| 24 int64_t cache_size, |
| 25 bool is_upper_limit); |
| 26 ~CacheResult() override; |
| 27 |
| 28 int64_t cache_size() const { return cache_size_; } |
| 29 bool is_upper_limit() const { return is_upper_limit_; } |
| 30 |
| 31 private: |
| 32 int64_t cache_size_; |
| 33 bool is_upper_limit_; |
| 34 |
| 35 DISALLOW_COPY_AND_ASSIGN(CacheResult); |
| 36 }; |
| 37 |
17 explicit CacheCounter(Profile* profile); | 38 explicit CacheCounter(Profile* profile); |
18 ~CacheCounter() override; | 39 ~CacheCounter() override; |
19 | 40 |
| 41 const char* GetPrefName() const override; |
| 42 |
20 // Whether this counter awaits the calculation result callback. | 43 // Whether this counter awaits the calculation result callback. |
21 // Used only for testing. | 44 // Used only for testing. |
22 bool Pending(); | 45 bool Pending(); |
23 | 46 |
24 const char* GetPrefName() const override; | 47 private: |
| 48 void Count() override; |
| 49 void OnCacheSizeCalculated(bool is_upper_limit, int64_t bytes); |
| 50 void FetchEstimate( |
| 51 base::WeakPtr<browsing_data::ConditionalCacheCountingHelper>); |
25 | 52 |
26 private: | |
27 Profile* profile_; | 53 Profile* profile_; |
28 bool pending_; | 54 bool pending_; |
29 | 55 |
30 base::WeakPtrFactory<CacheCounter> weak_ptr_factory_; | 56 base::WeakPtrFactory<CacheCounter> weak_ptr_factory_; |
31 | 57 |
32 void Count() override; | |
33 void OnCacheSizeCalculated(int64_t bytes); | |
34 }; | 58 }; |
35 | 59 |
36 #endif // CHROME_BROWSER_BROWSING_DATA_CACHE_COUNTER_H_ | 60 #endif // CHROME_BROWSER_BROWSING_DATA_CACHE_COUNTER_H_ |
OLD | NEW |