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

Side by Side Diff: components/favicon/core/favicon_handler.h

Issue 1295733002: Ignore duplicate FaviconHandler::OnUpdateFaviconURL() calls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@page_changed_under_us
Patch Set: Created 5 years, 2 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) 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 #ifndef COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_ 5 #ifndef COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_
6 #define COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_ 6 #define COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // Notifies |driver_| favicon available. See 224 // Notifies |driver_| favicon available. See
225 // FaviconDriver::NotifyFaviconAvailable() for |is_active_favicon| in detail. 225 // FaviconDriver::NotifyFaviconAvailable() for |is_active_favicon| in detail.
226 void NotifyFaviconAvailable( 226 void NotifyFaviconAvailable(
227 const std::vector<favicon_base::FaviconRawBitmapResult>& 227 const std::vector<favicon_base::FaviconRawBitmapResult>&
228 favicon_bitmap_results); 228 favicon_bitmap_results);
229 void NotifyFaviconAvailable(const GURL& icon_url, 229 void NotifyFaviconAvailable(const GURL& icon_url,
230 const gfx::Image& image); 230 const gfx::Image& image);
231 231
232 // Return the current candidate if any. 232 // Return the current candidate if any.
233 favicon::FaviconURL* current_candidate() { 233 favicon::FaviconURL* current_candidate() {
234 return (!image_urls_.empty()) ? &image_urls_.front() : NULL; 234 return current_candidate_index_ < image_urls_.size()
235 ? &image_urls_[current_candidate_index_]
236 : nullptr;
235 } 237 }
236 238
237 // Returns the preferred size of the image. 0 means no preference (any size 239 // Returns the preferred size of the image. 0 means no preference (any size
238 // will do). 240 // will do).
239 int preferred_icon_size() const { 241 int preferred_icon_size() const {
240 if (download_largest_icon_) 242 if (download_largest_icon_)
241 return 0; 243 return 0;
242 return handler_type_ == FAVICON ? gfx::kFaviconSize : 0; 244 return handler_type_ == FAVICON ? gfx::kFaviconSize : 0;
243 } 245 }
244 246
245 // Sorts the entries in |image_urls_| by icon size in descending order. 247 // Sorts the entries in |image_urls| by icon size in descending order.
246 // Additionally removes any entries whose sizes are all greater than the max 248 // Discards all but the largest size for each FaviconURL.
247 // allowed size. 249 void SortAndPruneImageUrls(std::vector<FaviconURL>* image_urls);
248 void SortAndPruneImageUrls();
249 250
250 // Used for FaviconService requests. 251 // Used for FaviconService requests.
251 base::CancelableTaskTracker cancelable_task_tracker_; 252 base::CancelableTaskTracker cancelable_task_tracker_;
252 253
253 // URL of the page we're requesting the favicon for. 254 // URL of the page we're requesting the favicon for.
254 GURL url_; 255 GURL url_;
255 256
256 // Whether we got data back for the initial request to the FaviconService. 257 // Whether we got data back for the initial request to the FaviconService.
257 bool got_favicon_from_history_; 258 bool got_favicon_from_history_;
258 259
(...skipping 22 matching lines...) Expand all
281 // The FaviconRawBitmapResults from history. 282 // The FaviconRawBitmapResults from history.
282 std::vector<favicon_base::FaviconRawBitmapResult> history_results_; 283 std::vector<favicon_base::FaviconRawBitmapResult> history_results_;
283 284
284 // The FaviconService which implements favicon operations. May be null during 285 // The FaviconService which implements favicon operations. May be null during
285 // testing. 286 // testing.
286 FaviconService* service_; 287 FaviconService* service_;
287 288
288 // This handler's driver, owns this object. 289 // This handler's driver, owns this object.
289 FaviconDriver* driver_; 290 FaviconDriver* driver_;
290 291
292 // The index of the favicon URL in |image_urls_| which is currently being
293 // requested from history or downloaded.
294 size_t current_candidate_index_;
295
291 // Best image we've seen so far. As images are downloaded from the page they 296 // Best image we've seen so far. As images are downloaded from the page they
292 // are stored here. When there is an exact match, or no more images are 297 // are stored here. When there is an exact match, or no more images are
293 // available the favicon service and the current page are updated (assuming 298 // available the favicon service and the current page are updated (assuming
294 // the image is for a favicon). 299 // the image is for a favicon).
295 FaviconCandidate best_favicon_candidate_; 300 FaviconCandidate best_favicon_candidate_;
296 301
297 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); 302 DISALLOW_COPY_AND_ASSIGN(FaviconHandler);
298 }; 303 };
299 304
300 } // namespace favicon 305 } // namespace favicon
301 306
302 #endif // COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_ 307 #endif // COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_
OLDNEW
« no previous file with comments | « no previous file | components/favicon/core/favicon_handler.cc » ('j') | components/favicon/core/favicon_handler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698