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

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

Issue 134863002: Track when profiles are last used. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: don't send notifications for active-time updates; nobody wants it and some tests aren't prepared fo… Created 6 years, 11 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_info_cache.cc
diff --git a/chrome/browser/profiles/profile_info_cache.cc b/chrome/browser/profiles/profile_info_cache.cc
index 6aeedf0f99b10a44e9b24848bd342f33384aa1b4..d9ff4ee37060e842b5ae61b70a3bcc18eb2eb507 100644
--- a/chrome/browser/profiles/profile_info_cache.cc
+++ b/chrome/browser/profiles/profile_info_cache.cc
@@ -53,6 +53,7 @@ const char kIsManagedKey[] = "is_managed";
const char kSigninRequiredKey[] = "signin_required";
const char kManagedUserId[] = "managed_user_id";
const char kProfileIsEphemeral[] = "is_ephemeral";
+const char kActiveTimeKey[] = "active_time";
const char kDefaultUrlPrefix[] = "chrome://theme/IDR_PROFILE_AVATAR_";
const char kGAIAPictureFileName[] = "Google Profile Picture.png";
@@ -309,6 +310,15 @@ base::FilePath ProfileInfoCache::GetPathOfProfileAtIndex(size_t index) const {
return user_data_dir_.AppendASCII(sorted_keys_[index]);
}
+base::Time ProfileInfoCache::GetProfileActiveTimeAtIndex(size_t index) const {
+ double dt;
+ if (GetInfoForProfileAtIndex(index)->GetDouble(kActiveTimeKey, &dt)) {
+ return base::Time::FromDoubleT(dt);
+ } else {
+ return base::Time();
+ }
+}
+
base::string16 ProfileInfoCache::GetUserNameOfProfileAtIndex(
size_t index) const {
base::string16 user_name;
@@ -474,6 +484,14 @@ size_t ProfileInfoCache::GetAvatarIconIndexOfProfileAtIndex(size_t index)
return icon_index;
}
+void ProfileInfoCache::SetProfileActiveTimeAtIndex(size_t index) {
+ scoped_ptr<base::DictionaryValue> info(
+ GetInfoForProfileAtIndex(index)->DeepCopy());
+ info->SetDouble(kActiveTimeKey, base::Time::Now().ToDoubleT());
+ // This takes ownership of |info|.
+ SetInfoQuietlyForProfileAtIndex(index, info.release());
+}
+
void ProfileInfoCache::SetNameOfProfileAtIndex(size_t index,
const base::string16& name) {
scoped_ptr<base::DictionaryValue> info(
@@ -869,11 +887,17 @@ const base::DictionaryValue* ProfileInfoCache::GetInfoForProfileAtIndex(
return info;
}
-void ProfileInfoCache::SetInfoForProfileAtIndex(size_t index,
- base::DictionaryValue* info) {
+void ProfileInfoCache::SetInfoQuietlyForProfileAtIndex(
+ size_t index, base::DictionaryValue* info) {
DictionaryPrefUpdate update(prefs_, prefs::kProfileInfoCache);
base::DictionaryValue* cache = update.Get();
cache->SetWithoutPathExpansion(sorted_keys_[index], info);
+}
+
+// TODO(noms): Switch to newer notification system.
+void ProfileInfoCache::SetInfoForProfileAtIndex(size_t index,
+ base::DictionaryValue* info) {
+ SetInfoQuietlyForProfileAtIndex(index, info);
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
« no previous file with comments | « chrome/browser/profiles/profile_info_cache.h ('k') | chrome/browser/profiles/profile_info_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698