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 <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
| 10 #include <memory> |
10 #include <string> | 11 #include <string> |
11 #include <unordered_map> | 12 #include <unordered_map> |
12 #include <vector> | 13 #include <vector> |
13 | 14 |
14 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
15 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
16 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
17 #include "base/macros.h" | 18 #include "base/macros.h" |
18 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
19 #include "base/observer_list.h" | 20 #include "base/observer_list.h" |
20 #include "base/strings/string16.h" | 21 #include "base/strings/string16.h" |
| 22 #include "base/values.h" |
21 #include "chrome/browser/profiles/profile_attributes_entry.h" | 23 #include "chrome/browser/profiles/profile_attributes_entry.h" |
22 #include "chrome/browser/profiles/profile_attributes_storage.h" | 24 #include "chrome/browser/profiles/profile_attributes_storage.h" |
23 #include "chrome/browser/profiles/profile_info_cache_observer.h" | 25 #include "chrome/browser/profiles/profile_info_cache_observer.h" |
24 #include "chrome/browser/profiles/profile_info_interface.h" | 26 #include "chrome/browser/profiles/profile_info_interface.h" |
25 | 27 |
26 namespace gfx { | 28 namespace gfx { |
27 class Image; | 29 class Image; |
28 } | 30 } |
29 | 31 |
30 namespace base { | 32 namespace base { |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 std::vector<ProfileAttributesEntry*> GetAllProfilesAttributes() override; | 196 std::vector<ProfileAttributesEntry*> GetAllProfilesAttributes() override; |
195 bool GetProfileAttributesWithPath(const base::FilePath& path, | 197 bool GetProfileAttributesWithPath(const base::FilePath& path, |
196 ProfileAttributesEntry** entry) override; | 198 ProfileAttributesEntry** entry) override; |
197 | 199 |
198 private: | 200 private: |
199 FRIEND_TEST_ALL_PREFIXES(ProfileInfoCacheTest, DownloadHighResAvatarTest); | 201 FRIEND_TEST_ALL_PREFIXES(ProfileInfoCacheTest, DownloadHighResAvatarTest); |
200 FRIEND_TEST_ALL_PREFIXES(ProfileInfoCacheTest, | 202 FRIEND_TEST_ALL_PREFIXES(ProfileInfoCacheTest, |
201 NothingToDownloadHighResAvatarTest); | 203 NothingToDownloadHighResAvatarTest); |
202 | 204 |
203 const base::DictionaryValue* GetInfoForProfileAtIndex(size_t index) const; | 205 const base::DictionaryValue* GetInfoForProfileAtIndex(size_t index) const; |
204 // Saves the profile info to a cache and takes ownership of |info|. | 206 // Saves the profile info to a cache. |
205 void SetInfoForProfileAtIndex(size_t index, base::DictionaryValue* info); | 207 void SetInfoForProfileAtIndex(size_t index, |
| 208 std::unique_ptr<base::DictionaryValue> info); |
206 std::string CacheKeyFromProfilePath(const base::FilePath& profile_path) const; | 209 std::string CacheKeyFromProfilePath(const base::FilePath& profile_path) const; |
207 std::vector<std::string>::iterator FindPositionForProfile( | 210 std::vector<std::string>::iterator FindPositionForProfile( |
208 const std::string& search_key, | 211 const std::string& search_key, |
209 const base::string16& search_name); | 212 const base::string16& search_name); |
210 | 213 |
211 // Updates the position of the profile at the given index so that the list | 214 // Updates the position of the profile at the given index so that the list |
212 // of profiles is still sorted. | 215 // of profiles is still sorted. |
213 void UpdateSortForProfileIndex(size_t index); | 216 void UpdateSortForProfileIndex(size_t index); |
214 | 217 |
215 // Loads or uses an already loaded high resolution image of the | 218 // Loads or uses an already loaded high resolution image of the |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 avatar_images_downloads_in_progress_; | 267 avatar_images_downloads_in_progress_; |
265 | 268 |
266 // Determines of the ProfileAvatarDownloader should be created and executed | 269 // Determines of the ProfileAvatarDownloader should be created and executed |
267 // or not. Only set to true for tests. | 270 // or not. Only set to true for tests. |
268 bool disable_avatar_download_for_testing_; | 271 bool disable_avatar_download_for_testing_; |
269 | 272 |
270 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); | 273 DISALLOW_COPY_AND_ASSIGN(ProfileInfoCache); |
271 }; | 274 }; |
272 | 275 |
273 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ | 276 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_H_ |
OLD | NEW |