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

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
« no previous file with comments | « no previous file | components/favicon/core/favicon_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
246 // Additionally removes any entries whose sizes are all greater than the max
247 // allowed size.
248 void SortAndPruneImageUrls();
249
250 // Used for FaviconService requests. 247 // Used for FaviconService requests.
251 base::CancelableTaskTracker cancelable_task_tracker_; 248 base::CancelableTaskTracker cancelable_task_tracker_;
252 249
253 // URL of the page we're requesting the favicon for. 250 // URL of the page we're requesting the favicon for.
254 GURL url_; 251 GURL url_;
255 252
256 // Whether we got data back for the initial request to the FaviconService. 253 // Whether we got data back for the initial request to the FaviconService.
257 bool got_favicon_from_history_; 254 bool got_favicon_from_history_;
258 255
259 // Whether the favicon is out of date or the favicon data in 256 // Whether the favicon is out of date or the favicon data in
(...skipping 21 matching lines...) Expand all
281 // The FaviconRawBitmapResults from history. 278 // The FaviconRawBitmapResults from history.
282 std::vector<favicon_base::FaviconRawBitmapResult> history_results_; 279 std::vector<favicon_base::FaviconRawBitmapResult> history_results_;
283 280
284 // The FaviconService which implements favicon operations. May be null during 281 // The FaviconService which implements favicon operations. May be null during
285 // testing. 282 // testing.
286 FaviconService* service_; 283 FaviconService* service_;
287 284
288 // This handler's driver, owns this object. 285 // This handler's driver, owns this object.
289 FaviconDriver* driver_; 286 FaviconDriver* driver_;
290 287
288 // The index of the favicon URL in |image_urls_| which is currently being
289 // requested from history or downloaded.
290 size_t current_candidate_index_;
291
291 // Best image we've seen so far. As images are downloaded from the page they 292 // 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 293 // 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 294 // available the favicon service and the current page are updated (assuming
294 // the image is for a favicon). 295 // the image is for a favicon).
295 FaviconCandidate best_favicon_candidate_; 296 FaviconCandidate best_favicon_candidate_;
296 297
297 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); 298 DISALLOW_COPY_AND_ASSIGN(FaviconHandler);
298 }; 299 };
299 300
300 } // namespace favicon 301 } // namespace favicon
301 302
302 #endif // COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_ 303 #endif // COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_
OLDNEW
« no previous file with comments | « no previous file | components/favicon/core/favicon_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698