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

Side by Side Diff: components/favicon/core/favicon_handler.h

Issue 2808063002: Add DownloadStatus metric to FaviconHandler (Closed)
Patch Set: Optimize UMA macro usage 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 (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 #ifndef COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_ 5 #ifndef COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_
6 #define COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_ 6 #define COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // 68 //
69 // When the renderer downloads favicons, it considers the entire list of 69 // When the renderer downloads favicons, it considers the entire list of
70 // favicon candidates, if |download_largest_favicon_| is true, the largest 70 // favicon candidates, if |download_largest_favicon_| is true, the largest
71 // favicon will be used, otherwise the one that best matches the preferred size 71 // favicon will be used, otherwise the one that best matches the preferred size
72 // is chosen (or the first one if there is no preferred size). Once the 72 // is chosen (or the first one if there is no preferred size). Once the
73 // matching favicon has been determined, SetFavicon is called which updates 73 // matching favicon has been determined, SetFavicon is called which updates
74 // the page's favicon and notifies the database to save the favicon. 74 // the page's favicon and notifies the database to save the favicon.
75 75
76 class FaviconHandler { 76 class FaviconHandler {
77 public: 77 public:
78 // Outcome of a favicon download.
79 // Recorded as Favicons.DownloadOutcome and public for testing.
80 //
81 // These values must stay in sync with the FaviconDownloadStatus enum
82 // in histograms.xml and should be treated as append-only, since it backs an
83 // UMA histogram..
84 enum class DownloadOutcome {
85 SUCCEEDED = 0,
86 FAILED = 1,
87 SKIPPED = 2,
88 DOWNLOAD_OUTCOME_COUNT = 3
89 };
90
78 class Delegate { 91 class Delegate {
79 public: 92 public:
80 // Mimics WebContents::ImageDownloadCallback. 93 // Mimics WebContents::ImageDownloadCallback.
81 typedef base::Callback<void( 94 typedef base::Callback<void(
82 int id, 95 int id,
83 int status_code, 96 int status_code,
84 const GURL& image_url, 97 const GURL& image_url,
85 const std::vector<SkBitmap>& bitmaps, 98 const std::vector<SkBitmap>& bitmaps,
86 const std::vector<gfx::Size>& original_bitmap_sizes)> 99 const std::vector<gfx::Size>& original_bitmap_sizes)>
87 ImageDownloadCallback; 100 ImageDownloadCallback;
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 GURL notification_icon_url_; 296 GURL notification_icon_url_;
284 favicon_base::IconType notification_icon_type_; 297 favicon_base::IconType notification_icon_type_;
285 298
286 // The FaviconService which implements favicon operations. May be null during 299 // The FaviconService which implements favicon operations. May be null during
287 // testing. 300 // testing.
288 FaviconService* service_; 301 FaviconService* service_;
289 302
290 // This handler's delegate. 303 // This handler's delegate.
291 Delegate* delegate_; 304 Delegate* delegate_;
292 305
306 // Captures the number of download requests that were initiated for the
307 // current url_.
308 int num_download_requests_;
309
293 // The index of the favicon URL in |image_urls_| which is currently being 310 // The index of the favicon URL in |image_urls_| which is currently being
294 // requested from history or downloaded. 311 // requested from history or downloaded.
295 size_t current_candidate_index_; 312 size_t current_candidate_index_;
296 313
297 // Best image we've seen so far. As images are downloaded from the page they 314 // Best image we've seen so far. As images are downloaded from the page they
298 // are stored here. When a satisfying icon is found (as defined in 315 // are stored here. When a satisfying icon is found (as defined in
299 // UpdateFaviconCandidate()), the favicon service and the delegate are 316 // UpdateFaviconCandidate()), the favicon service and the delegate are
300 // notified. 317 // notified.
301 DownloadedFavicon best_favicon_; 318 DownloadedFavicon best_favicon_;
302 319
303 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); 320 DISALLOW_COPY_AND_ASSIGN(FaviconHandler);
304 }; 321 };
305 322
306 } // namespace favicon 323 } // namespace favicon
307 324
308 #endif // COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_ 325 #endif // COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_
OLDNEW
« no previous file with comments | « no previous file | components/favicon/core/favicon_handler.cc » ('j') | components/favicon/core/favicon_handler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698