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

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

Issue 24625003: Delay wallpaper load by 2 * average wallpaper load time. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Catch WallpaperAnimationFinished event and inform JS. Created 7 years, 2 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/wallpaper_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_WALLPAPER_MANAGER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "ash/desktop_background/desktop_background_controller.h" 10 #include "ash/desktop_background/desktop_background_controller.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 extern const char kLargeWallpaperSuffix[]; 57 extern const char kLargeWallpaperSuffix[];
58 58
59 // Directory names of custom wallpapers. 59 // Directory names of custom wallpapers.
60 extern const char kSmallWallpaperSubDir[]; 60 extern const char kSmallWallpaperSubDir[];
61 extern const char kLargeWallpaperSubDir[]; 61 extern const char kLargeWallpaperSubDir[];
62 extern const char kOriginalWallpaperSubDir[]; 62 extern const char kOriginalWallpaperSubDir[];
63 extern const char kThumbnailWallpaperSubDir[]; 63 extern const char kThumbnailWallpaperSubDir[];
64 64
65 // This class maintains wallpapers for users who have logged into this Chrome 65 // This class maintains wallpapers for users who have logged into this Chrome
66 // OS device. 66 // OS device.
67 class WallpaperManager: public content::NotificationObserver { 67 class WallpaperManager : public content::NotificationObserver {
68 public: 68 public:
69 // For testing. 69 // For testing.
70 class TestApi { 70 class TestApi {
71 public: 71 public:
72 explicit TestApi(WallpaperManager* wallpaper_manager); 72 explicit TestApi(WallpaperManager* wallpaper_manager);
73 virtual ~TestApi(); 73 virtual ~TestApi();
74 74
75 base::FilePath current_wallpaper_path(); 75 base::FilePath current_wallpaper_path();
76 76
77 private: 77 private:
78 WallpaperManager* wallpaper_manager_; // not owned 78 WallpaperManager* wallpaper_manager_; // not owned
79 79
80 DISALLOW_COPY_AND_ASSIGN(TestApi); 80 DISALLOW_COPY_AND_ASSIGN(TestApi);
81 }; 81 };
82 82
83 class Observer : public base::RefCounted<Observer> {
84 public:
85 virtual ~Observer() {};
86 virtual void OnWallpaperAnimationFinished(const std::string& email) = 0;
87 };
88
89 typedef std::list<base::WeakPtr<Observer> > ObserverList;
dzhioev (left Google) 2013/10/17 12:47:49 Use ObserverList from base/observer_list.h
90
83 static WallpaperManager* Get(); 91 static WallpaperManager* Get();
84 92
85 WallpaperManager(); 93 WallpaperManager();
86 virtual ~WallpaperManager(); 94 virtual ~WallpaperManager();
87 95
88 void set_command_line_for_testing(CommandLine* command_line) { 96 void set_command_line_for_testing(CommandLine* command_line) {
89 command_line_for_testing_ = command_line; 97 command_line_for_testing_ = command_line;
90 } 98 }
91 99
92 // Indicates imminent shutdown, allowing the WallpaperManager to remove any 100 // Indicates imminent shutdown, allowing the WallpaperManager to remove any
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 void SetUserWallpaper(const std::string& email); 188 void SetUserWallpaper(const std::string& email);
181 189
182 // Sets wallpaper to |wallpaper|. 190 // Sets wallpaper to |wallpaper|.
183 void SetWallpaperFromImageSkia(const gfx::ImageSkia& wallpaper, 191 void SetWallpaperFromImageSkia(const gfx::ImageSkia& wallpaper,
184 ash::WallpaperLayout layout); 192 ash::WallpaperLayout layout);
185 193
186 // Updates current wallpaper. It may switch the size of wallpaper based on the 194 // Updates current wallpaper. It may switch the size of wallpaper based on the
187 // current display's resolution. 195 // current display's resolution.
188 void UpdateWallpaper(); 196 void UpdateWallpaper();
189 197
198 // Adds given observer to the list.
199 void AddObserver(base::WeakPtr<Observer> observer);
200
190 private: 201 private:
191 friend class TestApi; 202 friend class TestApi;
192 friend class WallpaperManagerBrowserTest; 203 friend class WallpaperManagerBrowserTest;
193 typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap; 204 typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap;
194 205
195 // The number of wallpapers have loaded. For test only. 206 // The number of wallpapers have loaded. For test only.
196 int loaded_wallpapers() const { return loaded_wallpapers_; } 207 int loaded_wallpapers() const { return loaded_wallpapers_; }
197 208
198 // Cache some (or all) logged in users' wallpapers to memory at login 209 // Cache some (or all) logged in users' wallpapers to memory at login
199 // screen. It should not compete with first wallpaper loading when boot 210 // screen. It should not compete with first wallpaper loading when boot
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 void SaveWallpaperInternal(const base::FilePath& path, const char* data, 291 void SaveWallpaperInternal(const base::FilePath& path, const char* data,
281 int size); 292 int size);
282 293
283 // Starts to load wallpaper at |wallpaper_path|. If |wallpaper_path| is the 294 // Starts to load wallpaper at |wallpaper_path|. If |wallpaper_path| is the
284 // same as |current_wallpaper_path_|, do nothing. Must be called on UI thread. 295 // same as |current_wallpaper_path_|, do nothing. Must be called on UI thread.
285 void StartLoad(const std::string& email, 296 void StartLoad(const std::string& email,
286 const WallpaperInfo& info, 297 const WallpaperInfo& info,
287 bool update_wallpaper, 298 bool update_wallpaper,
288 const base::FilePath& wallpaper_path); 299 const base::FilePath& wallpaper_path);
289 300
301 // Notify all registed observers.
302 void NotifyAnimationFinished();
303
290 // The number of loaded wallpapers. 304 // The number of loaded wallpapers.
291 int loaded_wallpapers_; 305 int loaded_wallpapers_;
292 306
293 // Sequence token associated with wallpaper operations. 307 // Sequence token associated with wallpaper operations.
294 base::SequencedWorkerPool::SequenceToken sequence_token_; 308 base::SequencedWorkerPool::SequenceToken sequence_token_;
295 309
296 // Wallpaper sequenced task runner. 310 // Wallpaper sequenced task runner.
297 scoped_refptr<base::SequencedTaskRunner> task_runner_; 311 scoped_refptr<base::SequencedTaskRunner> task_runner_;
298 312
299 // The file path of current loaded/loading custom/online wallpaper. 313 // The file path of current loaded/loading custom/online wallpaper.
(...skipping 16 matching lines...) Expand all
316 330
317 bool should_cache_wallpaper_; 331 bool should_cache_wallpaper_;
318 332
319 scoped_ptr<CrosSettings::ObserverSubscription> 333 scoped_ptr<CrosSettings::ObserverSubscription>
320 show_user_name_on_signin_subscription_; 334 show_user_name_on_signin_subscription_;
321 335
322 base::WeakPtrFactory<WallpaperManager> weak_factory_; 336 base::WeakPtrFactory<WallpaperManager> weak_factory_;
323 337
324 content::NotificationRegistrar registrar_; 338 content::NotificationRegistrar registrar_;
325 339
340 ObserverList observers_;
341
326 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); 342 DISALLOW_COPY_AND_ASSIGN(WallpaperManager);
327 }; 343 };
328 344
329 } // namespace chromeos 345 } // namespace chromeos
330 346
331 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ 347 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/wallpaper_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698