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

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

Issue 33753002: Sooper experimental refactoring of the profile info cache. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 7 years, 2 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_impl.cc ('k') | chrome/browser/profiles/profile_info_cache.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_info_cache.h
diff --git a/chrome/browser/profiles/profile_info_cache.h b/chrome/browser/profiles/profile_info_cache.h
index bf6cabe51c829960320d10cf8aab9d7c76348a0e..06891cbf2d80104f8775e33aae1c25c40c4a86c4 100644
--- a/chrome/browser/profiles/profile_info_cache.h
+++ b/chrome/browser/profiles/profile_info_cache.h
@@ -17,6 +17,7 @@
#include "base/strings/string16.h"
#include "chrome/browser/profiles/profile_info_cache_observer.h"
#include "chrome/browser/profiles/profile_info_interface.h"
+#include "chrome/browser/profiles/profile_info_entry.h"
namespace gfx {
class Image;
@@ -38,6 +39,17 @@ class ProfileInfoCache : public ProfileInfoInterface,
ProfileInfoCache(PrefService* prefs, const base::FilePath& user_data_dir);
virtual ~ProfileInfoCache();
+
+
+ // ******************* Start new code
+
+ virtual std::vector<ProfileInfoEntry> GetProfilesSortedByName() const OVERRIDE;
+
+ bool GetInfoForProfile(const base::FilePath& path,
+ ProfileInfoEntry* entry) const;
+
+ void SetInfoForProfile(const ProfileInfoEntry& info);
+
// This |is_managed| refers to local management (formerly "managed mode"),
// not enterprise management.
void AddProfileToCache(const base::FilePath& profile_path,
@@ -45,59 +57,101 @@ class ProfileInfoCache : public ProfileInfoInterface,
const string16& username,
size_t icon_index,
const std::string& managed_user_id);
+
void DeleteProfileFromCache(const base::FilePath& profile_path);
+
+ // ********************* End new code
+
+
+
+
+
+
// ProfileInfoInterface:
virtual size_t GetNumberOfProfiles() const OVERRIDE;
+
// Don't cache this value and reuse, because resorting the menu could cause
// the item being referred to to change out from under you.
- virtual size_t GetIndexOfProfileWithPath(
- const base::FilePath& profile_path) const OVERRIDE;
- virtual string16 GetNameOfProfileAtIndex(size_t index) const OVERRIDE;
- virtual string16 GetShortcutNameOfProfileAtIndex(size_t index)
- const OVERRIDE;
- virtual base::FilePath GetPathOfProfileAtIndex(size_t index) const OVERRIDE;
- virtual string16 GetUserNameOfProfileAtIndex(size_t index) const OVERRIDE;
- virtual const gfx::Image& GetAvatarIconOfProfileAtIndex(
- size_t index) const OVERRIDE;
+ // virtual size_t GetIndexOfProfileWithPath(
+ // const base::FilePath& profile_path) const OVERRIDE;
+
+
+
+ //virtual string16 GetNameOfProfileAtIndex(size_t index) const OVERRIDE;
+ //virtual string16 GetShortcutNameOfProfileAtIndex(size_t index)
+ // const OVERRIDE;
+ //virtual base::FilePath GetPathOfProfileAtIndex(size_t index) const OVERRIDE;
+ //virtual string16 GetUserNameOfProfileAtIndex(size_t index) const OVERRIDE;
+ virtual const gfx::Image& GetAvatarIconOfProfile(const base::FilePath& profile_path) const OVERRIDE;
// Note that a return value of false could mean an error in collection or
// that there are currently no background apps running. However, the action
// which results is the same in both cases (thus far).
- virtual bool GetBackgroundStatusOfProfileAtIndex(
- size_t index) const OVERRIDE;
- virtual string16 GetGAIANameOfProfileAtIndex(size_t index) const OVERRIDE;
- virtual string16 GetGAIAGivenNameOfProfileAtIndex(
- size_t index) const OVERRIDE;
- virtual bool IsUsingGAIANameOfProfileAtIndex(size_t index) const OVERRIDE;
+ //virtual bool GetBackgroundStatusOfProfileAtIndex(
+ // size_t index) const OVERRIDE;
+ //virtual string16 GetGAIANameOfProfileAtIndex(size_t index) const OVERRIDE;
+ //virtual string16 GetGAIAGivenNameOfProfileAtIndex(
+ // size_t index) const OVERRIDE;
+ //virtual bool IsUsingGAIANameOfProfileAtIndex(size_t index) const OVERRIDE;
// Returns the GAIA picture for the given profile. This may return NULL
// if the profile does not have a GAIA picture or if the picture must be
// loaded from disk.
- virtual const gfx::Image* GetGAIAPictureOfProfileAtIndex(
- size_t index) const OVERRIDE;
- virtual bool IsUsingGAIAPictureOfProfileAtIndex(
- size_t index) const OVERRIDE;
- virtual bool ProfileIsManagedAtIndex(size_t index) const OVERRIDE;
- virtual bool ProfileIsSigninRequiredAtIndex(size_t index) const OVERRIDE;
- virtual std::string GetManagedUserIdOfProfileAtIndex(size_t index) const
- OVERRIDE;
- virtual bool ProfileIsEphemeralAtIndex(size_t index) const OVERRIDE;
-
- size_t GetAvatarIconIndexOfProfileAtIndex(size_t index) const;
-
- void SetNameOfProfileAtIndex(size_t index, const string16& name);
- void SetShortcutNameOfProfileAtIndex(size_t index, const string16& name);
- void SetUserNameOfProfileAtIndex(size_t index, const string16& user_name);
- void SetAvatarIconOfProfileAtIndex(size_t index, size_t icon_index);
- void SetManagedUserIdOfProfileAtIndex(size_t index, const std::string& id);
- void SetBackgroundStatusOfProfileAtIndex(size_t index,
- bool running_background_apps);
- void SetGAIANameOfProfileAtIndex(size_t index, const string16& name);
- void SetGAIAGivenNameOfProfileAtIndex(size_t index, const string16& name);
- void SetIsUsingGAIANameOfProfileAtIndex(size_t index, bool value);
- void SetGAIAPictureOfProfileAtIndex(size_t index, const gfx::Image* image);
- void SetIsUsingGAIAPictureOfProfileAtIndex(size_t index, bool value);
- void SetProfileSigninRequiredAtIndex(size_t index, bool value);
- void SetProfileIsEphemeralAtIndex(size_t index, bool value);
+
+
+ // *** FROM HEAD
+ // virtual const gfx::Image* GetGAIAPictureOfProfileAtIndex(
+ // size_t index) const OVERRIDE;
+ // virtual bool IsUsingGAIAPictureOfProfileAtIndex(
+ // size_t index) const OVERRIDE;
+ // virtual bool ProfileIsManagedAtIndex(size_t index) const OVERRIDE;
+ // virtual bool ProfileIsSigninRequiredAtIndex(size_t index) const OVERRIDE;
+ // virtual std::string GetManagedUserIdOfProfileAtIndex(size_t index) const
+ // OVERRIDE;
+ // virtual bool ProfileIsEphemeralAtIndex(size_t index) const OVERRIDE;
+
+ // size_t GetAvatarIconIndexOfProfileAtIndex(size_t index) const;
+
+ // void SetNameOfProfileAtIndex(size_t index, const string16& name);
+ // void SetShortcutNameOfProfileAtIndex(size_t index, const string16& name);
+ // void SetUserNameOfProfileAtIndex(size_t index, const string16& user_name);
+ // void SetAvatarIconOfProfileAtIndex(size_t index, size_t icon_index);
+ // void SetManagedUserIdOfProfileAtIndex(size_t index, const std::string& id);
+ // void SetBackgroundStatusOfProfileAtIndex(size_t index,
+ // bool running_background_apps);
+ // void SetGAIANameOfProfileAtIndex(size_t index, const string16& name);
+ // void SetGAIAGivenNameOfProfileAtIndex(size_t index, const string16& name);
+ // void SetIsUsingGAIANameOfProfileAtIndex(size_t index, bool value);
+ // void SetGAIAPictureOfProfileAtIndex(size_t index, const gfx::Image* image);
+ // void SetIsUsingGAIAPictureOfProfileAtIndex(size_t index, bool value);
+ // void SetProfileSigninRequiredAtIndex(size_t index, bool value);
+ // void SetProfileIsEphemeralAtIndex(size_t index, bool value);
+
+ virtual const gfx::Image* GetGAIAPictureOfProfile(const base::FilePath& profile_path) const OVERRIDE;
+ //virtual bool IsUsingGAIAPictureOfProfileAtIndex(
+ // size_t index) const OVERRIDE;
+ //virtual bool ProfileIsManagedAtIndex(size_t index) const OVERRIDE;
+ //virtual bool ProfileIsSigninRequiredAtIndex(size_t index) const OVERRIDE;
+ //virtual std::string GetManagedUserIdOfProfileAtIndex(size_t index) const
+ // OVERRIDE;
+
+ //size_t GetAvatarIconIndexOfProfileAtIndex(size_t index) const;
+
+ //void SetNameOfProfileAtIndex(size_t index, const string16& name);
+ //void SetShortcutNameOfProfileAtIndex(size_t index, const string16& name);
+ //void SetUserNameOfProfileAtIndex(size_t index, const string16& user_name);
+ //void SetAvatarIconOfProfileAtIndex(size_t index, size_t icon_index);
+ //void SetManagedUserIdOfProfileAtIndex(size_t index, const std::string& id);
+ //void SetBackgroundStatusOfProfileAtIndex(size_t index,
+ // bool running_background_apps);
+ //void SetGAIANameOfProfileAtIndex(size_t index, const string16& name);
+ //void SetGAIAGivenNameOfProfileAtIndex(size_t index, const string16& name);
+ //void SetIsUsingGAIANameOfProfileAtIndex(size_t index, bool value);
+ void SetGAIAPictureOfProfile(const base::FilePath& profile_path, const gfx::Image* image);
+ //void SetIsUsingGAIAPictureOfProfileAtIndex(size_t index, bool value);
+ //void SetProfileSigninRequiredAtIndex(size_t index, bool value);
+
+
+
// Returns unique name that can be assigned to a newly created profile.
string16 ChooseNameForNewProfile(size_t icon_index) const;
@@ -106,11 +160,11 @@ class ProfileInfoCache : public ProfileInfoInterface,
// for the profile name and picture. This pref is used to switch over
// to GAIA info the first time it is available. Afterwards this pref is
// checked to prevent clobbering the user's custom settings.
- bool GetHasMigratedToGAIAInfoOfProfileAtIndex(size_t index) const;
+ //bool GetHasMigratedToGAIAInfoOfProfileAtIndex(size_t index) const;
// Marks the given profile as having switched to using GAIA information
// for the profile name and picture.
- void SetHasMigratedToGAIAInfoOfProfileAtIndex(size_t index, bool value);
+ //void SetHasMigratedToGAIAInfoOfProfileAtIndex(size_t index, bool value);
// Returns an avatar icon index that can be assigned to a newly created
// profile. Note that the icon may not be unique since there are a limited
@@ -145,15 +199,15 @@ class ProfileInfoCache : public ProfileInfoInterface,
void RemoveObserver(ProfileInfoCacheObserver* obs);
private:
- const base::DictionaryValue* GetInfoForProfileAtIndex(size_t index) const;
+ //const base::DictionaryValue* GetInfoForProfileAtIndex(size_t index) const;
// Saves the profile info to a cache and takes ownership of |info|.
// Currently the only information that is cached is the profile's name,
// user name, and avatar icon.
- void SetInfoForProfileAtIndex(size_t index, base::DictionaryValue* info);
+ //void SetInfoForProfileAtIndex(size_t index, base::DictionaryValue* info);
std::string CacheKeyFromProfilePath(const base::FilePath& profile_path) const;
- std::vector<std::string>::iterator FindPositionForProfile(
- const std::string& search_key,
- const string16& search_name);
+ //std::vector<std::string>::iterator FindPositionForProfile(
+ // const std::string& search_key,
+ // const string16& search_name);
// Returns true if the given icon index is not in use by another profie.
bool IconIndexIsUnique(size_t icon_index) const;
@@ -166,14 +220,15 @@ class ProfileInfoCache : public ProfileInfoInterface,
// Updates the position of the profile at the given index so that the list
// of profiles is still sorted.
- void UpdateSortForProfileIndex(size_t index);
+ //void UpdateSortForProfileIndex(size_t index);
void OnGAIAPictureLoaded(const base::FilePath& path,
gfx::Image** image) const;
void OnGAIAPictureSaved(const base::FilePath& path, bool* success) const;
PrefService* prefs_;
- std::vector<std::string> sorted_keys_;
+ //std::vector<std::string> sorted_keys_;
+ std::map<std::string, ProfileInfoEntry> cached_entries_;
base::FilePath user_data_dir_;
ObserverList<ProfileInfoCacheObserver> observer_list_;
« no previous file with comments | « chrome/browser/profiles/profile_impl.cc ('k') | chrome/browser/profiles/profile_info_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698