| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |