OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ | 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ |
6 #define CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ | 6 #define CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 | 129 |
130 // Gets all names of profiles associated with this instance of Chrome. | 130 // Gets all names of profiles associated with this instance of Chrome. |
131 // Because this method will be called during uninstall, before the creation | 131 // Because this method will be called during uninstall, before the creation |
132 // of the ProfileManager, it reads directly from the local state preferences, | 132 // of the ProfileManager, it reads directly from the local state preferences, |
133 // rather than going through the ProfileInfoCache object. | 133 // rather than going through the ProfileInfoCache object. |
134 static std::vector<base::string16> GetProfileNames(); | 134 static std::vector<base::string16> GetProfileNames(); |
135 | 135 |
136 // Register cache related preferences in Local State. | 136 // Register cache related preferences in Local State. |
137 static void RegisterPrefs(PrefRegistrySimple* registry); | 137 static void RegisterPrefs(PrefRegistrySimple* registry); |
138 | 138 |
139 // Starts downloading the high res avatar at index |icon_index| for profile | 139 // Checks whether the high res avatar at index |icon_index| exists, and |
140 // with path |profile_path|. | 140 // if it does not, calls |DownloadHighResAvatar|. |
141 void DownloadHighResAvatar(size_t icon_index, | 141 void DownloadHighResAvatarIfNeeded(size_t icon_index, |
142 const base::FilePath& profile_path); | 142 const base::FilePath& profile_path); |
143 | 143 |
144 // Saves the avatar |image| at |image_path|. This is used both for the | 144 // Saves the avatar |image| at |image_path|. This is used both for the |
145 // GAIA profile pictures and the ProfileAvatarDownloader that is used to | 145 // GAIA profile pictures and the ProfileAvatarDownloader that is used to |
146 // download the high res avatars. | 146 // download the high res avatars. |
147 void SaveAvatarImageAtPath(const gfx::Image* image, | 147 void SaveAvatarImageAtPath(const gfx::Image* image, |
148 const std::string& key, | 148 const std::string& key, |
149 const base::FilePath& image_path, | 149 const base::FilePath& image_path, |
150 const base::FilePath& profile_path); | 150 const base::FilePath& profile_path); |
151 | 151 |
152 void AddObserver(ProfileInfoCacheObserver* obs); | 152 void AddObserver(ProfileInfoCacheObserver* obs); |
(...skipping 24 matching lines...) Expand all Loading... | |
177 size_t* out_icon_index) const; | 177 size_t* out_icon_index) const; |
178 | 178 |
179 // Updates the position of the profile at the given index so that the list | 179 // Updates the position of the profile at the given index so that the list |
180 // of profiles is still sorted. | 180 // of profiles is still sorted. |
181 void UpdateSortForProfileIndex(size_t index); | 181 void UpdateSortForProfileIndex(size_t index); |
182 | 182 |
183 // Loads or uses an already loaded high resolution image of the | 183 // Loads or uses an already loaded high resolution image of the |
184 // generic profile avatar. | 184 // generic profile avatar. |
185 const gfx::Image* GetHighResAvatarOfProfileAtIndex(size_t index) const; | 185 const gfx::Image* GetHighResAvatarOfProfileAtIndex(size_t index) const; |
186 | 186 |
187 // Starts downloading the high res avatar at index |icon_index| for profile | |
188 // with path |profile_path|. | |
189 void DownloadHighResAvatar(const std::string file_name, | |
Mike Lerman
2015/01/27 16:39:15
nit: mention |file_name| in the comment, for compl
noms (inactive)
2015/01/28 02:18:35
Done.
| |
190 size_t icon_index, | |
191 const base::FilePath& profile_path); | |
192 | |
187 // Returns the decoded image at |image_path|. Used both by the GAIA profile | 193 // Returns the decoded image at |image_path|. Used both by the GAIA profile |
188 // image and the high res avatars. | 194 // image and the high res avatars. |
189 const gfx::Image* LoadAvatarPictureFromPath( | 195 const gfx::Image* LoadAvatarPictureFromPath( |
190 const base::FilePath& profile_path, | 196 const base::FilePath& profile_path, |
191 const std::string& key, | 197 const std::string& key, |
192 const base::FilePath& image_path) const; | 198 const base::FilePath& image_path) const; |
193 | 199 |
194 // Called when the picture given by |key| has been loaded from disk and | 200 // Called when the picture given by |key| has been loaded from disk and |
195 // decoded into |image|. | 201 // decoded into |image|. |
196 void OnAvatarPictureLoaded(const base::FilePath& profile_path, | 202 void OnAvatarPictureLoaded(const base::FilePath& profile_path, |
(...skipping 27 matching lines...) Expand all Loading... | |
224 // This prevents a picture from being downloaded multiple times. The | 230 // This prevents a picture from being downloaded multiple times. The |
225 // ProfileAvatarDownloader instances are deleted when the download completes | 231 // ProfileAvatarDownloader instances are deleted when the download completes |
226 // or when the ProfileInfoCache is destroyed. | 232 // or when the ProfileInfoCache is destroyed. |
227 mutable std::map<std::string, ProfileAvatarDownloader*> | 233 mutable std::map<std::string, ProfileAvatarDownloader*> |
228 avatar_images_downloads_in_progress_; | 234 avatar_images_downloads_in_progress_; |
229 | 235 |
230 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); | 236 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); |
231 }; | 237 }; |
232 | 238 |
233 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ | 239 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ |
OLD | NEW |