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

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

Issue 2804283003: [LargeIconService] Report size of the downloaded favicon to UMA (Closed)
Patch Set: Created 3 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/large_icon_service.h" 5 #include "components/favicon/core/large_icon_service.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/metrics/histogram_macros.h"
15 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
16 #include "base/task_runner.h" 17 #include "base/task_runner.h"
17 #include "base/threading/sequenced_worker_pool.h" 18 #include "base/threading/sequenced_worker_pool.h"
18 #include "base/threading/thread_task_runner_handle.h" 19 #include "base/threading/thread_task_runner_handle.h"
19 #include "components/data_use_measurement/core/data_use_user_data.h" 20 #include "components/data_use_measurement/core/data_use_user_data.h"
20 #include "components/favicon/core/favicon_service.h" 21 #include "components/favicon/core/favicon_service.h"
21 #include "components/favicon_base/fallback_icon_style.h" 22 #include "components/favicon_base/fallback_icon_style.h"
22 #include "components/favicon_base/favicon_types.h" 23 #include "components/favicon_base/favicon_types.h"
23 #include "components/favicon_base/favicon_util.h" 24 #include "components/favicon_base/favicon_util.h"
24 #include "skia/ext/image_operations.h" 25 #include "skia/ext/image_operations.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 const GURL& page_url, 222 const GURL& page_url,
222 const base::Callback<void(bool success)>& callback, 223 const base::Callback<void(bool success)>& callback,
223 const std::string& icon_url, 224 const std::string& icon_url,
224 const gfx::Image& image, 225 const gfx::Image& image,
225 const image_fetcher::RequestMetadata& metadata) { 226 const image_fetcher::RequestMetadata& metadata) {
226 if (image.IsEmpty()) { 227 if (image.IsEmpty()) {
227 DLOG(WARNING) << "large icon server fetch empty " << icon_url; 228 DLOG(WARNING) << "large icon server fetch empty " << icon_url;
228 favicon_service->UnableToDownloadFavicon(GURL(icon_url)); 229 favicon_service->UnableToDownloadFavicon(GURL(icon_url));
229 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 230 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
230 base::Bind(callback, false)); 231 base::Bind(callback, false));
232 UMA_HISTOGRAM_COUNTS_1000("Favicons.LargeIconService.DownloadedSize", 0);
231 return; 233 return;
232 } 234 }
233 235
236 UMA_HISTOGRAM_COUNTS_1000("Favicons.LargeIconService.DownloadedSize",
237 image.Width());
Ilya Sherman 2017/04/07 19:26:47 nit: Histogram macros expand to a fair bit of code
jkrcal 2017/04/11 19:25:37 Done.
238
234 // TODO(crbug.com/699542): Extract the original icon url from the response 239 // TODO(crbug.com/699542): Extract the original icon url from the response
235 // headers if available and use it instead of |icon_url|. Possibly the type 240 // headers if available and use it instead of |icon_url|. Possibly the type
236 // too, because using TOUCH_ICON is a hacky way that allows us to not 241 // too, because using TOUCH_ICON is a hacky way that allows us to not
237 // interfere with sync. 242 // interfere with sync.
238 243
239 // Write fetched icons to FaviconService's cache, but only if no icon was 244 // Write fetched icons to FaviconService's cache, but only if no icon was
240 // available (clients are encouraged to do this in advance, but meanwhile 245 // available (clients are encouraged to do this in advance, but meanwhile
241 // something else could've been written). By marking the icons initially 246 // something else could've been written). By marking the icons initially
242 // expired (out-of-date), they will be refetched when we visit the original 247 // expired (out-of-date), they will be refetched when we visit the original
243 // page any time in the future. 248 // page any time in the future.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 // TODO(beaudoin): For now this is just a wrapper around 338 // TODO(beaudoin): For now this is just a wrapper around
334 // GetLargestRawFaviconForPageURL. Add the logic required to select the best 339 // GetLargestRawFaviconForPageURL. Add the logic required to select the best
335 // possible large icon. Also add logic to fetch-on-demand when the URL of 340 // possible large icon. Also add logic to fetch-on-demand when the URL of
336 // a large icon is known but its bitmap is not available. 341 // a large icon is known but its bitmap is not available.
337 return favicon_service_->GetLargestRawFaviconForPageURL( 342 return favicon_service_->GetLargestRawFaviconForPageURL(
338 page_url, large_icon_types_, min_source_size_in_pixel, 343 page_url, large_icon_types_, min_source_size_in_pixel,
339 base::Bind(&LargeIconWorker::OnIconLookupComplete, worker), tracker); 344 base::Bind(&LargeIconWorker::OnIconLookupComplete, worker), tracker);
340 } 345 }
341 346
342 } // namespace favicon 347 } // namespace favicon
OLDNEW
« no previous file with comments | « no previous file | components/favicon/core/large_icon_service_unittest.cc » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698