| Index: components/ntp_tiles/icon_cacher_impl.cc
|
| diff --git a/components/ntp_tiles/icon_cacher_impl.cc b/components/ntp_tiles/icon_cacher_impl.cc
|
| index 488e102ff953f4fa9a183f9c4b5c8941a1261799..974e96c06be6ea25fffb7b8aafe24f800066e5a0 100644
|
| --- a/components/ntp_tiles/icon_cacher_impl.cc
|
| +++ b/components/ntp_tiles/icon_cacher_impl.cc
|
| @@ -7,6 +7,7 @@
|
| #include <utility>
|
|
|
| #include "base/memory/ptr_util.h"
|
| +#include "base/metrics/histogram_macros.h"
|
| #include "components/favicon/core/favicon_service.h"
|
| #include "components/favicon/core/favicon_util.h"
|
| #include "components/favicon/core/large_icon_service.h"
|
| @@ -32,6 +33,21 @@ constexpr int kDesiredFrameSize = 128;
|
| constexpr int kTileIconMinSizePx = 48;
|
| constexpr int kTileIconDesiredSizePx = 96;
|
|
|
| +// Enumeration listing all possible outcomes for fetch attempts of favicons for
|
| +// NTP tiles. Used for UMA histograms, so do not change existing
|
| +// values. Insert new values at the end, and update the histogram definition.
|
| +enum class TileFaviconFetchResult { SUCCESS = 0, FAILURE = 1, COUNT = 2 };
|
| +
|
| +void RecordPopularSitesFaviconFetchResult(TileFaviconFetchResult result) {
|
| + UMA_HISTOGRAM_ENUMERATION("NewTabPage.TileFaviconFetched.popular", result,
|
| + TileFaviconFetchResult::COUNT);
|
| +}
|
| +
|
| +void RecordMostLikelyFaviconFetchResult(TileFaviconFetchResult result) {
|
| + UMA_HISTOGRAM_ENUMERATION("NewTabPage.TileFaviconFetched.server", result,
|
| + TileFaviconFetchResult::COUNT);
|
| +}
|
| +
|
| favicon_base::IconType IconType(const PopularSites::Site& site) {
|
| return site.large_icon_url.is_valid() ? favicon_base::TOUCH_ICON
|
| : favicon_base::FAVICON;
|
| @@ -115,6 +131,7 @@ void IconCacherImpl::OnPopularSitesFaviconDownloaded(
|
| const image_fetcher::RequestMetadata& metadata) {
|
| if (fetched_image.IsEmpty()) {
|
| FinishRequestAndNotifyIconAvailable(site.url, /*newly_available=*/false);
|
| + RecordPopularSitesFaviconFetchResult(TileFaviconFetchResult::FAILURE);
|
| return;
|
| }
|
|
|
| @@ -125,6 +142,7 @@ void IconCacherImpl::OnPopularSitesFaviconDownloaded(
|
| }
|
| SaveIconForSite(site, fetched_image);
|
| FinishRequestAndNotifyIconAvailable(site.url, /*newly_available=*/true);
|
| + RecordPopularSitesFaviconFetchResult(TileFaviconFetchResult::SUCCESS);
|
| }
|
|
|
| void IconCacherImpl::SaveAndNotifyDefaultIconForSite(
|
| @@ -196,10 +214,17 @@ void IconCacherImpl::OnGetLargeIconOrFallbackStyleFinished(
|
| large_icon_service_
|
| ->GetLargeIconOrFallbackStyleFromGoogleServerSkippingLocalCache(
|
| page_url, kTileIconMinSizePx, kTileIconDesiredSizePx,
|
| - base::Bind(&IconCacherImpl::FinishRequestAndNotifyIconAvailable,
|
| + base::Bind(&IconCacherImpl::OnMostLikelyFaviconDownloaded,
|
| weak_ptr_factory_.GetWeakPtr(), page_url));
|
| }
|
|
|
| +void IconCacherImpl::OnMostLikelyFaviconDownloaded(const GURL& request_url,
|
| + bool success) {
|
| + RecordMostLikelyFaviconFetchResult(success ? TileFaviconFetchResult::SUCCESS
|
| + : TileFaviconFetchResult::FAILURE);
|
| + FinishRequestAndNotifyIconAvailable(request_url, success);
|
| +}
|
| +
|
| bool IconCacherImpl::StartRequest(const GURL& request_url,
|
| const base::Closure& icon_available) {
|
| bool in_flight = in_flight_requests_.count(request_url) > 0;
|
|
|