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

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

Issue 222313005: [Profiles] Download high-res avatars using the --new-profile-management flag (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 8 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_avatar_icon_util.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 4b88fcb4807ff4fbf7f72f5c79bc89cac8e8cd7d..cf6dec155e94a562e2811dfba1851a4d949c73c3 100644
--- a/chrome/browser/profiles/profile_info_cache.h
+++ b/chrome/browser/profiles/profile_info_cache.h
@@ -28,6 +28,7 @@ class DictionaryValue;
class PrefService;
class PrefRegistrySimple;
+class ProfileAvatarDownloader;
// This class saves various information about profiles to local preferences.
// This cache can be used to display a list of profiles without having to
@@ -135,10 +136,22 @@ class ProfileInfoCache : public ProfileInfoInterface,
// Register cache related preferences in Local State.
static void RegisterPrefs(PrefRegistrySimple* registry);
+ // Starts downloading the high res avatar at index |icon_index|.
+ void DownloadHighResAvatar(size_t icon_index);
+
+ // Saves the avatar |image| at |image_path|. This is used both for the
+ // GAIA profile pictures and the ProfileAvatarDownloader that is used to
+ // download the high res avatars.
+ void SaveAvatarImageAtPath(const gfx::Image* image,
+ const std::string& key,
+ const base::FilePath& image_path);
+
void AddObserver(ProfileInfoCacheObserver* obs);
void RemoveObserver(ProfileInfoCacheObserver* obs);
private:
+ FRIEND_TEST_ALL_PREFIXES(ProfileInfoCacheTest, DownloadHighResAvatarTest);
+
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,
@@ -168,12 +181,19 @@ class ProfileInfoCache : public ProfileInfoInterface,
// generic profile avatar.
const gfx::Image* GetHighResAvatarOfProfileAtIndex(size_t index) const;
+ // Returns the decoded image at |image_path|. Used both by the GAIA profile
+ // image and the high res avatars.
const gfx::Image* LoadAvatarPictureFromPath(
const std::string& key,
const base::FilePath& image_path) const;
+
+ // Called when the picture given by |key| has been loaded from disk and
+ // decoded into |image|.
void OnAvatarPictureLoaded(const std::string& key,
gfx::Image** image) const;
- void OnGAIAPictureSaved(const base::FilePath& path, bool* success) const;
+ // Called when the picture given by |file_name| has been saved to disk.
+ // Used both for the GAIA profile picture and the high res avatar files.
+ void OnAvatarPictureSaved(const std::string& file_name);
PrefService* prefs_;
std::vector<std::string> sorted_keys_;
@@ -184,10 +204,18 @@ class ProfileInfoCache : public ProfileInfoInterface,
// A cache of gaia/high res avatar profile pictures. This cache is updated
// lazily so it needs to be mutable.
mutable std::map<std::string, gfx::Image*> cached_avatar_images_;
- // Marks a profile picture as loading. This prevents a picture from
+ // Marks a profile picture as loading from disk. This prevents a picture from
// loading multiple times.
mutable std::map<std::string, bool> cached_avatar_images_loading_;
+ // Map of profile pictures currently being downloaded from the remote
+ // location and the ProfileAvatarDownloader instances downloading them.
+ // This prevents a picture from being downloaded multiple times. The
+ // ProfileAvatarDownloader instances are deleted when the download completes
+ // or when the ProfileInfoCache is destroyed.
+ mutable std::map<std::string, ProfileAvatarDownloader*>
+ avatar_images_downloads_in_progress_;
+
DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache);
};
« no previous file with comments | « chrome/browser/profiles/profile_avatar_icon_util.cc ('k') | chrome/browser/profiles/profile_info_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698