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

Side by Side Diff: components/wallpaper/wallpaper_manager_base.cc

Issue 1794323003: Make user_manager::UserImage non-copyable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: just rebase Created 4 years, 8 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 | « components/wallpaper/wallpaper_manager_base.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "components/wallpaper/wallpaper_manager_base.h" 5 #include "components/wallpaper/wallpaper_manager_base.h"
6 6
7 #include <numeric> 7 #include <numeric>
8 #include <vector> 8 #include <vector>
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 delay = base::TimeDelta::FromMilliseconds(0); 903 delay = base::TimeDelta::FromMilliseconds(0);
904 else if (interval > base::TimeDelta::FromMilliseconds(0)) 904 else if (interval > base::TimeDelta::FromMilliseconds(0))
905 delay -= interval; 905 delay -= interval;
906 } 906 }
907 return delay; 907 return delay;
908 } 908 }
909 909
910 void WallpaperManagerBase::OnCustomizedDefaultWallpaperDecoded( 910 void WallpaperManagerBase::OnCustomizedDefaultWallpaperDecoded(
911 const GURL& wallpaper_url, 911 const GURL& wallpaper_url,
912 scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files, 912 scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files,
913 const user_manager::UserImage& wallpaper) { 913 scoped_ptr<user_manager::UserImage> wallpaper) {
914 DCHECK(thread_checker_.CalledOnValidThread()); 914 DCHECK(thread_checker_.CalledOnValidThread());
915 915
916 // If decoded wallpaper is empty, we have probably failed to decode the file. 916 // If decoded wallpaper is empty, we have probably failed to decode the file.
917 if (wallpaper.image().isNull()) { 917 if (wallpaper->image().isNull()) {
918 LOG(WARNING) << "Failed to decode customized wallpaper."; 918 LOG(WARNING) << "Failed to decode customized wallpaper.";
919 return; 919 return;
920 } 920 }
921 921
922 wallpaper.image().EnsureRepsForSupportedScales(); 922 wallpaper->image().EnsureRepsForSupportedScales();
923 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.image().DeepCopy()); 923 // TODO(crbug.com/593251): DeepCopy() may be unnecessary as this function
924 // owns |wallpaper| as scoped_ptr whereas it used to be a const reference.
925 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper->image().DeepCopy());
924 926
925 scoped_ptr<bool> success(new bool(false)); 927 scoped_ptr<bool> success(new bool(false));
926 scoped_ptr<gfx::ImageSkia> small_wallpaper_image(new gfx::ImageSkia); 928 scoped_ptr<gfx::ImageSkia> small_wallpaper_image(new gfx::ImageSkia);
927 scoped_ptr<gfx::ImageSkia> large_wallpaper_image(new gfx::ImageSkia); 929 scoped_ptr<gfx::ImageSkia> large_wallpaper_image(new gfx::ImageSkia);
928 930
929 // TODO(bshe): This may break if Bytes becomes RefCountedMemory. 931 // TODO(bshe): This may break if Bytes becomes RefCountedMemory.
930 base::Closure resize_closure = base::Bind( 932 base::Closure resize_closure = base::Bind(
931 &WallpaperManagerBase::ResizeCustomizedDefaultWallpaper, 933 &WallpaperManagerBase::ResizeCustomizedDefaultWallpaper,
932 base::Passed(&deep_copy), wallpaper.image_bytes(), 934 // TODO(crbug.com/593251): Remove the data copy via image_bytes().
935 base::Passed(&deep_copy), wallpaper->image_bytes(),
933 base::Unretained(rescaled_files.get()), base::Unretained(success.get()), 936 base::Unretained(rescaled_files.get()), base::Unretained(success.get()),
934 base::Unretained(small_wallpaper_image.get()), 937 base::Unretained(small_wallpaper_image.get()),
935 base::Unretained(large_wallpaper_image.get())); 938 base::Unretained(large_wallpaper_image.get()));
936 base::Closure on_resized_closure = base::Bind( 939 base::Closure on_resized_closure = base::Bind(
937 &WallpaperManagerBase::OnCustomizedDefaultWallpaperResized, 940 &WallpaperManagerBase::OnCustomizedDefaultWallpaperResized,
938 weak_factory_.GetWeakPtr(), wallpaper_url, 941 weak_factory_.GetWeakPtr(), wallpaper_url,
939 base::Passed(std::move(rescaled_files)), base::Passed(std::move(success)), 942 base::Passed(std::move(rescaled_files)), base::Passed(std::move(success)),
940 base::Passed(std::move(small_wallpaper_image)), 943 base::Passed(std::move(small_wallpaper_image)),
941 base::Passed(std::move(large_wallpaper_image))); 944 base::Passed(std::move(large_wallpaper_image)));
942 945
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 void WallpaperManagerBase::CreateSolidDefaultWallpaper() { 1009 void WallpaperManagerBase::CreateSolidDefaultWallpaper() {
1007 loaded_wallpapers_for_test_++; 1010 loaded_wallpapers_for_test_++;
1008 SkBitmap bitmap; 1011 SkBitmap bitmap;
1009 bitmap.allocN32Pixels(1, 1); 1012 bitmap.allocN32Pixels(1, 1);
1010 bitmap.eraseColor(kDefaultWallpaperColor); 1013 bitmap.eraseColor(kDefaultWallpaperColor);
1011 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); 1014 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
1012 default_wallpaper_image_.reset(new user_manager::UserImage(image)); 1015 default_wallpaper_image_.reset(new user_manager::UserImage(image));
1013 } 1016 }
1014 1017
1015 } // namespace wallpaper 1018 } // namespace wallpaper
OLDNEW
« no previous file with comments | « components/wallpaper/wallpaper_manager_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698