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

Side by Side Diff: chrome/browser/favicon/favicon_service.cc

Issue 10918065: Introduce structures to reduce the number of arguments in the FaviconService methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove the auxiliary structure for non-URL cases. Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/favicon/favicon_service.h" 5 #include "chrome/browser/favicon/favicon_service.h"
6 6
7 #include "chrome/browser/favicon/favicon_util.h" 7 #include "chrome/browser/favicon/favicon_util.h"
8 #include "chrome/browser/favicon/select_favicon_frames.h" 8 #include "chrome/browser/favicon/select_favicon_frames.h"
9 #include "chrome/browser/history/history.h" 9 #include "chrome/browser/history/history.h"
10 #include "chrome/browser/history/history_backend.h" 10 #include "chrome/browser/history/history_backend.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 AddRequest(request, consumer); 87 AddRequest(request, consumer);
88 if (history_service_) 88 if (history_service_)
89 history_service_->UpdateFaviconMappingAndFetch(request, page_url, 89 history_service_->UpdateFaviconMappingAndFetch(request, page_url,
90 icon_url, icon_type); 90 icon_url, icon_type);
91 else 91 else
92 ForwardEmptyResultAsync(request); 92 ForwardEmptyResultAsync(request);
93 return request->handle(); 93 return request->handle();
94 } 94 }
95 95
96 FaviconService::Handle FaviconService::GetFaviconImageForURL( 96 FaviconService::Handle FaviconService::GetFaviconImageForURL(
97 Profile* profile, 97 const FaviconForURLParams& params,
98 const GURL& page_url,
99 int icon_types,
100 int desired_size_in_dip,
101 CancelableRequestConsumerBase* consumer,
102 const FaviconImageCallback& callback) { 98 const FaviconImageCallback& callback) {
103 GetFaviconRequest* request = new GetFaviconRequest(base::Bind( 99 GetFaviconRequest* request = new GetFaviconRequest(base::Bind(
104 &FaviconService::GetFaviconImageCallback, 100 &FaviconService::GetFaviconImageCallback,
105 base::Unretained(this), 101 base::Unretained(this),
106 desired_size_in_dip, 102 params.desired_size_in_dip,
107 callback)); 103 callback));
108 104
109 std::vector<ui::ScaleFactor> desired_scale_factors = 105 std::vector<ui::ScaleFactor> desired_scale_factors =
110 ui::GetSupportedScaleFactors(); 106 ui::GetSupportedScaleFactors();
111 return GetFaviconForURLImpl(profile, page_url, icon_types, 107 return GetFaviconForURLImpl(params, desired_scale_factors, request);
112 desired_size_in_dip, desired_scale_factors, consumer, request);
113 } 108 }
114 109
115 FaviconService::Handle FaviconService::GetRawFaviconForURL( 110 FaviconService::Handle FaviconService::GetRawFaviconForURL(
116 Profile* profile, 111 const FaviconForURLParams& params,
117 const GURL& page_url,
118 int icon_types,
119 int desired_size_in_dip,
120 ui::ScaleFactor desired_scale_factor, 112 ui::ScaleFactor desired_scale_factor,
121 CancelableRequestConsumerBase* consumer,
122 const FaviconRawCallback& callback) { 113 const FaviconRawCallback& callback) {
123 GetFaviconRequest* request = new GetFaviconRequest(base::Bind( 114 GetFaviconRequest* request = new GetFaviconRequest(base::Bind(
124 &FaviconService::GetRawFaviconCallback, 115 &FaviconService::GetRawFaviconCallback,
125 base::Unretained(this), 116 base::Unretained(this),
126 desired_size_in_dip, 117 params.desired_size_in_dip,
127 desired_scale_factor, 118 desired_scale_factor,
128 callback)); 119 callback));
129 120
130 std::vector<ui::ScaleFactor> desired_scale_factors; 121 std::vector<ui::ScaleFactor> desired_scale_factors;
131 desired_scale_factors.push_back(desired_scale_factor); 122 desired_scale_factors.push_back(desired_scale_factor);
132 return GetFaviconForURLImpl(profile, page_url, icon_types, 123 return GetFaviconForURLImpl(params, desired_scale_factors, request);
133 desired_size_in_dip, desired_scale_factors, consumer, request);
134 } 124 }
135 125
136 FaviconService::Handle FaviconService::GetFaviconForURL( 126 FaviconService::Handle FaviconService::GetFaviconForURL(
137 Profile* profile, 127 const FaviconForURLParams& params,
138 const GURL& page_url,
139 int icon_types,
140 int desired_size_in_dip,
141 const std::vector<ui::ScaleFactor>& desired_scale_factors, 128 const std::vector<ui::ScaleFactor>& desired_scale_factors,
142 CancelableRequestConsumerBase* consumer,
143 const FaviconResultsCallback& callback) { 129 const FaviconResultsCallback& callback) {
144 GetFaviconRequest* request = new GetFaviconRequest(callback); 130 GetFaviconRequest* request = new GetFaviconRequest(callback);
145 return GetFaviconForURLImpl(profile, page_url, icon_types, 131 return GetFaviconForURLImpl(params, desired_scale_factors, request);
146 desired_size_in_dip, desired_scale_factors, consumer, request);
147 } 132 }
148 133
149 FaviconService::Handle FaviconService::GetRawFaviconForID( 134 FaviconService::Handle FaviconService::GetRawFaviconForID(
150 history::FaviconID favicon_id, 135 history::FaviconID favicon_id,
151 int desired_size_in_dip, 136 int desired_size_in_dip,
152 ui::ScaleFactor desired_scale_factor, 137 ui::ScaleFactor desired_scale_factor,
153 CancelableRequestConsumerBase* consumer, 138 CancelableRequestConsumerBase* consumer,
154 const FaviconRawCallback& callback) { 139 const FaviconRawCallback& callback) {
155 GetFaviconRequest* request = new GetFaviconRequest(base::Bind( 140 GetFaviconRequest* request = new GetFaviconRequest(base::Bind(
156 &FaviconService::GetRawFaviconCallback, 141 &FaviconService::GetRawFaviconCallback,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 const std::vector<unsigned char>& image_data, 178 const std::vector<unsigned char>& image_data,
194 history::IconType icon_type) { 179 history::IconType icon_type) {
195 if (history_service_) 180 if (history_service_)
196 history_service_->SetFavicon(page_url, icon_url, image_data, icon_type); 181 history_service_->SetFavicon(page_url, icon_url, image_data, icon_type);
197 } 182 }
198 183
199 FaviconService::~FaviconService() { 184 FaviconService::~FaviconService() {
200 } 185 }
201 186
202 FaviconService::Handle FaviconService::GetFaviconForURLImpl( 187 FaviconService::Handle FaviconService::GetFaviconForURLImpl(
203 Profile* profile, 188 const FaviconForURLParams& params,
204 const GURL& page_url,
205 int icon_types,
206 int desired_size_in_dip,
207 const std::vector<ui::ScaleFactor>& desired_scale_factors, 189 const std::vector<ui::ScaleFactor>& desired_scale_factors,
208 CancelableRequestConsumerBase* consumer,
209 GetFaviconRequest* request) { 190 GetFaviconRequest* request) {
210 AddRequest(request, consumer); 191 AddRequest(request, params.consumer);
211 FaviconService::Handle handle = request->handle(); 192 FaviconService::Handle handle = request->handle();
212 if (page_url.SchemeIs(chrome::kChromeUIScheme) || 193 if (params.page_url.SchemeIs(chrome::kChromeUIScheme) ||
213 page_url.SchemeIs(chrome::kExtensionScheme)) { 194 params.page_url.SchemeIs(chrome::kExtensionScheme)) {
214 ChromeWebUIControllerFactory::GetInstance()->GetFaviconForURL( 195 ChromeWebUIControllerFactory::GetInstance()->GetFaviconForURL(
215 profile, request, page_url, desired_scale_factors); 196 params.profile, request, params.page_url, desired_scale_factors);
216 } else { 197 } else {
217 // TODO(pkotwicz): Pass in desired size and desired scale factors. 198 // TODO(pkotwicz): Pass in desired size and desired scale factors.
218 if (history_service_) 199 if (history_service_) {
219 history_service_->GetFaviconForURL(request, page_url, icon_types); 200 history_service_->GetFaviconForURL(request,
220 else 201 params.page_url,
202 params.icon_types);
203 } else {
221 ForwardEmptyResultAsync(request); 204 ForwardEmptyResultAsync(request);
205 }
222 } 206 }
223 return handle; 207 return handle;
224 } 208 }
225 209
226 void FaviconService::GetFaviconImageCallback( 210 void FaviconService::GetFaviconImageCallback(
227 int desired_size_in_dip, 211 int desired_size_in_dip,
228 FaviconImageCallback callback, 212 FaviconImageCallback callback,
229 Handle handle, 213 Handle handle,
230 std::vector<history::FaviconBitmapResult> favicon_bitmap_results, 214 std::vector<history::FaviconBitmapResult> favicon_bitmap_results,
231 history::IconURLSizesMap icon_url_sizes_map) { 215 history::IconURLSizesMap icon_url_sizes_map) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 bitmap_result.bitmap_data = base::RefCountedBytes::TakeVector( 276 bitmap_result.bitmap_data = base::RefCountedBytes::TakeVector(
293 &resized_bitmap_data); 277 &resized_bitmap_data);
294 callback.Run(handle, bitmap_result); 278 callback.Run(handle, bitmap_result);
295 } 279 }
296 280
297 void FaviconService::ForwardEmptyResultAsync(GetFaviconRequest* request) { 281 void FaviconService::ForwardEmptyResultAsync(GetFaviconRequest* request) {
298 request->ForwardResultAsync(request->handle(), 282 request->ForwardResultAsync(request->handle(),
299 std::vector<history::FaviconBitmapResult>(), 283 std::vector<history::FaviconBitmapResult>(),
300 history::IconURLSizesMap()); 284 history::IconURLSizesMap());
301 } 285 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698