Chromium Code Reviews| Index: chrome/browser/profiles/profile_statistics.h |
| diff --git a/chrome/browser/profiles/profile_statistics.h b/chrome/browser/profiles/profile_statistics.h |
| index c24393a5105f1a84ba84e057ed4e9bf6bfe28843..e2df87a45eb32093e1d8c8526e9fa194bcf545a9 100644 |
| --- a/chrome/browser/profiles/profile_statistics.h |
| +++ b/chrome/browser/profiles/profile_statistics.h |
| @@ -5,61 +5,54 @@ |
| #ifndef CHROME_BROWSER_PROFILES_PROFILE_STATISTICS_H_ |
| #define CHROME_BROWSER_PROFILES_PROFILE_STATISTICS_H_ |
| +#include <map> |
| #include <string> |
| #include <utility> |
| -#include <vector> |
| -#include "base/files/file_path.h" |
| -#include "base/task/cancelable_task_tracker.h" |
| -#include "chrome/browser/profiles/profile.h" |
| -namespace profiles { |
| +#include "chrome/browser/profiles/profile_statistics_types.h" |
| +#include "components/keyed_service/core/keyed_service.h" |
| -// Constants for the categories in ProfileCategoryStats |
| -extern const char kProfileStatisticsBrowsingHistory[]; |
| -extern const char kProfileStatisticsPasswords[]; |
| -extern const char kProfileStatisticsBookmarks[]; |
| -extern const char kProfileStatisticsSettings[]; |
| +namespace base { |
| +class FilePath; |
| +} // namespace base |
| +class Profile; |
| +class ProfileStatisticsAggregator; |
| -// Definition of a single return value of |ProfileStatisticsCallback|. If |
| -// |success| is false, the statistics failed to load and |count| is undefined. |
| -// The data look like these: {"BrowsingHistory", 912, true}, |
| -// {"Passwords", 71, true}, {"Bookmarks", 120, true}, {"Settings", 200, true} |
| -struct ProfileCategoryStat { |
| - std::string category; |
| - int count; |
| - bool success; |
| -}; |
| +class ProfileStatistics : public KeyedService { |
| + public: |
| + // Profile Statistics -------------------------------------------------------- |
| -// Definition of the return value of |ProfileStatisticsCallback|. |
| -using ProfileCategoryStats = std::vector<ProfileCategoryStat>; |
| + // This function collects statistical information about |profile|, also |
| + // returns the information via |callback| if |callback| is not null. The |
| + // statistical information is also copied to ProfileAttributesStorage. |
| + // Currently bookmarks, history, logins and preferences are counted. The |
| + // callback function will probably be called more than once, so binding |
| + // parameters with bind::Passed() is prohibited. Most of the async tasks |
| + // involved in this function can be cancelled if |tracker| is not null. |
| + void GatherStatistics(const profiles::ProfileStatisticsCallback& callback); |
| -// Definition of the callback function. Note that a copy of |
| -// |ProfileCategoryStats| is made each time the callback is called. |
| -using ProfileStatisticsCallback = base::Callback<void(ProfileCategoryStats)>; |
| + bool HasAggregator(); |
| + ProfileStatisticsAggregator* const GetAggregator(); |
| -// Profile Statistics ---------------------------------------------------------- |
| + // ProfileAttributesStorage -------------------------------------------------- |
| -// This function collects statistical information about |profile|, also returns |
| -// the information via |callback| if |callback| is not null. The statistical |
| -// information is also copied to ProfileInfoCache. Currently bookmarks, history, |
| -// logins and preferences are counted. The callback function will probably be |
| -// called more than once, so binding parameters with bind::Passed() is |
| -// prohibited. Most of the async tasks involved in this function can be |
| -// cancelled if |tracker| is not null. |
| -void GatherProfileStatistics(Profile* profile, |
| - const ProfileStatisticsCallback& callback, |
| - base::CancelableTaskTracker* tracker); |
| + // Gets statistical information from the profiles attributes storage. |
| + static profiles::ProfileCategoryStats GetProfileStatisticsFromCache( |
| + const base::FilePath& profile_path); |
| -// ProfileInfoCache ------------------------------------------------------------ |
| + // Sets an individual statistic to the profiles attributes storage. |
| + static void SetProfileStatisticsInCache(const base::FilePath& profile_path, |
| + const std::string& category, int count); |
| -// Gets statistical information from ProfileInfoCache. |
| -ProfileCategoryStats GetProfileStatisticsFromCache( |
| - const base::FilePath& profile_path); |
| + private: |
| + friend class ProfileStatisticsFactory; |
| -// Sets an individual statistic to ProfileInfoCache. |
| -void SetProfileStatisticsInCache(const base::FilePath& profile_path, |
| - const std::string& category, int count); |
| + explicit ProfileStatistics(Profile* profile) : profile_(profile) {} |
|
Mike Lerman
2016/03/15 18:54:22
Set profile_ in the .cc file
lwchkg
2016/03/16 13:28:02
Done.
|
| + void RegisterAggregator(ProfileStatisticsAggregator* const aggregator); |
| + void DeregisterAggregator(); |
| -} // namespace profiles |
| + Profile* profile_; |
| + ProfileStatisticsAggregator* aggregator_ = nullptr; |
|
Mike Lerman
2016/03/15 18:54:22
set aggregator_ = nullptr in the .cc file's constr
lwchkg
2016/03/16 13:28:02
Done.
|
| +}; |
| #endif // CHROME_BROWSER_PROFILES_PROFILE_STATISTICS_H_ |