| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 IOS_CHROME_BROWSER_BROWSING_DATA_CACHE_COUNTER_H_ | 5 #ifndef IOS_CHROME_BROWSER_BROWSING_DATA_CACHE_COUNTER_H_ |
| 6 #define IOS_CHROME_BROWSER_BROWSING_DATA_CACHE_COUNTER_H_ | 6 #define IOS_CHROME_BROWSER_BROWSING_DATA_CACHE_COUNTER_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "components/browsing_data/core/counters/browsing_data_counter.h" | 9 #include "components/browsing_data/core/counters/browsing_data_counter.h" |
| 10 | 10 |
| 11 namespace web { | 11 namespace web { |
| 12 class BrowserState; | 12 class BrowserState; |
| 13 } | 13 } |
| 14 | 14 |
| 15 class CacheCounter : public browsing_data::BrowsingDataCounter { | 15 class CacheCounter : public browsing_data::BrowsingDataCounter { |
| 16 public: | 16 public: |
| 17 explicit CacheCounter(web::BrowserState* browser_state); | 17 explicit CacheCounter(web::BrowserState* browser_state); |
| 18 ~CacheCounter() override; | 18 ~CacheCounter() override; |
| 19 | 19 |
| 20 // Whether this counter awaits the calculation result callback. | |
| 21 // Used only for testing. | |
| 22 bool pending() { return pending_; } | |
| 23 | |
| 24 // BrowsingDataCounter implementation. | 20 // BrowsingDataCounter implementation. |
| 25 const char* GetPrefName() const override; | 21 const char* GetPrefName() const override; |
| 26 | 22 |
| 27 private: | 23 private: |
| 28 // BrowsingDataCounter implementation. | 24 // BrowsingDataCounter implementation. |
| 29 void Count() override; | 25 void Count() override; |
| 30 | 26 |
| 31 void OnCacheSizeCalculated(int result_bytes); | 27 void OnCacheSizeCalculated(int result_bytes); |
| 32 | 28 |
| 33 bool pending_; | |
| 34 | |
| 35 web::BrowserState* browser_state_; | 29 web::BrowserState* browser_state_; |
| 36 | 30 |
| 37 base::WeakPtrFactory<CacheCounter> weak_ptr_factory_; | 31 base::WeakPtrFactory<CacheCounter> weak_ptr_factory_; |
| 38 }; | 32 }; |
| 39 | 33 |
| 40 #endif // IOS_CHROME_BROWSER_BROWSING_DATA_CACHE_COUNTER_H_ | 34 #endif // IOS_CHROME_BROWSER_BROWSING_DATA_CACHE_COUNTER_H_ |
| OLD | NEW |