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

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

Issue 1857683002: Remove image_bytes parameter from ResizeCustomizedDefaultWallpaper() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 913 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 // owns |wallpaper| as scoped_ptr whereas it used to be a const reference. 924 // owns |wallpaper| as scoped_ptr whereas it used to be a const reference.
925 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper->image().DeepCopy()); 925 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper->image().DeepCopy());
926 926
927 scoped_ptr<bool> success(new bool(false)); 927 scoped_ptr<bool> success(new bool(false));
928 scoped_ptr<gfx::ImageSkia> small_wallpaper_image(new gfx::ImageSkia); 928 scoped_ptr<gfx::ImageSkia> small_wallpaper_image(new gfx::ImageSkia);
929 scoped_ptr<gfx::ImageSkia> large_wallpaper_image(new gfx::ImageSkia); 929 scoped_ptr<gfx::ImageSkia> large_wallpaper_image(new gfx::ImageSkia);
930 930
931 // TODO(bshe): This may break if Bytes becomes RefCountedMemory. 931 // TODO(bshe): This may break if Bytes becomes RefCountedMemory.
932 base::Closure resize_closure = base::Bind( 932 base::Closure resize_closure = base::Bind(
933 &WallpaperManagerBase::ResizeCustomizedDefaultWallpaper, 933 &WallpaperManagerBase::ResizeCustomizedDefaultWallpaper,
934 // TODO(crbug.com/593251): Remove the data copy via image_bytes(). 934 base::Passed(&deep_copy),
935 base::Passed(&deep_copy), wallpaper->image_bytes(),
936 base::Unretained(rescaled_files.get()), base::Unretained(success.get()), 935 base::Unretained(rescaled_files.get()), base::Unretained(success.get()),
937 base::Unretained(small_wallpaper_image.get()), 936 base::Unretained(small_wallpaper_image.get()),
938 base::Unretained(large_wallpaper_image.get())); 937 base::Unretained(large_wallpaper_image.get()));
939 base::Closure on_resized_closure = base::Bind( 938 base::Closure on_resized_closure = base::Bind(
940 &WallpaperManagerBase::OnCustomizedDefaultWallpaperResized, 939 &WallpaperManagerBase::OnCustomizedDefaultWallpaperResized,
941 weak_factory_.GetWeakPtr(), wallpaper_url, 940 weak_factory_.GetWeakPtr(), wallpaper_url,
942 base::Passed(std::move(rescaled_files)), base::Passed(std::move(success)), 941 base::Passed(std::move(rescaled_files)), base::Passed(std::move(success)),
943 base::Passed(std::move(small_wallpaper_image)), 942 base::Passed(std::move(small_wallpaper_image)),
944 base::Passed(std::move(large_wallpaper_image))); 943 base::Passed(std::move(large_wallpaper_image)));
945 944
946 if (!task_runner_->PostTaskAndReply(FROM_HERE, resize_closure, 945 if (!task_runner_->PostTaskAndReply(FROM_HERE, resize_closure,
947 on_resized_closure)) { 946 on_resized_closure)) {
948 LOG(WARNING) << "Failed to start Customized Wallpaper resize."; 947 LOG(WARNING) << "Failed to start Customized Wallpaper resize.";
949 } 948 }
950 } 949 }
951 950
952 void WallpaperManagerBase::ResizeCustomizedDefaultWallpaper( 951 void WallpaperManagerBase::ResizeCustomizedDefaultWallpaper(
953 scoped_ptr<gfx::ImageSkia> image, 952 scoped_ptr<gfx::ImageSkia> image,
954 const user_manager::UserImage::Bytes& image_bytes,
955 const CustomizedWallpaperRescaledFiles* rescaled_files, 953 const CustomizedWallpaperRescaledFiles* rescaled_files,
956 bool* success, 954 bool* success,
957 gfx::ImageSkia* small_wallpaper_image, 955 gfx::ImageSkia* small_wallpaper_image,
958 gfx::ImageSkia* large_wallpaper_image) { 956 gfx::ImageSkia* large_wallpaper_image) {
959 *success = true; 957 *success = true;
960 958
961 *success &= ResizeAndSaveWallpaper( 959 *success &= ResizeAndSaveWallpaper(
962 *image, rescaled_files->path_rescaled_small(), WALLPAPER_LAYOUT_STRETCH, 960 *image, rescaled_files->path_rescaled_small(), WALLPAPER_LAYOUT_STRETCH,
963 kSmallWallpaperMaxWidth, kSmallWallpaperMaxHeight, small_wallpaper_image); 961 kSmallWallpaperMaxWidth, kSmallWallpaperMaxHeight, small_wallpaper_image);
964 962
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 void WallpaperManagerBase::CreateSolidDefaultWallpaper() { 1007 void WallpaperManagerBase::CreateSolidDefaultWallpaper() {
1010 loaded_wallpapers_for_test_++; 1008 loaded_wallpapers_for_test_++;
1011 SkBitmap bitmap; 1009 SkBitmap bitmap;
1012 bitmap.allocN32Pixels(1, 1); 1010 bitmap.allocN32Pixels(1, 1);
1013 bitmap.eraseColor(kDefaultWallpaperColor); 1011 bitmap.eraseColor(kDefaultWallpaperColor);
1014 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); 1012 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
1015 default_wallpaper_image_.reset(new user_manager::UserImage(image)); 1013 default_wallpaper_image_.reset(new user_manager::UserImage(image));
1016 } 1014 }
1017 1015
1018 } // namespace wallpaper 1016 } // 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