Chromium Code Reviews| Index: chrome/browser/profiles/profile_statistics_service.h |
| diff --git a/chrome/browser/profiles/profile_statistics_service.h b/chrome/browser/profiles/profile_statistics_service.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0157f4172247f22751582c0070e357c99d261b6e |
| --- /dev/null |
| +++ b/chrome/browser/profiles/profile_statistics_service.h |
| @@ -0,0 +1,63 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_PROFILES_PROFILE_STATISTICS_SERVICE_H_ |
| +#define CHROME_BROWSER_PROFILES_PROFILE_STATISTICS_SERVICE_H_ |
| + |
| +#include <string> |
| +#include <utility> |
| +#include <vector> |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/task/cancelable_task_tracker.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "components/bookmarks/browser/bookmark_model.h" |
| + |
| +namespace profiles { |
| + |
| +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.
|
| + public: |
| + // typedefs for ProfileStatisticsCallback. |
| + 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.
|
| + // 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.
|
| + // a copy of ProfileStatisticsValues each time the callback is called. |
| + typedef base::Callback<void(ProfileStatisticsValues)> |
| + ProfileStatisticsCallback; |
| + |
| + // Constructor |
| + explicit ProfileStatisticsService(Profile* profile, |
| + ProfileStatisticsCallback callback); |
| + |
| + private: |
| + // Private variables |
| + base::CancelableTaskTracker tracker_; |
| + Profile* profile_; |
| + ProfileStatisticsValues profile_stats_values_; |
| + |
| + // For generating weak pointers to itself for callbacks. |
| + base::WeakPtrFactory<ProfileStatisticsService> weak_factory_; |
| + |
| + // Callback function to be called when results arrive. Will be called |
| + // multiple times (once for each statistics). |
| + ProfileStatisticsCallback callback_; |
|
Mike Lerman
2015/07/22 01:39:27
this can be const.
lwchkg
2015/07/26 17:38:23
Acknowledged.
|
| + |
| + // Initialization. Called by constructors. |
| + 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.
|
| + |
| + // Internal callback. Appends result to profile_stats_values_, and then |
| + // call the external callback. |
| + 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.
|
| + |
| + // For bookmark counting. |
| + static int CountURLsFromNode_(const bookmarks::BookmarkNode* node); |
| + static int CountURLs_(const bookmarks::BookmarkModel* bookmark_model); |
| + |
| + // For preference counting. |
| + int CountPrefs_() const; |
| + |
| + 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?
|
| +}; |
| + |
| +} // namespace profiles |
| + |
| +#endif // CHROME_BROWSER_PROFILES_PROFILE_STATISTICS_SERVICE_H_ |