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

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

Issue 2728893004: Move WasUnableToDownload logic to FaviconHandler (Closed)
Patch Set: Reverted accidental changes. Created 3 years, 9 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 #include "components/favicon/core/favicon_handler.h" 5 #include "components/favicon/core/favicon_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 654
655 if (has_expired_or_incomplete_result) { 655 if (has_expired_or_incomplete_result) {
656 ScheduleDownload(current_candidate()->icon_url, 656 ScheduleDownload(current_candidate()->icon_url,
657 current_candidate()->icon_type); 657 current_candidate()->icon_type);
658 } 658 }
659 } 659 }
660 660
661 void FaviconHandler::ScheduleDownload(const GURL& image_url, 661 void FaviconHandler::ScheduleDownload(const GURL& image_url,
662 favicon_base::IconType icon_type) { 662 favicon_base::IconType icon_type) {
663 DCHECK(image_url.is_valid()); 663 DCHECK(image_url.is_valid());
664 if (service_ && service_->WasUnableToDownloadFavicon(image_url)) {
665 DVLOG(1) << "Skip Failed FavIcon: " << image_url;
666 // Registration in download_requests_ is needed to prevent
667 // OnDidDownloadFavicon() from returning early.
668 download_requests_[0] = DownloadRequest(image_url, icon_type);
669 OnDidDownloadFavicon(0, 0, image_url, std::vector<SkBitmap>(),
670 std::vector<gfx::Size>());
671 return;
672 }
664 // A max bitmap size is specified to avoid receiving huge bitmaps in 673 // A max bitmap size is specified to avoid receiving huge bitmaps in
665 // OnDidDownloadFavicon(). See FaviconDriver::StartDownload() 674 // OnDidDownloadFavicon(). See FaviconDriver::StartDownload()
666 // for more details about the max bitmap size. 675 // for more details about the max bitmap size.
667 const int download_id = 676 const int download_id =
668 delegate_->DownloadImage(image_url, GetMaximalIconSize(icon_type), 677 delegate_->DownloadImage(image_url, GetMaximalIconSize(icon_type),
669 base::Bind(&FaviconHandler::OnDidDownloadFavicon, 678 base::Bind(&FaviconHandler::OnDidDownloadFavicon,
670 weak_ptr_factory_.GetWeakPtr())); 679 weak_ptr_factory_.GetWeakPtr()));
671 680
672 // Download ids should be unique. 681 // Download ids should be unique.
673 DCHECK(download_requests_.find(download_id) == download_requests_.end()); 682 DCHECK(download_requests_.find(download_id) == download_requests_.end());
674 download_requests_[download_id] = DownloadRequest(image_url, icon_type); 683 download_requests_[download_id] = DownloadRequest(image_url, icon_type);
675 684
685 // TODO(mastiz): Remove the download_id == 0 handling because it's not used
686 // in production code, only tests.
676 if (download_id == 0) { 687 if (download_id == 0) {
677 // If DownloadFavicon() did not start a download, it returns a download id 688 // If DownloadFavicon() did not start a download, it returns a download id
678 // of 0. We still need to call OnDidDownloadFavicon() because the method is 689 // of 0. We still need to call OnDidDownloadFavicon() because the method is
679 // responsible for initiating the data request for the next candidate. 690 // responsible for initiating the data request for the next candidate.
680 OnDidDownloadFavicon(download_id, 0, image_url, std::vector<SkBitmap>(), 691 OnDidDownloadFavicon(download_id, 0, image_url, std::vector<SkBitmap>(),
681 std::vector<gfx::Size>()); 692 std::vector<gfx::Size>());
682 } 693 }
683 } 694 }
684 695
685 } // namespace favicon 696 } // namespace favicon
OLDNEW
« no previous file with comments | « components/favicon/core/favicon_driver_impl.cc ('k') | components/favicon/ios/web_favicon_driver.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698