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

Side by Side Diff: chrome/browser/profiles/profile_info_cache.h

Issue 1214483002: Improve the ProfileInfoCache API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review feedback 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 unified diff | Download patch
OLDNEW
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>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/observer_list.h" 16 #include "base/observer_list.h"
17 #include "base/strings/string16.h" 17 #include "base/strings/string16.h"
18 #include "chrome/browser/profiles/profile_attributes_storage.h"
18 #include "chrome/browser/profiles/profile_info_cache_observer.h" 19 #include "chrome/browser/profiles/profile_info_cache_observer.h"
19 #include "chrome/browser/profiles/profile_info_interface.h" 20 #include "chrome/browser/profiles/profile_info_interface.h"
20 21
21 namespace gfx { 22 namespace gfx {
22 class Image; 23 class Image;
23 } 24 }
24 25
25 namespace base { 26 namespace base {
26 class DictionaryValue; 27 class DictionaryValue;
27 } 28 }
28 29
29 class PrefService; 30 class PrefService;
30 class PrefRegistrySimple; 31 class PrefRegistrySimple;
31 class ProfileAvatarDownloader; 32 class ProfileAvatarDownloader;
32 33
33 // This class saves various information about profiles to local preferences. 34 // This class saves various information about profiles to local preferences.
34 // This cache can be used to display a list of profiles without having to 35 // This cache can be used to display a list of profiles without having to
35 // actually load the profiles from disk. 36 // actually load the profiles from disk.
36 class ProfileInfoCache : public ProfileInfoInterface, 37 class ProfileInfoCache : public ProfileInfoInterface,
38 public ProfileAttributesStorage,
37 public base::SupportsWeakPtr<ProfileInfoCache> { 39 public base::SupportsWeakPtr<ProfileInfoCache> {
38 public: 40 public:
39 ProfileInfoCache(PrefService* prefs, const base::FilePath& user_data_dir); 41 ProfileInfoCache(PrefService* prefs, const base::FilePath& user_data_dir);
40 ~ProfileInfoCache() override; 42 ~ProfileInfoCache() override;
41 43
42 // If the |supervised_user_id| is non-empty, the profile will be marked to be 44 // If the |supervised_user_id| is non-empty, the profile will be marked to be
43 // omitted from the avatar-menu list on desktop versions. This is used while a 45 // omitted from the avatar-menu list on desktop versions. This is used while a
44 // supervised user is in the process of being registered with the server. Use 46 // supervised user is in the process of being registered with the server. Use
45 // SetIsOmittedProfileAtIndex() to clear the flag when the profile is ready to 47 // SetIsOmittedProfileAtIndex() to clear the flag when the profile is ready to
46 // be shown in the menu. 48 // be shown in the menu.
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 const base::FilePath& profile_path); 156 const base::FilePath& profile_path);
155 157
156 void AddObserver(ProfileInfoCacheObserver* obs); 158 void AddObserver(ProfileInfoCacheObserver* obs);
157 void RemoveObserver(ProfileInfoCacheObserver* obs); 159 void RemoveObserver(ProfileInfoCacheObserver* obs);
158 160
159 void set_disable_avatar_download_for_testing( 161 void set_disable_avatar_download_for_testing(
160 bool disable_avatar_download_for_testing) { 162 bool disable_avatar_download_for_testing) {
161 disable_avatar_download_for_testing_ = disable_avatar_download_for_testing; 163 disable_avatar_download_for_testing_ = disable_avatar_download_for_testing;
162 } 164 }
163 165
166 // ProfileMetadataStorage:
167 void AddProfile(const base::FilePath& profile_path,
168 const base::string16& name,
169 const std::string& gaia_id,
170 const base::string16& user_name,
171 size_t icon_index,
172 const std::string& supervised_user_id) override;
173 void DeleteProfile(const base::FilePath& profile_path) override;
174 std::vector<ProfileAttributesEntry> GetAllProfilesAttributes() override;
Mike Lerman 2015/07/02 18:01:31 This is now an unordered collection. Perhaps retur
anthonyvd 2015/07/07 21:05:32 I believe this would make using this function hard
Mike Lerman 2015/07/08 18:26:34 Easily sort - because you can do an in-place sort.
anthonyvd 2015/07/09 17:02:13 Exactly! Done.
175 bool GetProfileAttributesWithPath(
176 const base::FilePath& path,
177 ProfileAttributesEntry* entry) override;
178
164 private: 179 private:
165 FRIEND_TEST_ALL_PREFIXES(ProfileInfoCacheTest, DownloadHighResAvatarTest); 180 FRIEND_TEST_ALL_PREFIXES(ProfileInfoCacheTest, DownloadHighResAvatarTest);
166 FRIEND_TEST_ALL_PREFIXES(ProfileInfoCacheTest, 181 FRIEND_TEST_ALL_PREFIXES(ProfileInfoCacheTest,
167 NothingToDownloadHighResAvatarTest); 182 NothingToDownloadHighResAvatarTest);
168 183
169 const base::DictionaryValue* GetInfoForProfileAtIndex(size_t index) const; 184 const base::DictionaryValue* GetInfoForProfileAtIndex(size_t index) const;
170 // Saves the profile info to a cache and takes ownership of |info|. 185 // Saves the profile info to a cache and takes ownership of |info|.
171 void SetInfoForProfileAtIndex(size_t index, base::DictionaryValue* info); 186 void SetInfoForProfileAtIndex(size_t index, base::DictionaryValue* info);
172 std::string CacheKeyFromProfilePath(const base::FilePath& profile_path) const; 187 std::string CacheKeyFromProfilePath(const base::FilePath& profile_path) const;
173 std::vector<std::string>::iterator FindPositionForProfile( 188 std::vector<std::string>::iterator FindPositionForProfile(
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 avatar_images_downloads_in_progress_; 255 avatar_images_downloads_in_progress_;
241 256
242 // Determines of the ProfileAvatarDownloader should be created and executed 257 // Determines of the ProfileAvatarDownloader should be created and executed
243 // or not. Only set to true for tests. 258 // or not. Only set to true for tests.
244 bool disable_avatar_download_for_testing_; 259 bool disable_avatar_download_for_testing_;
245 260
246 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); 261 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache);
247 }; 262 };
248 263
249 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ 264 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698