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

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: Rebased. Created 7 years, 1 month 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"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/memory/ref_counted_memory.h" 12 #include "base/memory/ref_counted_memory.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/observer_list.h"
15 #include "base/threading/sequenced_worker_pool.h" 16 #include "base/threading/sequenced_worker_pool.h"
16 #include "base/time/time.h" 17 #include "base/time/time.h"
17 #include "chrome/browser/chromeos/login/user.h" 18 #include "chrome/browser/chromeos/login/user.h"
18 #include "chrome/browser/chromeos/login/user_image.h" 19 #include "chrome/browser/chromeos/login/user_image.h"
19 #include "chrome/browser/chromeos/login/user_image_loader.h" 20 #include "chrome/browser/chromeos/login/user_image_loader.h"
20 #include "chrome/browser/chromeos/settings/cros_settings.h" 21 #include "chrome/browser/chromeos/settings/cros_settings.h"
21 #include "content/public/browser/notification_observer.h" 22 #include "content/public/browser/notification_observer.h"
22 #include "content/public/browser/notification_registrar.h" 23 #include "content/public/browser/notification_registrar.h"
23 #include "third_party/icu/source/i18n/unicode/timezone.h" 24 #include "third_party/icu/source/i18n/unicode/timezone.h"
24 #include "ui/gfx/image/image_skia.h" 25 #include "ui/gfx/image/image_skia.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 virtual ~TestApi(); 74 virtual ~TestApi();
74 75
75 base::FilePath current_wallpaper_path(); 76 base::FilePath current_wallpaper_path();
76 77
77 private: 78 private:
78 WallpaperManager* wallpaper_manager_; // not owned 79 WallpaperManager* wallpaper_manager_; // not owned
79 80
80 DISALLOW_COPY_AND_ASSIGN(TestApi); 81 DISALLOW_COPY_AND_ASSIGN(TestApi);
81 }; 82 };
82 83
84 class Observer {
85 public:
86 virtual ~Observer() {}
87 virtual void OnWallpaperAnimationFinished(const std::string& email) = 0;
88 };
89
83 static WallpaperManager* Get(); 90 static WallpaperManager* Get();
84 91
85 WallpaperManager(); 92 WallpaperManager();
86 virtual ~WallpaperManager(); 93 virtual ~WallpaperManager();
87 94
88 void set_command_line_for_testing(CommandLine* command_line) { 95 void set_command_line_for_testing(CommandLine* command_line) {
89 command_line_for_testing_ = command_line; 96 command_line_for_testing_ = command_line;
90 } 97 }
91 98
92 // Indicates imminent shutdown, allowing the WallpaperManager to remove any 99 // Indicates imminent shutdown, allowing the WallpaperManager to remove any
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 void SetUserWallpaper(const std::string& email); 188 void SetUserWallpaper(const std::string& email);
182 189
183 // Sets wallpaper to |wallpaper|. 190 // Sets wallpaper to |wallpaper|.
184 void SetWallpaperFromImageSkia(const gfx::ImageSkia& wallpaper, 191 void SetWallpaperFromImageSkia(const gfx::ImageSkia& wallpaper,
185 ash::WallpaperLayout layout); 192 ash::WallpaperLayout layout);
186 193
187 // 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
188 // current display's resolution. 195 // current display's resolution.
189 void UpdateWallpaper(); 196 void UpdateWallpaper();
190 197
198 // Adds given observer to the list.
199 void AddObserver(Observer* observer);
200
201 // Removes given observer from the list.
202 void RemoveObserver(Observer* observer);
203
191 private: 204 private:
192 friend class TestApi; 205 friend class TestApi;
193 friend class WallpaperManagerBrowserTest; 206 friend class WallpaperManagerBrowserTest;
194 typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap; 207 typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap;
195 208
196 // The number of wallpapers have loaded. For test only. 209 // The number of wallpapers have loaded. For test only.
197 int loaded_wallpapers() const { return loaded_wallpapers_; } 210 int loaded_wallpapers() const { return loaded_wallpapers_; }
198 211
199 // Cache some (or all) logged in users' wallpapers to memory at login 212 // Cache some (or all) logged in users' wallpapers to memory at login
200 // screen. It should not compete with first wallpaper loading when boot 213 // screen. It should not compete with first wallpaper loading when boot
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 void SaveWallpaperInternal(const base::FilePath& path, const char* data, 312 void SaveWallpaperInternal(const base::FilePath& path, const char* data,
300 int size); 313 int size);
301 314
302 // Starts to load wallpaper at |wallpaper_path|. If |wallpaper_path| is the 315 // Starts to load wallpaper at |wallpaper_path|. If |wallpaper_path| is the
303 // same as |current_wallpaper_path_|, do nothing. Must be called on UI thread. 316 // same as |current_wallpaper_path_|, do nothing. Must be called on UI thread.
304 void StartLoad(const std::string& email, 317 void StartLoad(const std::string& email,
305 const WallpaperInfo& info, 318 const WallpaperInfo& info,
306 bool update_wallpaper, 319 bool update_wallpaper,
307 const base::FilePath& wallpaper_path); 320 const base::FilePath& wallpaper_path);
308 321
322 // Notify all registed observers.
323 void NotifyAnimationFinished();
324
309 // The number of loaded wallpapers. 325 // The number of loaded wallpapers.
310 int loaded_wallpapers_; 326 int loaded_wallpapers_;
311 327
312 // Sequence token associated with wallpaper operations. 328 // Sequence token associated with wallpaper operations.
313 base::SequencedWorkerPool::SequenceToken sequence_token_; 329 base::SequencedWorkerPool::SequenceToken sequence_token_;
314 330
315 // Wallpaper sequenced task runner. 331 // Wallpaper sequenced task runner.
316 scoped_refptr<base::SequencedTaskRunner> task_runner_; 332 scoped_refptr<base::SequencedTaskRunner> task_runner_;
317 333
318 // The file path of current loaded/loading custom/online wallpaper. 334 // The file path of current loaded/loading custom/online wallpaper.
(...skipping 16 matching lines...) Expand all
335 351
336 bool should_cache_wallpaper_; 352 bool should_cache_wallpaper_;
337 353
338 scoped_ptr<CrosSettings::ObserverSubscription> 354 scoped_ptr<CrosSettings::ObserverSubscription>
339 show_user_name_on_signin_subscription_; 355 show_user_name_on_signin_subscription_;
340 356
341 base::WeakPtrFactory<WallpaperManager> weak_factory_; 357 base::WeakPtrFactory<WallpaperManager> weak_factory_;
342 358
343 content::NotificationRegistrar registrar_; 359 content::NotificationRegistrar registrar_;
344 360
361 ObserverList<Observer> observers_;
362
345 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); 363 DISALLOW_COPY_AND_ASSIGN(WallpaperManager);
346 }; 364 };
347 365
348 } // namespace chromeos 366 } // namespace chromeos
349 367
350 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ 368 #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