Chromium Code Reviews| Index: chrome/browser/chromeos/login/wallpaper_manager.cc |
| diff --git a/chrome/browser/chromeos/login/wallpaper_manager.cc b/chrome/browser/chromeos/login/wallpaper_manager.cc |
| index 05f307d3d42d9c346c201f9de9b6d02366641065..43243e2d3ae43342e1dcc9dc5c4d32aad8ccce1d 100644 |
| --- a/chrome/browser/chromeos/login/wallpaper_manager.cc |
| +++ b/chrome/browser/chromeos/login/wallpaper_manager.cc |
| @@ -484,25 +484,26 @@ void WallpaperManager::SetCustomWallpaper(const std::string& username, |
| bool is_persistent = ShouldPersistDataForUser(username); |
| - BrowserThread::PostTask( |
| - BrowserThread::FILE, |
| - FROM_HERE, |
| - base::Bind(&WallpaperManager::GenerateUserWallpaperThumbnail, |
| - base::Unretained(this), username, type, delegate, |
| - wallpaper.image())); |
| + wallpaper.image().EnsureRepsForSupportedScaleFactors(); |
| + scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.image().DeepCopy()); |
| - if (is_persistent) { |
| - BrowserThread::PostTask( |
| + WallpaperInfo info = { |
| + wallpaper_path, |
| + layout, |
| + User::CUSTOMIZED, |
|
oshima
2012/11/13 17:46:42
shouldn't this be "type"?
bshe
2012/11/13 21:18:45
Aha. You are right. Sorry.
|
| + base::Time::Now().LocalMidnight() |
|
oshima
2012/11/13 17:46:42
add comment that this isn't used.
bshe
2012/11/13 21:18:45
Done.
|
| + }; |
| + BrowserThread::PostTask( |
| BrowserThread::FILE, |
| FROM_HERE, |
| - base::Bind(&WallpaperManager::SaveCustomWallpaper, |
| + base::Bind(&WallpaperManager::ProcessCustomWallpaper, |
| base::Unretained(this), |
| username, |
| - FilePath(wallpaper_path), |
| - layout, |
| - wallpaper)); |
| - } |
| - |
| + is_persistent, |
| + info, |
| + delegate, |
| + base::Passed(&deep_copy), |
| + wallpaper.raw_image())); |
|
oshima
2012/11/12 16:39:28
Can you remove or update TODO for raw_image()? Thi
bshe
2012/11/12 19:12:48
Good point. Added a TODO.
On 2012/11/12 16:39:28,
|
| ash::Shell::GetInstance()->desktop_background_controller()-> |
| SetCustomWallpaper(wallpaper.image(), layout); |
| @@ -811,9 +812,10 @@ void WallpaperManager::CacheUserWallpaper(const std::string& email) { |
| } |
| void WallpaperManager::CacheThumbnail(const std::string& email, |
| - const gfx::ImageSkia& wallpaper) { |
| + scoped_ptr<gfx::ImageSkia> wallpaper) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| - custom_wallpaper_thumbnail_cache_[email] = GetWallpaperThumbnail(wallpaper); |
| + custom_wallpaper_thumbnail_cache_[email] = |
| + GetWallpaperThumbnail(*wallpaper.get()); |
| } |
| void WallpaperManager::DeleteWallpaperInList( |
| @@ -1164,13 +1166,16 @@ void WallpaperManager::OnWallpaperDecoded(const std::string& email, |
| } |
| return; |
| } |
| + // Generate all reps before passing to another thread. |
| + wallpaper.image().EnsureRepsForSupportedScaleFactors(); |
| + scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.image().DeepCopy()); |
| BrowserThread::PostTask( |
| BrowserThread::FILE, |
| FROM_HERE, |
| base::Bind(&WallpaperManager::CacheThumbnail, |
| base::Unretained(this), email, |
| - wallpaper.image().DeepCopy())); |
| + base::Passed(&deep_copy))); |
| // Only cache user wallpaper at login screen. |
| if (!UserManager::Get()->IsUserLoggedIn()) { |
| wallpaper_cache_.insert(std::make_pair(email, wallpaper.image())); |
| @@ -1181,6 +1186,21 @@ void WallpaperManager::OnWallpaperDecoded(const std::string& email, |
| } |
| } |
| +void WallpaperManager::ProcessCustomWallpaper( |
| + const std::string& email, |
| + bool persistent, |
| + const WallpaperInfo& info, |
| + base::WeakPtr<WallpaperDelegate> delegate, |
| + scoped_ptr<gfx::ImageSkia> image, |
| + const UserImage::RawImage& raw_image) { |
| + UserImage wallpaper(*image.get(), raw_image); |
| + GenerateUserWallpaperThumbnail(email, info.type, delegate, wallpaper.image()); |
| + if (persistent) |
| + SaveCustomWallpaper(email, FilePath(info.file), info.layout, wallpaper); |
| +} |
| + |
| + |
| + |
| void WallpaperManager::OnWallpaperEncoded(const FilePath& path, |
| scoped_refptr<base::RefCountedBytes> data) { |
| SaveWallpaperInternal(path, |