Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(646)

Unified Diff: chrome/browser/profiles/profile_statistics_service.h

Issue 1248613003: Issue 501916 : Add data type counts to profile deletion flow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First draft Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698