| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_MANAGER_IMPL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_MANAGER_IMPL_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_MANAGER_IMPL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_MANAGER_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 class UserImageManagerImpl | 42 class UserImageManagerImpl |
| 43 : public UserImageManager, | 43 : public UserImageManager, |
| 44 public ProfileDownloaderDelegate { | 44 public ProfileDownloaderDelegate { |
| 45 public: | 45 public: |
| 46 // UserImageManager: | 46 // UserImageManager: |
| 47 UserImageManagerImpl(const std::string& user_id, | 47 UserImageManagerImpl(const std::string& user_id, |
| 48 user_manager::UserManager* user_manager); | 48 user_manager::UserManager* user_manager); |
| 49 virtual ~UserImageManagerImpl(); | 49 virtual ~UserImageManagerImpl(); |
| 50 | 50 |
| 51 virtual void LoadUserImage() OVERRIDE; | 51 virtual void LoadUserImage() override; |
| 52 virtual void UserLoggedIn(bool user_is_new, bool user_is_local) OVERRIDE; | 52 virtual void UserLoggedIn(bool user_is_new, bool user_is_local) override; |
| 53 virtual void SaveUserDefaultImageIndex(int default_image_index) OVERRIDE; | 53 virtual void SaveUserDefaultImageIndex(int default_image_index) override; |
| 54 virtual void SaveUserImage( | 54 virtual void SaveUserImage( |
| 55 const user_manager::UserImage& user_image) OVERRIDE; | 55 const user_manager::UserImage& user_image) override; |
| 56 virtual void SaveUserImageFromFile(const base::FilePath& path) OVERRIDE; | 56 virtual void SaveUserImageFromFile(const base::FilePath& path) override; |
| 57 virtual void SaveUserImageFromProfileImage() OVERRIDE; | 57 virtual void SaveUserImageFromProfileImage() override; |
| 58 virtual void DeleteUserImage() OVERRIDE; | 58 virtual void DeleteUserImage() override; |
| 59 virtual void DownloadProfileImage(const std::string& reason) OVERRIDE; | 59 virtual void DownloadProfileImage(const std::string& reason) override; |
| 60 virtual const gfx::ImageSkia& DownloadedProfileImage() const OVERRIDE; | 60 virtual const gfx::ImageSkia& DownloadedProfileImage() const override; |
| 61 virtual UserImageSyncObserver* GetSyncObserver() const OVERRIDE; | 61 virtual UserImageSyncObserver* GetSyncObserver() const override; |
| 62 virtual void Shutdown() OVERRIDE; | 62 virtual void Shutdown() override; |
| 63 | 63 |
| 64 virtual void OnExternalDataSet(const std::string& policy) OVERRIDE; | 64 virtual void OnExternalDataSet(const std::string& policy) override; |
| 65 virtual void OnExternalDataCleared(const std::string& policy) OVERRIDE; | 65 virtual void OnExternalDataCleared(const std::string& policy) override; |
| 66 virtual void OnExternalDataFetched(const std::string& policy, | 66 virtual void OnExternalDataFetched(const std::string& policy, |
| 67 scoped_ptr<std::string> data) OVERRIDE; | 67 scoped_ptr<std::string> data) override; |
| 68 | 68 |
| 69 static void IgnoreProfileDataDownloadDelayForTesting(); | 69 static void IgnoreProfileDataDownloadDelayForTesting(); |
| 70 | 70 |
| 71 private: | 71 private: |
| 72 friend class UserImageManagerTest; | 72 friend class UserImageManagerTest; |
| 73 | 73 |
| 74 // Every image load or update is encapsulated by a Job. Whenever an image load | 74 // Every image load or update is encapsulated by a Job. Whenever an image load |
| 75 // or update is requested for a user, the Job currently running for that user | 75 // or update is requested for a user, the Job currently running for that user |
| 76 // (if any) is canceled. This ensures that at most one Job is running per user | 76 // (if any) is canceled. This ensures that at most one Job is running per user |
| 77 // at any given time. There are two further guarantees: | 77 // at any given time. There are two further guarantees: |
| 78 // | 78 // |
| 79 // * Changes to User objects and local state are performed on the thread that | 79 // * Changes to User objects and local state are performed on the thread that |
| 80 // |this| runs on. | 80 // |this| runs on. |
| 81 // * File writes and deletions are performed via |background_task_runner_|. | 81 // * File writes and deletions are performed via |background_task_runner_|. |
| 82 // | 82 // |
| 83 // With the above, it is guaranteed that any changes made by a canceled Job | 83 // With the above, it is guaranteed that any changes made by a canceled Job |
| 84 // cannot race against against changes made by the superseding Job. | 84 // cannot race against against changes made by the superseding Job. |
| 85 class Job; | 85 class Job; |
| 86 | 86 |
| 87 // ProfileDownloaderDelegate: | 87 // ProfileDownloaderDelegate: |
| 88 virtual bool NeedsProfilePicture() const OVERRIDE; | 88 virtual bool NeedsProfilePicture() const override; |
| 89 virtual int GetDesiredImageSideLength() const OVERRIDE; | 89 virtual int GetDesiredImageSideLength() const override; |
| 90 virtual Profile* GetBrowserProfile() OVERRIDE; | 90 virtual Profile* GetBrowserProfile() override; |
| 91 virtual std::string GetCachedPictureURL() const OVERRIDE; | 91 virtual std::string GetCachedPictureURL() const override; |
| 92 virtual void OnProfileDownloadSuccess(ProfileDownloader* downloader) OVERRIDE; | 92 virtual void OnProfileDownloadSuccess(ProfileDownloader* downloader) override; |
| 93 virtual void OnProfileDownloadFailure( | 93 virtual void OnProfileDownloadFailure( |
| 94 ProfileDownloader* downloader, | 94 ProfileDownloader* downloader, |
| 95 ProfileDownloaderDelegate::FailureReason reason) OVERRIDE; | 95 ProfileDownloaderDelegate::FailureReason reason) override; |
| 96 | 96 |
| 97 // Returns true if the user image for the user is managed by | 97 // Returns true if the user image for the user is managed by |
| 98 // policy and the user is not allowed to change it. | 98 // policy and the user is not allowed to change it. |
| 99 bool IsUserImageManaged() const; | 99 bool IsUserImageManaged() const; |
| 100 | 100 |
| 101 // Randomly chooses one of the default images for the specified user, sends a | 101 // Randomly chooses one of the default images for the specified user, sends a |
| 102 // LOGIN_USER_IMAGE_CHANGED notification and updates local state. | 102 // LOGIN_USER_IMAGE_CHANGED notification and updates local state. |
| 103 void SetInitialUserImage(); | 103 void SetInitialUserImage(); |
| 104 | 104 |
| 105 // Initializes the |downloaded_profile_image_| for the currently logged-in | 105 // Initializes the |downloaded_profile_image_| for the currently logged-in |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 bool user_needs_migration_; | 218 bool user_needs_migration_; |
| 219 | 219 |
| 220 base::WeakPtrFactory<UserImageManagerImpl> weak_factory_; | 220 base::WeakPtrFactory<UserImageManagerImpl> weak_factory_; |
| 221 | 221 |
| 222 DISALLOW_COPY_AND_ASSIGN(UserImageManagerImpl); | 222 DISALLOW_COPY_AND_ASSIGN(UserImageManagerImpl); |
| 223 }; | 223 }; |
| 224 | 224 |
| 225 } // namespace chromeos | 225 } // namespace chromeos |
| 226 | 226 |
| 227 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_MANAGER_IMPL_H_ | 227 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_MANAGER_IMPL_H_ |
| OLD | NEW |