| 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..5ab1717f6f236d80971c8f9d5909ad5e9fdbe841 100644
|
| --- a/chrome/browser/profiles/profile_statistics.h
|
| +++ b/chrome/browser/profiles/profile_statistics.h
|
| @@ -6,60 +6,59 @@
|
| #define CHROME_BROWSER_PROFILES_PROFILE_STATISTICS_H_
|
|
|
| #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 "base/memory/weak_ptr.h"
|
| +#include "chrome/browser/profiles/profile_statistics_common.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;
|
| -};
|
| +// Instances of ProfileStatistics should be created directly. Use
|
| +// ProfileStatisticsFactory instead.
|
| +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() const;
|
| + ProfileStatisticsAggregator* GetAggregator() const;
|
|
|
| -// 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
|
| + GetProfileStatisticsFromAttributesStorage(
|
| + const base::FilePath& profile_path);
|
|
|
| -// ProfileInfoCache ------------------------------------------------------------
|
| + // Sets an individual statistic to the profiles attributes storage.
|
| + static void SetProfileStatisticsToAttributesStorage(
|
| + 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);
|
| + ~ProfileStatistics() override;
|
| + void RegisterAggregator(ProfileStatisticsAggregator* const aggregator);
|
| + void DeregisterAggregator();
|
|
|
| -} // namespace profiles
|
| + Profile* profile_;
|
| + ProfileStatisticsAggregator* aggregator_;
|
| + base::WeakPtrFactory<ProfileStatistics> weak_ptr_factory_;
|
| +};
|
|
|
| #endif // CHROME_BROWSER_PROFILES_PROFILE_STATISTICS_H_
|
|
|