OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 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. | |
4 | |
5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_STATISTICS_SERVICE_H_ | |
6 #define CHROME_BROWSER_PROFILES_PROFILE_STATISTICS_SERVICE_H_ | |
7 | |
8 #include <string> | |
9 #include <utility> | |
10 #include <vector> | |
11 #include "base/memory/weak_ptr.h" | |
12 #include "base/task/cancelable_task_tracker.h" | |
13 #include "chrome/browser/profiles/profile.h" | |
14 #include "components/bookmarks/browser/bookmark_model.h" | |
15 | |
16 namespace profiles { | |
17 | |
18 class ProfileStatisticsService { | |
Mike Lerman
2015/07/22 01:39:26
Please add a class comment about what this class d
lwchkg
2015/07/26 17:38:23
Acknowledged.
| |
19 public: | |
20 // typedefs for ProfileStatisticsCallback. | |
21 typedef std::vector<std::pair<std::string, int> > ProfileStatisticsValues; | |
Mike Lerman
2015/07/22 01:39:27
can you comment what is stored in ProfileStatistic
lwchkg
2015/07/26 17:38:23
Acknowledged.
| |
22 // Definition of the callback function. Note that a copy of | |
Mike Lerman
2015/07/22 01:39:27
nit: you wrote "a copy of" twice
lwchkg
2015/07/26 17:38:23
Acknowledged.
| |
23 // a copy of ProfileStatisticsValues each time the callback is called. | |
24 typedef base::Callback<void(ProfileStatisticsValues)> | |
25 ProfileStatisticsCallback; | |
26 | |
27 // Constructor | |
28 explicit ProfileStatisticsService(Profile* profile, | |
29 ProfileStatisticsCallback callback); | |
30 | |
31 private: | |
32 // Private variables | |
33 base::CancelableTaskTracker tracker_; | |
34 Profile* profile_; | |
35 ProfileStatisticsValues profile_stats_values_; | |
36 | |
37 // For generating weak pointers to itself for callbacks. | |
38 base::WeakPtrFactory<ProfileStatisticsService> weak_factory_; | |
39 | |
40 // Callback function to be called when results arrive. Will be called | |
41 // multiple times (once for each statistics). | |
42 ProfileStatisticsCallback callback_; | |
Mike Lerman
2015/07/22 01:39:27
this can be const.
lwchkg
2015/07/26 17:38:23
Acknowledged.
| |
43 | |
44 // Initialization. Called by constructors. | |
45 void init_(); | |
Mike Lerman
2015/07/22 01:39:27
remove _ from this and all other methods.
Also, c
lwchkg
2015/07/26 17:38:22
Acknowledged.
| |
46 | |
47 // Internal callback. Appends result to profile_stats_values_, and then | |
48 // call the external callback. | |
49 void StatsticsCallback_(std::string category, int count); | |
Mike Lerman
2015/07/22 01:39:26
nit: mis-spelled Statistics.
lwchkg
2015/07/26 17:38:23
Acknowledged.
| |
50 | |
51 // For bookmark counting. | |
52 static int CountURLsFromNode_(const bookmarks::BookmarkNode* node); | |
53 static int CountURLs_(const bookmarks::BookmarkModel* bookmark_model); | |
54 | |
55 // For preference counting. | |
56 int CountPrefs_() const; | |
57 | |
58 DISALLOW_IMPLICIT_CONSTRUCTORS(ProfileStatisticsService); | |
Mike Lerman
2015/07/22 01:39:27
Prefer DISALLOW_COPY_AND_ASSIGN.
lwchkg
2015/07/26 17:38:23
Should I disable the default constructor?
| |
59 }; | |
60 | |
61 } // namespace profiles | |
62 | |
63 #endif // CHROME_BROWSER_PROFILES_PROFILE_STATISTICS_SERVICE_H_ | |
OLD | NEW |