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

Unified Diff: ash/desktop_background/desktop_background_controller.cc

Issue 10827154: Preload default wallpaper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use DCHECK replace if cause. Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: ash/desktop_background/desktop_background_controller.cc
diff --git a/ash/desktop_background/desktop_background_controller.cc b/ash/desktop_background/desktop_background_controller.cc
index de3a1211b8871c2f4fdcb0b1e7ad644799172445..9cb17206fb331ce398fefa3936d2b106a8c8ae35 100644
--- a/ash/desktop_background/desktop_background_controller.cc
+++ b/ash/desktop_background/desktop_background_controller.cc
@@ -150,6 +150,18 @@ void DesktopBackgroundController::OnRootWindowAdded(
InstallComponent(root_window);
}
+void DesktopBackgroundController::CacheDefaultWallpaper(int index) {
+ DCHECK(index >= 0);
+
+ WallpaperResolution resolution = GetAppropriateResolution();
+ scoped_refptr<WallpaperOperation> wallpaper_op =
+ new WallpaperOperation(index, resolution);
+ base::WorkerPool::PostTask(
+ FROM_HERE,
+ base::Bind(&WallpaperOperation::Run, wallpaper_op),
+ true);
+}
+
void DesktopBackgroundController::SetDefaultWallpaper(int index,
bool force_reload) {
// We should not change background when index is invalid. For instance, at
@@ -168,15 +180,7 @@ void DesktopBackgroundController::SetDefaultWallpaper(int index,
CancelPendingWallpaperOperation();
- WallpaperResolution resolution = SMALL;
- Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
- for (Shell::RootWindowList::iterator iter = root_windows.begin();
- iter != root_windows.end(); ++iter) {
- gfx::Size root_window_size = (*iter)->GetHostSize();
- if (root_window_size.width() > kSmallWallpaperMaximalWidth ||
- root_window_size.height() > kSmallWallpaperMaximalHeight)
- resolution = LARGE;
- }
+ WallpaperResolution resolution = GetAppropriateResolution();
wallpaper_op_ = new WallpaperOperation(index, resolution);
base::WorkerPool::PostTaskAndReply(
@@ -354,4 +358,17 @@ int DesktopBackgroundController::GetBackgroundContainerId(bool locked) {
internal::kShellWindowId_DesktopBackgroundContainer;
}
+WallpaperResolution DesktopBackgroundController::GetAppropriateResolution() {
+ WallpaperResolution resolution = SMALL;
+ Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
+ for (Shell::RootWindowList::iterator iter = root_windows.begin();
+ iter != root_windows.end(); ++iter) {
+ gfx::Size root_window_size = (*iter)->GetHostSize();
+ if (root_window_size.width() > kSmallWallpaperMaximalWidth ||
+ root_window_size.height() > kSmallWallpaperMaximalHeight)
+ resolution = LARGE;
+ }
+ return resolution;
+}
+
} // namespace ash
« no previous file with comments | « ash/desktop_background/desktop_background_controller.h ('k') | chrome/browser/chromeos/login/user_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698