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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
375 int id, | 375 int id, |
376 int http_status_code, | 376 int http_status_code, |
377 const GURL& image_url, | 377 const GURL& image_url, |
378 const std::vector<SkBitmap>& bitmaps, | 378 const std::vector<SkBitmap>& bitmaps, |
379 const std::vector<gfx::Size>& original_bitmap_sizes) { | 379 const std::vector<gfx::Size>& original_bitmap_sizes) { |
380 // Mark download as finished. | 380 // Mark download as finished. |
381 download_request_.Cancel(); | 381 download_request_.Cancel(); |
382 | 382 |
383 if (bitmaps.empty() && http_status_code == 404) { | 383 if (bitmaps.empty() && http_status_code == 404) { |
384 DVLOG(1) << "Failed to Download Favicon:" << image_url; | 384 DVLOG(1) << "Failed to Download Favicon:" << image_url; |
385 UMA_HISTOGRAM_COUNTS_100("Favicons.DownloadOutcome", | |
Ilya Sherman
2017/04/12 23:22:13
Could this be UMA_HISTOGRAM_SPARSE_SLOWLY or UMA_H
fhorschig
2017/04/13 15:14:05
Done.
| |
386 DownloadOutcome::FAILED); | |
385 if (service_) | 387 if (service_) |
386 service_->UnableToDownloadFavicon(image_url); | 388 service_->UnableToDownloadFavicon(image_url); |
387 } | 389 } |
388 | 390 |
389 bool request_next_icon = true; | 391 bool request_next_icon = true; |
390 if (!bitmaps.empty()) { | 392 if (!bitmaps.empty()) { |
393 UMA_HISTOGRAM_COUNTS_100("Favicons.DownloadOutcome", | |
394 DownloadOutcome::SUCCEEDED); | |
Ilya Sherman
2017/04/12 23:22:13
Please create a small wrapper function for emittin
fhorschig
2017/04/13 15:14:05
Done, thanks for the explanation!
| |
391 float score = 0.0f; | 395 float score = 0.0f; |
392 gfx::ImageSkia image_skia; | 396 gfx::ImageSkia image_skia; |
393 if (download_largest_icon_) { | 397 if (download_largest_icon_) { |
394 std::vector<size_t> best_indices; | 398 std::vector<size_t> best_indices; |
395 SelectFaviconFrameIndices(original_bitmap_sizes, | 399 SelectFaviconFrameIndices(original_bitmap_sizes, |
396 GetDesiredPixelSizes(handler_type_), | 400 GetDesiredPixelSizes(handler_type_), |
397 &best_indices, &score); | 401 &best_indices, &score); |
398 DCHECK_EQ(1U, best_indices.size()); | 402 DCHECK_EQ(1U, best_indices.size()); |
399 image_skia = | 403 image_skia = |
400 gfx::ImageSkia::CreateFrom1xBitmap(bitmaps[best_indices.front()]); | 404 gfx::ImageSkia::CreateFrom1xBitmap(bitmaps[best_indices.front()]); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
550 } | 554 } |
551 } | 555 } |
552 | 556 |
553 void FaviconHandler::ScheduleDownload(const GURL& image_url, | 557 void FaviconHandler::ScheduleDownload(const GURL& image_url, |
554 favicon_base::IconType icon_type) { | 558 favicon_base::IconType icon_type) { |
555 DCHECK(image_url.is_valid()); | 559 DCHECK(image_url.is_valid()); |
556 // Note that CancelableCallback starts cancelled. | 560 // Note that CancelableCallback starts cancelled. |
557 DCHECK(download_request_.IsCancelled()) << "More than one ongoing download"; | 561 DCHECK(download_request_.IsCancelled()) << "More than one ongoing download"; |
558 if (service_ && service_->WasUnableToDownloadFavicon(image_url)) { | 562 if (service_ && service_->WasUnableToDownloadFavicon(image_url)) { |
559 DVLOG(1) << "Skip Failed FavIcon: " << image_url; | 563 DVLOG(1) << "Skip Failed FavIcon: " << image_url; |
564 UMA_HISTOGRAM_COUNTS_100("Favicons.DownloadOutcome", | |
565 DownloadOutcome::SKIPPED); | |
560 OnDidDownloadFavicon(icon_type, 0, 0, image_url, std::vector<SkBitmap>(), | 566 OnDidDownloadFavicon(icon_type, 0, 0, image_url, std::vector<SkBitmap>(), |
561 std::vector<gfx::Size>()); | 567 std::vector<gfx::Size>()); |
562 return; | 568 return; |
563 } | 569 } |
564 ++num_download_requests_; | 570 ++num_download_requests_; |
565 download_request_.Reset(base::Bind(&FaviconHandler::OnDidDownloadFavicon, | 571 download_request_.Reset(base::Bind(&FaviconHandler::OnDidDownloadFavicon, |
566 base::Unretained(this), icon_type)); | 572 base::Unretained(this), icon_type)); |
567 // A max bitmap size is specified to avoid receiving huge bitmaps in | 573 // A max bitmap size is specified to avoid receiving huge bitmaps in |
568 // OnDidDownloadFavicon(). See FaviconDriver::StartDownload() | 574 // OnDidDownloadFavicon(). See FaviconDriver::StartDownload() |
569 // for more details about the max bitmap size. | 575 // for more details about the max bitmap size. |
570 const int download_id = | 576 const int download_id = |
571 delegate_->DownloadImage(image_url, GetMaximalIconSize(handler_type_), | 577 delegate_->DownloadImage(image_url, GetMaximalIconSize(handler_type_), |
572 download_request_.callback()); | 578 download_request_.callback()); |
573 DCHECK_NE(download_id, 0); | 579 DCHECK_NE(download_id, 0); |
574 } | 580 } |
575 | 581 |
576 } // namespace favicon | 582 } // namespace favicon |
OLD | NEW |