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

Side by Side Diff: chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h

Issue 1010443003: Make the lifetime of wallpaper manager more clear. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the failed unittests. Created 5 years, 9 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 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_WALLPAPER_WALLPAPER_MANAGER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 19 matching lines...) Expand all
30 #include "ui/gfx/image/image_skia.h" 30 #include "ui/gfx/image/image_skia.h"
31 31
32 namespace chromeos { 32 namespace chromeos {
33 33
34 class WallpaperManager : 34 class WallpaperManager :
35 public wallpaper::WallpaperManagerBase, 35 public wallpaper::WallpaperManagerBase,
36 public user_manager::UserManager::UserSessionStateObserver { 36 public user_manager::UserManager::UserSessionStateObserver {
37 public: 37 public:
38 class PendingWallpaper; 38 class PendingWallpaper;
39 39
40 WallpaperManager();
41 ~WallpaperManager() override; 40 ~WallpaperManager() override;
42 41
43 // Get pointer to singleton WallpaperManager instance, create it if necessary. 42 // Creates an instance of Wallpaper Manager. If there is no instance, create
43 // one. Otherwise, returns the existing instance.
44 static void Initialize();
45
46 // Gets pointer to singleton WallpaperManager instance.
44 static WallpaperManager* Get(); 47 static WallpaperManager* Get();
45 48
49 // Deletes the existing instance of WallpaperManager. Allows the
50 // WallpaperManager to remove any observers it has registered.
51 static void Shutdown();
52
46 // Returns the appropriate wallpaper resolution for all root windows. 53 // Returns the appropriate wallpaper resolution for all root windows.
47 WallpaperResolution GetAppropriateResolution() override; 54 WallpaperResolution GetAppropriateResolution() override;
48 55
49 // Indicates imminent shutdown, allowing the WallpaperManager to remove any
50 // observers it has registered.
51 void Shutdown() override;
52
53 // Adds PowerManagerClient, TimeZoneSettings and CrosSettings observers. 56 // Adds PowerManagerClient, TimeZoneSettings and CrosSettings observers.
54 void AddObservers() override; 57 void AddObservers() override;
55 58
56 // Loads wallpaper asynchronously if the current wallpaper is not the 59 // Loads wallpaper asynchronously if the current wallpaper is not the
57 // wallpaper of logged in user. 60 // wallpaper of logged in user.
58 void EnsureLoggedInUserWallpaperLoaded() override; 61 void EnsureLoggedInUserWallpaperLoaded() override;
59 62
60 // Initializes wallpaper. If logged in, loads user's wallpaper. If not logged 63 // Initializes wallpaper. If logged in, loads user's wallpaper. If not logged
61 // in, uses a solid color wallpaper. If logged in as a stub user, uses an 64 // in, uses a solid color wallpaper. If logged in as a stub user, uses an
62 // empty wallpaper. 65 // empty wallpaper.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 123
121 // Overridden from user_manager::UserManager::UserSessionStateObserver: 124 // Overridden from user_manager::UserManager::UserSessionStateObserver:
122 void UserChangedChildStatus(user_manager::User* user) override; 125 void UserChangedChildStatus(user_manager::User* user) override;
123 126
124 private: 127 private:
125 friend class TestApi; 128 friend class TestApi;
126 friend class WallpaperManagerBrowserTest; 129 friend class WallpaperManagerBrowserTest;
127 friend class WallpaperManagerBrowserTestDefaultWallpaper; 130 friend class WallpaperManagerBrowserTestDefaultWallpaper;
128 friend class WallpaperManagerPolicyTest; 131 friend class WallpaperManagerPolicyTest;
129 132
133 WallpaperManager();
134
130 // Returns modifiable PendingWallpaper. 135 // Returns modifiable PendingWallpaper.
131 // Returns pending_inactive_ or creates new PendingWallpaper if necessary. 136 // Returns pending_inactive_ or creates new PendingWallpaper if necessary.
132 PendingWallpaper* GetPendingWallpaper(const std::string& user_id, 137 PendingWallpaper* GetPendingWallpaper(const std::string& user_id,
133 bool delayed); 138 bool delayed);
134 139
135 // This is called by PendingWallpaper when load is finished. 140 // This is called by PendingWallpaper when load is finished.
136 void RemovePendingWallpaperFromList(PendingWallpaper* pending); 141 void RemovePendingWallpaperFromList(PendingWallpaper* pending);
137 142
138 // WallpaperManagerBase overrides: 143 // WallpaperManagerBase overrides:
139 void ClearObsoleteWallpaperPrefs() override; 144 void ClearObsoleteWallpaperPrefs() override;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 typedef std::vector<scoped_refptr<PendingWallpaper> > PendingList; 198 typedef std::vector<scoped_refptr<PendingWallpaper> > PendingList;
194 PendingList loading_; 199 PendingList loading_;
195 200
196 base::WeakPtrFactory<WallpaperManager> weak_factory_; 201 base::WeakPtrFactory<WallpaperManager> weak_factory_;
197 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); 202 DISALLOW_COPY_AND_ASSIGN(WallpaperManager);
198 }; 203 };
199 204
200 } // namespace chromeos 205 } // namespace chromeos
201 206
202 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_ 207 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698