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

Side by Side Diff: components/favicon/core/large_icon_service.cc

Issue 1918083002: Convert //components/[f-n]* from scoped_ptr to std::unique_ptr (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
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 "components/favicon/core/large_icon_service.h" 5 #include "components/favicon/core/large_icon_service.h"
6 6
7 #include <memory>
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/macros.h" 12 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/task_runner.h" 14 #include "base/task_runner.h"
14 #include "base/threading/sequenced_worker_pool.h" 15 #include "base/threading/sequenced_worker_pool.h"
15 #include "components/favicon/core/favicon_service.h" 16 #include "components/favicon/core/favicon_service.h"
16 #include "components/favicon_base/fallback_icon_style.h" 17 #include "components/favicon_base/fallback_icon_style.h"
17 #include "components/favicon_base/favicon_types.h" 18 #include "components/favicon_base/favicon_types.h"
18 #include "skia/ext/image_operations.h" 19 #include "skia/ext/image_operations.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 22
22 namespace { 23 namespace {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 // Must run on the owner (UI) thread in production. 62 // Must run on the owner (UI) thread in production.
62 // Invoked when ProcessIconOnBackgroundThread() is done. 63 // Invoked when ProcessIconOnBackgroundThread() is done.
63 void OnIconProcessingComplete(); 64 void OnIconProcessingComplete();
64 65
65 int min_source_size_in_pixel_; 66 int min_source_size_in_pixel_;
66 int desired_size_in_pixel_; 67 int desired_size_in_pixel_;
67 favicon_base::LargeIconCallback callback_; 68 favicon_base::LargeIconCallback callback_;
68 scoped_refptr<base::TaskRunner> background_task_runner_; 69 scoped_refptr<base::TaskRunner> background_task_runner_;
69 base::CancelableTaskTracker* tracker_; 70 base::CancelableTaskTracker* tracker_;
70 favicon_base::FaviconRawBitmapResult bitmap_result_; 71 favicon_base::FaviconRawBitmapResult bitmap_result_;
71 scoped_ptr<favicon_base::LargeIconResult> result_; 72 std::unique_ptr<favicon_base::LargeIconResult> result_;
72 73
73 DISALLOW_COPY_AND_ASSIGN(LargeIconWorker); 74 DISALLOW_COPY_AND_ASSIGN(LargeIconWorker);
74 }; 75 };
75 76
76 LargeIconWorker::LargeIconWorker( 77 LargeIconWorker::LargeIconWorker(
77 int min_source_size_in_pixel, 78 int min_source_size_in_pixel,
78 int desired_size_in_pixel, 79 int desired_size_in_pixel,
79 favicon_base::LargeIconCallback callback, 80 favicon_base::LargeIconCallback callback,
80 scoped_refptr<base::TaskRunner> background_task_runner, 81 scoped_refptr<base::TaskRunner> background_task_runner,
81 base::CancelableTaskTracker* tracker) 82 base::CancelableTaskTracker* tracker)
(...skipping 16 matching lines...) Expand all
98 base::Bind(&LargeIconWorker::OnIconProcessingComplete, this)); 99 base::Bind(&LargeIconWorker::OnIconProcessingComplete, this));
99 } 100 }
100 101
101 void LargeIconWorker::ProcessIconOnBackgroundThread() { 102 void LargeIconWorker::ProcessIconOnBackgroundThread() {
102 favicon_base::FaviconRawBitmapResult resized_bitmap_result; 103 favicon_base::FaviconRawBitmapResult resized_bitmap_result;
103 if (ResizeLargeIconOnBackgroundThreadIfValid(&resized_bitmap_result)) { 104 if (ResizeLargeIconOnBackgroundThreadIfValid(&resized_bitmap_result)) {
104 result_.reset( 105 result_.reset(
105 new favicon_base::LargeIconResult(resized_bitmap_result)); 106 new favicon_base::LargeIconResult(resized_bitmap_result));
106 } else { 107 } else {
107 // Failed to resize |bitmap_result_|, so compute fallback icon style. 108 // Failed to resize |bitmap_result_|, so compute fallback icon style.
108 scoped_ptr<favicon_base::FallbackIconStyle> fallback_icon_style( 109 std::unique_ptr<favicon_base::FallbackIconStyle> fallback_icon_style(
109 new favicon_base::FallbackIconStyle()); 110 new favicon_base::FallbackIconStyle());
110 if (bitmap_result_.is_valid()) { 111 if (bitmap_result_.is_valid()) {
111 favicon_base::SetDominantColorAsBackground( 112 favicon_base::SetDominantColorAsBackground(
112 bitmap_result_.bitmap_data, fallback_icon_style.get()); 113 bitmap_result_.bitmap_data, fallback_icon_style.get());
113 } 114 }
114 result_.reset( 115 result_.reset(
115 new favicon_base::LargeIconResult(fallback_icon_style.release())); 116 new favicon_base::LargeIconResult(fallback_icon_style.release()));
116 } 117 }
117 } 118 }
118 119
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 // GetLargestRawFaviconForPageURL. Add the logic required to select the best 195 // GetLargestRawFaviconForPageURL. Add the logic required to select the best
195 // possible large icon. Also add logic to fetch-on-demand when the URL of 196 // possible large icon. Also add logic to fetch-on-demand when the URL of
196 // a large icon is known but its bitmap is not available. 197 // a large icon is known but its bitmap is not available.
197 return favicon_service_->GetLargestRawFaviconForPageURL( 198 return favicon_service_->GetLargestRawFaviconForPageURL(
198 page_url, large_icon_types_, min_source_size_in_pixel, 199 page_url, large_icon_types_, min_source_size_in_pixel,
199 base::Bind(&LargeIconWorker::OnIconLookupComplete, worker), 200 base::Bind(&LargeIconWorker::OnIconLookupComplete, worker),
200 tracker); 201 tracker);
201 } 202 }
202 203
203 } // namespace favicon 204 } // namespace favicon
OLDNEW
« no previous file with comments | « components/favicon/core/favicon_service.cc ('k') | components/favicon/core/large_icon_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698