| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_STATISTICS_H_ | 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_STATISTICS_H_ |
| 6 #define CHROME_BROWSER_PROFILES_PROFILE_STATISTICS_H_ | 6 #define CHROME_BROWSER_PROFILES_PROFILE_STATISTICS_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <string> | 9 #include <string> |
| 9 | 10 |
| 10 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 11 #include "chrome/browser/profiles/profile_statistics_common.h" | 12 #include "chrome/browser/profiles/profile_statistics_common.h" |
| 12 #include "components/keyed_service/core/keyed_service.h" | 13 #include "components/keyed_service/core/keyed_service.h" |
| 13 | 14 |
| 14 class Profile; | 15 class Profile; |
| 15 class ProfileStatisticsAggregator; | 16 class ProfileStatisticsAggregator; |
| 16 | 17 |
| 17 // Instances of ProfileStatistics should be created directly. Use | 18 // Instances of ProfileStatistics should be created directly. Use |
| 18 // ProfileStatisticsFactory instead. | 19 // ProfileStatisticsFactory instead. |
| 19 class ProfileStatistics : public KeyedService { | 20 class ProfileStatistics : public KeyedService { |
| 20 public: | 21 public: |
| 21 // Profile Statistics -------------------------------------------------------- | 22 // Profile Statistics -------------------------------------------------------- |
| 22 | 23 |
| 23 // This function collects statistical information about |profile|, also | 24 // This function collects statistical information about |profile|, also |
| 24 // returns the information via |callback| if |callback| is not null. | 25 // returns the information via |callback| if |callback| is not null. |
| 25 // Currently bookmarks, history, logins and preferences are counted. The | 26 // Currently bookmarks, history, logins and autofill forms are counted. The |
| 26 // callback function will probably be called more than once, so binding | 27 // callback function will probably be called more than once, so binding |
| 27 // parameters with bind::Passed() is prohibited. | 28 // parameters with bind::Passed() is prohibited. |
| 28 void GatherStatistics(const profiles::ProfileStatisticsCallback& callback); | 29 void GatherStatistics(const profiles::ProfileStatisticsCallback& callback); |
| 29 | 30 |
| 30 private: | 31 private: |
| 31 friend class ProfileStatisticsFactory; | 32 friend class ProfileStatisticsFactory; |
| 32 | 33 |
| 33 explicit ProfileStatistics(Profile* profile); | 34 explicit ProfileStatistics(Profile* profile); |
| 34 ~ProfileStatistics() override; | 35 ~ProfileStatistics() override; |
| 35 void DeregisterAggregator(); | 36 void DeregisterAggregator(); |
| 36 | 37 |
| 37 Profile* profile_; | 38 Profile* profile_; |
| 38 scoped_refptr<ProfileStatisticsAggregator> aggregator_; | 39 std::unique_ptr<ProfileStatisticsAggregator> aggregator_; |
| 39 base::WeakPtrFactory<ProfileStatistics> weak_ptr_factory_; | 40 base::WeakPtrFactory<ProfileStatistics> weak_ptr_factory_; |
| 40 }; | 41 }; |
| 41 | 42 |
| 42 #endif // CHROME_BROWSER_PROFILES_PROFILE_STATISTICS_H_ | 43 #endif // CHROME_BROWSER_PROFILES_PROFILE_STATISTICS_H_ |
| OLD | NEW |