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

Unified Diff: chrome/browser/profiles/profile_info_cache.cc

Issue 1415223002: Add counts of User data to ProfileInfoCache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added methods in profile_statistics.cc to access ProfileInfoCache, fixed a few style errors Created 5 years, 1 month 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_info_cache.cc
diff --git a/chrome/browser/profiles/profile_info_cache.cc b/chrome/browser/profiles/profile_info_cache.cc
index fd71e1779060269b5b2252fde7f7cb57e7becae7..811c8316c2cb3d770ef103305496c214b62a1e16 100644
--- a/chrome/browser/profiles/profile_info_cache.cc
+++ b/chrome/browser/profiles/profile_info_cache.cc
@@ -60,6 +60,10 @@ const char kSupervisedUserId[] = "managed_user_id";
const char kProfileIsEphemeral[] = "is_ephemeral";
const char kActiveTimeKey[] = "active_time";
const char kIsAuthErrorKey[] = "is_auth_error";
+const char kStatsBrowsingHistoryKey[] = "stats_browsing_history";
+const char kStatsPasswordsKey[] = "stats_passwords";
+const char kStatsBookmarksKey[] = "stats_bookmarks";
+const char kStatsSettingsKey[] = "stats_settings";
// First eight are generic icons, which use IDS_NUMBERED_PROFILE_NAME.
const int kDefaultNames[] = {
@@ -499,6 +503,61 @@ size_t ProfileInfoCache::GetAvatarIconIndexOfProfileAtIndex(size_t index)
return icon_index;
}
+bool ProfileInfoCache::HasStatsBrowsingHistoryOfProfileAtIndex(size_t index)
+ const {
+ int value = 0;
+ return GetInfoForProfileAtIndex(index)->GetInteger(kStatsBrowsingHistoryKey,
+ &value);
+}
+
+int ProfileInfoCache::GetStatsBrowsingHistoryOfProfileAtIndex(size_t index)
+ const {
+ int value = 0;
+ GetInfoForProfileAtIndex(index)->GetInteger(kStatsBrowsingHistoryKey, &value);
+ return value;
+}
+
+bool ProfileInfoCache::HasStatsPasswordsOfProfileAtIndex(size_t index)
+ const {
+ int value = 0;
+ return GetInfoForProfileAtIndex(index)->GetInteger(kStatsPasswordsKey,
+ &value);
+}
+
+int ProfileInfoCache::GetStatsPasswordsOfProfileAtIndex(size_t index)
+ const {
+ int value = 0;
+ GetInfoForProfileAtIndex(index)->GetInteger(kStatsPasswordsKey, &value);
+ return value;
+}
+
+bool ProfileInfoCache::HasStatsBookmarksOfProfileAtIndex(size_t index)
+ const {
+ int value = 0;
+ return GetInfoForProfileAtIndex(index)->GetInteger(kStatsBookmarksKey,
+ &value);
+}
+
+int ProfileInfoCache::GetStatsBookmarksOfProfileAtIndex(size_t index)
+ const {
+ int value = 0;
+ GetInfoForProfileAtIndex(index)->GetInteger(kStatsBookmarksKey, &value);
+ return value;
+}
+
+bool ProfileInfoCache::HasStatsSettingsOfProfileAtIndex(size_t index)
Mike Lerman 2015/11/17 16:29:51 nit: I think const can go on the line before. (and
lwchkg 2015/11/18 17:34:53 Done. Six pairs replaced.
+ const {
+ int value = 0;
+ return GetInfoForProfileAtIndex(index)->GetInteger(kStatsSettingsKey, &value);
+}
+
+int ProfileInfoCache::GetStatsSettingsOfProfileAtIndex(size_t index)
+ const {
+ int value = 0;
+ GetInfoForProfileAtIndex(index)->GetInteger(kStatsSettingsKey, &value);
+ return value;
+}
+
void ProfileInfoCache::SetProfileActiveTimeAtIndex(size_t index) {
if (base::Time::Now() - GetProfileActiveTimeAtIndex(index) <
base::TimeDelta::FromHours(1)) {
@@ -909,6 +968,42 @@ size_t ProfileInfoCache::ChooseAvatarIconIndexForNewProfile() const {
return 0;
}
+void ProfileInfoCache::SetStatsBrowsingHistoryOfProfileAtIndex(size_t index,
+ int value) {
+ scoped_ptr<base::DictionaryValue> info(
+ GetInfoForProfileAtIndex(index)->DeepCopy());
+ info->SetInteger(kStatsBrowsingHistoryKey, value);
+ // This takes ownership of |info|.
+ SetInfoForProfileAtIndex(index, info.release());
+}
+
+void ProfileInfoCache::SetStatsPasswordsOfProfileAtIndex(size_t index,
+ int value) {
anthonyvd 2015/11/17 19:03:30 nit: alignment of the params here and the followin
lwchkg 2015/11/18 17:34:53 Done. (Anyway, what's happening with me with those
+ scoped_ptr<base::DictionaryValue> info(
+ GetInfoForProfileAtIndex(index)->DeepCopy());
+ info->SetInteger(kStatsPasswordsKey, value);
+ // This takes ownership of |info|.
+ SetInfoForProfileAtIndex(index, info.release());
+}
+
+void ProfileInfoCache::SetStatsBookmarksOfProfileAtIndex(size_t index,
+ int value) {
+ scoped_ptr<base::DictionaryValue> info(
+ GetInfoForProfileAtIndex(index)->DeepCopy());
+ info->SetInteger(kStatsBookmarksKey, value);
+ // This takes ownership of |info|.
+ SetInfoForProfileAtIndex(index, info.release());
+}
+
+void ProfileInfoCache::SetStatsSettingsOfProfileAtIndex(size_t index,
+ int value) {
+ scoped_ptr<base::DictionaryValue> info(
+ GetInfoForProfileAtIndex(index)->DeepCopy());
+ info->SetInteger(kStatsSettingsKey, value);
+ // This takes ownership of |info|.
+ SetInfoForProfileAtIndex(index, info.release());
+}
+
const base::FilePath& ProfileInfoCache::GetUserDataDir() const {
return user_data_dir_;
}

Powered by Google App Engine
This is Rietveld 408576698