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

Side by Side Diff: chrome/browser/ui/app_list/arc/arc_app_icon.cc

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/ui/app_list/arc/arc_app_icon.h" 5 #include "chrome/browser/ui/app_list/arc/arc_app_icon.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h"
13 #include "base/task_runner_util.h" 14 #include "base/task_runner_util.h"
14 #include "chrome/browser/image_decoder.h" 15 #include "chrome/browser/image_decoder.h"
15 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" 16 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
16 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
17 #include "extensions/grit/extensions_browser_resources.h" 18 #include "extensions/grit/extensions_browser_resources.h"
18 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/gfx/codec/png_codec.h" 20 #include "ui/gfx/codec/png_codec.h"
20 #include "ui/gfx/geometry/size.h" 21 #include "ui/gfx/geometry/size.h"
21 #include "ui/gfx/image/image_skia_operations.h" 22 #include "ui/gfx/image/image_skia_operations.h"
22 #include "ui/gfx/image/image_skia_source.h" 23 #include "ui/gfx/image/image_skia_source.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 214 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
214 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context_); 215 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context_);
215 216
216 // ArcAppListPrefs notifies ArcAppModelBuilder via Observer when icon is ready 217 // ArcAppListPrefs notifies ArcAppModelBuilder via Observer when icon is ready
217 // and ArcAppModelBuilder refreshes the icon of the corresponding item by 218 // and ArcAppModelBuilder refreshes the icon of the corresponding item by
218 // calling LoadScaleFactor. 219 // calling LoadScaleFactor.
219 prefs->RequestIcon(app_id_, scale_factor); 220 prefs->RequestIcon(app_id_, scale_factor);
220 } 221 }
221 222
222 // static 223 // static
223 scoped_ptr<ArcAppIcon::ReadResult> ArcAppIcon::ReadOnFileThread( 224 std::unique_ptr<ArcAppIcon::ReadResult> ArcAppIcon::ReadOnFileThread(
224 ui::ScaleFactor scale_factor, 225 ui::ScaleFactor scale_factor,
225 const base::FilePath& path) { 226 const base::FilePath& path) {
226 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); 227 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
227 DCHECK(!path.empty()); 228 DCHECK(!path.empty());
228 229
229 if (!base::PathExists(path)) 230 if (!base::PathExists(path))
230 return make_scoped_ptr(new ArcAppIcon::ReadResult( 231 return base::WrapUnique(new ArcAppIcon::ReadResult(
231 ArcAppIcon::ReadResult::Status::REQUEST_TO_INSTALL, scale_factor)); 232 ArcAppIcon::ReadResult::Status::REQUEST_TO_INSTALL, scale_factor));
232 233
233 // Read the file from disk. 234 // Read the file from disk.
234 std::string unsafe_icon_data; 235 std::string unsafe_icon_data;
235 if (!base::ReadFileToString(path, &unsafe_icon_data)) { 236 if (!base::ReadFileToString(path, &unsafe_icon_data)) {
236 VLOG(2) << "Failed to read an ARC icon from file " << path.MaybeAsASCII(); 237 VLOG(2) << "Failed to read an ARC icon from file " << path.MaybeAsASCII();
237 return make_scoped_ptr(new ArcAppIcon::ReadResult( 238 return base::WrapUnique(new ArcAppIcon::ReadResult(
238 ArcAppIcon::ReadResult::Status::FAIL, scale_factor)); 239 ArcAppIcon::ReadResult::Status::FAIL, scale_factor));
239 } 240 }
240 241
241 return make_scoped_ptr(new ArcAppIcon::ReadResult(scale_factor, 242 return base::WrapUnique(
242 unsafe_icon_data)); 243 new ArcAppIcon::ReadResult(scale_factor, unsafe_icon_data));
243 } 244 }
244 245
245 void ArcAppIcon::OnIconRead(scoped_ptr<ArcAppIcon::ReadResult> read_result) { 246 void ArcAppIcon::OnIconRead(
247 std::unique_ptr<ArcAppIcon::ReadResult> read_result) {
246 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 248 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
247 249
248 switch (read_result->status) { 250 switch (read_result->status) {
249 case ReadResult::Status::OK: 251 case ReadResult::Status::OK:
250 decode_requests_.push_back( 252 decode_requests_.push_back(
251 new DecodeRequest(weak_ptr_factory_.GetWeakPtr(), 253 new DecodeRequest(weak_ptr_factory_.GetWeakPtr(),
252 resource_size_in_dip_, 254 resource_size_in_dip_,
253 read_result->scale_factor)); 255 read_result->scale_factor));
254 if (disable_safe_decoding) { 256 if (disable_safe_decoding) {
255 SkBitmap bitmap; 257 SkBitmap bitmap;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 299
298 void ArcAppIcon::DiscardDecodeRequest(DecodeRequest* request) { 300 void ArcAppIcon::DiscardDecodeRequest(DecodeRequest* request) {
299 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 301 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
300 302
301 ScopedVector<DecodeRequest>::iterator it = std::find(decode_requests_.begin(), 303 ScopedVector<DecodeRequest>::iterator it = std::find(decode_requests_.begin(),
302 decode_requests_.end(), 304 decode_requests_.end(),
303 request); 305 request);
304 CHECK(it != decode_requests_.end()); 306 CHECK(it != decode_requests_.end());
305 decode_requests_.erase(it); 307 decode_requests_.erase(it);
306 } 308 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_icon.h ('k') | chrome/browser/ui/app_list/arc/arc_app_icon_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698