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_BROWSING_DATA_COUNTER_H_ | 5 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COUNTER_H_ |
6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COUNTER_H_ | 6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COUNTER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 // Should be called once to initialize this class. | 22 // Should be called once to initialize this class. |
23 void Init(Profile* profile, | 23 void Init(Profile* profile, |
24 const Callback& callback); | 24 const Callback& callback); |
25 | 25 |
26 // Name of the preference associated with this counter. | 26 // Name of the preference associated with this counter. |
27 virtual const std::string& GetPrefName() const = 0; | 27 virtual const std::string& GetPrefName() const = 0; |
28 | 28 |
29 // The profile associated with this counter. | 29 // The profile associated with this counter. |
30 Profile* GetProfile() const; | 30 Profile* GetProfile() const; |
31 | 31 |
| 32 // Restarts the counter. Will be called automatically if the counting needs |
| 33 // to be restarted, e.g. when the deletion preference changes state or when |
| 34 // we are notified of data changes. |
| 35 void Restart(); |
| 36 |
32 protected: | 37 protected: |
33 // Called when some conditions have changed and the counting should be | |
34 // restarted, e.g. when the deletion preference changed state or when | |
35 // we were notified of data changes. | |
36 void RestartCounting(); | |
37 | |
38 // Should be called from |Count| by any overriding class to indicate that | 38 // Should be called from |Count| by any overriding class to indicate that |
39 // counting is finished and report the |result|. | 39 // counting is finished and report the |result|. |
40 void ReportResult(uint32 result); | 40 void ReportResult(uint32 result); |
41 | 41 |
42 // Calculates the beginning of the counting period as |period_| before now. | 42 // Calculates the beginning of the counting period as |period_| before now. |
43 base::Time GetPeriodStart(); | 43 base::Time GetPeriodStart(); |
44 | 44 |
45 private: | 45 private: |
46 // Called after the class is initialized by calling |Init|. | 46 // Called after the class is initialized by calling |Init|. |
47 virtual void OnInitialized(); | 47 virtual void OnInitialized(); |
(...skipping 14 matching lines...) Expand all Loading... |
62 | 62 |
63 // The integer preference describing the time period for which this data type | 63 // The integer preference describing the time period for which this data type |
64 // is to be deleted. | 64 // is to be deleted. |
65 IntegerPrefMember period_; | 65 IntegerPrefMember period_; |
66 | 66 |
67 // Whether this class was properly initialized by calling |Init|. | 67 // Whether this class was properly initialized by calling |Init|. |
68 bool initialized_ = false; | 68 bool initialized_ = false; |
69 }; | 69 }; |
70 | 70 |
71 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COUNTER_H_ | 71 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COUNTER_H_ |
OLD | NEW |