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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COUNTER_H_
6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COUNTER_H_
10 #include "base/callback.h"
11 #include "base/prefs/pref_member.h"
12 #include "chrome/browser/browsing_data/browsing_data_remover.h"
13 #include "chrome/browser/profiles/profile.h"
15 class BrowsingDataCounter
{
17 typedef base::Callback
<void(bool, uint32
)> Callback
;
19 BrowsingDataCounter();
20 virtual ~BrowsingDataCounter();
22 // Should be called once to initialize this class.
23 void Init(Profile
* profile
,
24 const Callback
& callback
);
26 // Name of the preference associated with this counter.
27 virtual const std::string
& GetPrefName() const = 0;
29 // The profile associated with this counter.
30 Profile
* GetProfile() const;
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();
38 // Should be called from |Count| by any overriding class to indicate that
39 // counting is finished and report the |result|.
40 void ReportResult(uint32 result
);
42 // Calculates the beginning of the counting period as |period_| before now.
43 base::Time
GetPeriodStart();
46 // Called after the class is initialized by calling |Init|.
47 virtual void OnInitialized();
50 virtual void Count() = 0;
52 // The profile for which we will count the data volume.
55 // The callback that will be called when the UI should be updated with a new
59 // The boolean preference indicating whether this data type is to be deleted.
60 // If false, we will not count it.
61 BooleanPrefMember pref_
;
63 // The integer preference describing the time period for which this data type
65 IntegerPrefMember period_
;
67 // Whether this class was properly initialized by calling |Init|.
68 bool initialized_
= false;
71 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COUNTER_H_