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/profiles/profile.h"
14 class BrowsingDataCounter
{
16 typedef base::Callback
<void(bool, uint32
)> Callback
;
18 BrowsingDataCounter();
19 virtual ~BrowsingDataCounter();
21 // Should be called once to initialize this class.
22 void Init(Profile
* profile
,
23 const Callback
& callback
);
25 // Name of the preference associated with this counter.
26 virtual const std::string
& GetPrefName() const = 0;
28 // The profile associated with this counter.
29 Profile
* GetProfile() const;
32 // Called when some conditions have changed and the counting should be
33 // restarted, e.g. when the deletion preference changed state or when
34 // we were notified of data changes.
35 void RestartCounting();
37 // Should be called from |Count| by any overriding class to indicate that
38 // counting is finished and report the |result|.
39 void ReportResult(uint32 result
);
42 // Called after the class is initialized by calling |Init|.
43 virtual void OnInitialized();
46 virtual void Count() = 0;
48 // The profile for which we will count the data volume.
51 // The callback that will be called when the UI should be updated with a new
55 // The boolean preference indicating whether this data type is to be deleted.
56 // If false, we will not count it.
57 BooleanPrefMember pref_
;
59 // Whether this counter is currently in the process of counting.
60 bool counting_
= false;
62 // Whether this class was properly initialized by calling |Init|.
63 bool initialized_
= false;
66 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COUNTER_H_