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

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

Issue 2338363002: Replace single-threaded SequencedWorkerPool with base::Thread in WallpaperResizerTest. (Closed)
Patch Set: Created 4 years, 3 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
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 #include "components/wallpaper/wallpaper_resizer.h" 5 #include "components/wallpaper/wallpaper_resizer.h"
6 6
7 #include <utility>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/location.h" 10 #include "base/location.h"
9 #include "base/logging.h" 11 #include "base/logging.h"
10 #include "base/task_runner.h" 12 #include "base/task_runner.h"
11 #include "components/wallpaper/wallpaper_resizer_observer.h" 13 #include "components/wallpaper/wallpaper_resizer_observer.h"
12 #include "third_party/skia/include/core/SkImage.h" 14 #include "third_party/skia/include/core/SkImage.h"
13 #include "ui/gfx/image/image_skia_rep.h" 15 #include "ui/gfx/image/image_skia_rep.h"
14 #include "ui/gfx/skia_util.h" 16 #include "ui/gfx/skia_util.h"
15 17
16 namespace wallpaper { 18 namespace wallpaper {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // static 100 // static
99 uint32_t WallpaperResizer::GetImageId(const gfx::ImageSkia& image) { 101 uint32_t WallpaperResizer::GetImageId(const gfx::ImageSkia& image) {
100 const gfx::ImageSkiaRep& image_rep = image.GetRepresentation(1.0f); 102 const gfx::ImageSkiaRep& image_rep = image.GetRepresentation(1.0f);
101 return image_rep.is_null() ? 0 : image_rep.sk_bitmap().getGenerationID(); 103 return image_rep.is_null() ? 0 : image_rep.sk_bitmap().getGenerationID();
102 } 104 }
103 105
104 WallpaperResizer::WallpaperResizer( 106 WallpaperResizer::WallpaperResizer(
105 const gfx::ImageSkia& image, 107 const gfx::ImageSkia& image,
106 const gfx::Size& target_size, 108 const gfx::Size& target_size,
107 WallpaperLayout layout, 109 WallpaperLayout layout,
108 const scoped_refptr<base::TaskRunner>& task_runner) 110 scoped_refptr<base::TaskRunner> task_runner)
109 : image_(image), 111 : image_(image),
110 original_image_id_(GetImageId(image_)), 112 original_image_id_(GetImageId(image_)),
111 target_size_(target_size), 113 target_size_(target_size),
112 layout_(layout), 114 layout_(layout),
113 task_runner_(task_runner), 115 task_runner_(std::move(task_runner)),
114 weak_ptr_factory_(this) { 116 weak_ptr_factory_(this) {
115 image_.MakeThreadSafe(); 117 image_.MakeThreadSafe();
116 } 118 }
117 119
118 WallpaperResizer::~WallpaperResizer() { 120 WallpaperResizer::~WallpaperResizer() {
119 } 121 }
120 122
121 void WallpaperResizer::StartResize() { 123 void WallpaperResizer::StartResize() {
122 SkBitmap* resized_bitmap = new SkBitmap; 124 SkBitmap* resized_bitmap = new SkBitmap;
123 if (!task_runner_->PostTaskAndReply( 125 if (!task_runner_->PostTaskAndReply(
(...skipping 15 matching lines...) Expand all
139 void WallpaperResizer::RemoveObserver(WallpaperResizerObserver* observer) { 141 void WallpaperResizer::RemoveObserver(WallpaperResizerObserver* observer) {
140 observers_.RemoveObserver(observer); 142 observers_.RemoveObserver(observer);
141 } 143 }
142 144
143 void WallpaperResizer::OnResizeFinished(SkBitmap* resized_bitmap) { 145 void WallpaperResizer::OnResizeFinished(SkBitmap* resized_bitmap) {
144 image_ = gfx::ImageSkia::CreateFrom1xBitmap(*resized_bitmap); 146 image_ = gfx::ImageSkia::CreateFrom1xBitmap(*resized_bitmap);
145 FOR_EACH_OBSERVER(WallpaperResizerObserver, observers_, OnWallpaperResized()); 147 FOR_EACH_OBSERVER(WallpaperResizerObserver, observers_, OnWallpaperResized());
146 } 148 }
147 149
148 } // namespace wallpaper 150 } // namespace wallpaper
OLDNEW
« no previous file with comments | « components/wallpaper/wallpaper_resizer.h ('k') | components/wallpaper/wallpaper_resizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698