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

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

Issue 1214483002: Improve the ProfileInfoCache API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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
« no previous file with comments | « chrome/browser/profiles/profile_info_cache.h ('k') | chrome/browser/profiles/profile_info_interface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2c1d80f166e7e4edac254274f0375594ff4ffb6f..652c0f1ce8ab7945f4d922fe289f0bc1b5ffbed3 100644
--- a/chrome/browser/profiles/profile_info_cache.cc
+++ b/chrome/browser/profiles/profile_info_cache.cc
@@ -259,6 +259,7 @@ void ProfileInfoCache::DeleteProfileFromCache(
std::string key = CacheKeyFromProfilePath(profile_path);
cache->Remove(key, NULL);
sorted_keys_.erase(std::find(sorted_keys_.begin(), sorted_keys_.end(), key));
+ profile_attributes_entries_.erase(profile_path);
FOR_EACH_OBSERVER(ProfileInfoCacheObserver,
observer_list_,
@@ -1238,3 +1239,51 @@ void ProfileInfoCache::MigrateLegacyProfileNamesAndDownloadAvatars() {
}
#endif
}
+
+void ProfileInfoCache::AddProfile(
+ const base::FilePath& profile_path,
+ const base::string16& name,
+ const std::string& gaia_id,
+ const base::string16& user_name,
+ size_t icon_index,
+ const std::string& supervised_user_id) {
+ AddProfileToCache(
+ profile_path, name, gaia_id, user_name, icon_index, supervised_user_id);
+}
+
+void ProfileInfoCache::RemoveProfile(const base::FilePath& profile_path) {
+ DeleteProfileFromCache(profile_path);
+}
+
+std::vector<ProfileAttributesEntry*>
+ProfileInfoCache::GetAllProfilesAttributes() {
+ std::vector<ProfileAttributesEntry*> ret;
+ for (size_t i = 0; i < GetNumberOfProfiles(); ++i) {
+ ProfileAttributesEntry* entry;
+ if (GetProfileAttributesWithPath(GetPathOfProfileAtIndex(i), &entry)) {
+ ret.push_back(entry);
+ }
+ }
+ return ret;
+}
+
+bool ProfileInfoCache::GetProfileAttributesWithPath(
+ const base::FilePath& path, ProfileAttributesEntry** entry) {
+ if (GetNumberOfProfiles() == 0)
+ return false;
+
+ if (GetIndexOfProfileWithPath(path) == std::string::npos)
+ return false;
+
+ if (profile_attributes_entries_.find(path) ==
+ profile_attributes_entries_.end()) {
+ // The profile info is in the cache but its entry isn't created yet, insert
+ // it in the map.
+ scoped_ptr<ProfileAttributesEntry> new_entry(new ProfileAttributesEntry());
+ profile_attributes_entries_.add(path, new_entry.Pass());
+ profile_attributes_entries_.get(path)->Initialize(this, path);
+ }
+
+ *entry = profile_attributes_entries_.get(path);
+ return true;
+}
« no previous file with comments | « chrome/browser/profiles/profile_info_cache.h ('k') | chrome/browser/profiles/profile_info_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698