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 <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 int id, | 368 int id, |
369 int http_status_code, | 369 int http_status_code, |
370 const GURL& image_url, | 370 const GURL& image_url, |
371 const std::vector<SkBitmap>& bitmaps, | 371 const std::vector<SkBitmap>& bitmaps, |
372 const std::vector<gfx::Size>& original_bitmap_sizes) { | 372 const std::vector<gfx::Size>& original_bitmap_sizes) { |
373 // Mark download as finished. | 373 // Mark download as finished. |
374 download_request_.Cancel(); | 374 download_request_.Cancel(); |
375 | 375 |
376 if (bitmaps.empty() && http_status_code == 404) { | 376 if (bitmaps.empty() && http_status_code == 404) { |
377 DVLOG(1) << "Failed to Download Favicon:" << image_url; | 377 DVLOG(1) << "Failed to Download Favicon:" << image_url; |
378 UMA_HISTOGRAM_COUNTS_100("Favicons.DownloadOutcome", | |
379 DownloadOutcome::FAILED); | |
378 if (service_) | 380 if (service_) |
379 service_->UnableToDownloadFavicon(image_url); | 381 service_->UnableToDownloadFavicon(image_url); |
382 } else if (http_status_code == 200) { | |
pkotwicz
2017/04/10 18:30:59
Can we record this whenever !bitmaps.empty()
fhorschig
2017/04/11 12:24:53
Done.
| |
383 UMA_HISTOGRAM_COUNTS_100("Favicons.DownloadOutcome", | |
384 DownloadOutcome::SUCCEEDED); | |
380 } | 385 } |
381 | 386 |
382 bool request_next_icon = true; | 387 bool request_next_icon = true; |
383 if (!bitmaps.empty()) { | 388 if (!bitmaps.empty()) { |
384 float score = 0.0f; | 389 float score = 0.0f; |
385 gfx::ImageSkia image_skia; | 390 gfx::ImageSkia image_skia; |
386 if (download_largest_icon_) { | 391 if (download_largest_icon_) { |
387 std::vector<size_t> best_indices; | 392 std::vector<size_t> best_indices; |
388 SelectFaviconFrameIndices(original_bitmap_sizes, | 393 SelectFaviconFrameIndices(original_bitmap_sizes, |
389 GetDesiredPixelSizes(handler_type_), | 394 GetDesiredPixelSizes(handler_type_), |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
538 } | 543 } |
539 } | 544 } |
540 | 545 |
541 void FaviconHandler::ScheduleDownload(const GURL& image_url, | 546 void FaviconHandler::ScheduleDownload(const GURL& image_url, |
542 favicon_base::IconType icon_type) { | 547 favicon_base::IconType icon_type) { |
543 DCHECK(image_url.is_valid()); | 548 DCHECK(image_url.is_valid()); |
544 // Note that CancelableCallback starts cancelled. | 549 // Note that CancelableCallback starts cancelled. |
545 DCHECK(download_request_.IsCancelled()) << "More than one ongoing download"; | 550 DCHECK(download_request_.IsCancelled()) << "More than one ongoing download"; |
546 if (service_ && service_->WasUnableToDownloadFavicon(image_url)) { | 551 if (service_ && service_->WasUnableToDownloadFavicon(image_url)) { |
547 DVLOG(1) << "Skip Failed FavIcon: " << image_url; | 552 DVLOG(1) << "Skip Failed FavIcon: " << image_url; |
553 UMA_HISTOGRAM_COUNTS_100("Favicons.DownloadOutcome", | |
554 DownloadOutcome::SKIPPED); | |
548 OnDidDownloadFavicon(icon_type, 0, 0, image_url, std::vector<SkBitmap>(), | 555 OnDidDownloadFavicon(icon_type, 0, 0, image_url, std::vector<SkBitmap>(), |
549 std::vector<gfx::Size>()); | 556 std::vector<gfx::Size>()); |
550 return; | 557 return; |
551 } | 558 } |
552 download_request_.Reset(base::Bind(&FaviconHandler::OnDidDownloadFavicon, | 559 download_request_.Reset(base::Bind(&FaviconHandler::OnDidDownloadFavicon, |
553 base::Unretained(this), icon_type)); | 560 base::Unretained(this), icon_type)); |
554 // A max bitmap size is specified to avoid receiving huge bitmaps in | 561 // A max bitmap size is specified to avoid receiving huge bitmaps in |
555 // OnDidDownloadFavicon(). See FaviconDriver::StartDownload() | 562 // OnDidDownloadFavicon(). See FaviconDriver::StartDownload() |
556 // for more details about the max bitmap size. | 563 // for more details about the max bitmap size. |
557 const int download_id = | 564 const int download_id = |
558 delegate_->DownloadImage(image_url, GetMaximalIconSize(handler_type_), | 565 delegate_->DownloadImage(image_url, GetMaximalIconSize(handler_type_), |
559 download_request_.callback()); | 566 download_request_.callback()); |
560 DCHECK_NE(download_id, 0); | 567 DCHECK_NE(download_id, 0); |
561 } | 568 } |
562 | 569 |
563 } // namespace favicon | 570 } // namespace favicon |
OLD | NEW |