OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 // |
| 5 // Holds helpers for gathering UMA stats about downloads. |
| 6 |
| 7 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_STATS_H_ |
| 8 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_STATS_H_ |
| 9 #pragma once |
| 10 |
| 11 #include <string> |
| 12 |
| 13 #include "base/basictypes.h" |
| 14 |
| 15 namespace base { |
| 16 class TimeTicks; |
| 17 } |
| 18 |
| 19 namespace download_stats { |
| 20 |
| 21 // We keep a count of how often various events occur in the |
| 22 // histogram "Download.Counts". |
| 23 enum DownloadCountTypes { |
| 24 // The download was initiated by navigating to a URL (e.g. by user |
| 25 // click). |
| 26 INITIATED_BY_NAVIGATION_COUNT = 0, |
| 27 |
| 28 // The download was initiated by invoking a context menu within a page. |
| 29 INITIATED_BY_CONTEXT_MENU_COUNT, |
| 30 |
| 31 // The download was initiated when the SavePackage system rejected |
| 32 // a Save Page As ... by returning false from |
| 33 // SavePackage::IsSaveableContents(). |
| 34 INITIATED_BY_SAVE_PACKAGE_FAILURE_COUNT, |
| 35 |
| 36 // The download was initiated by a drag and drop from a drag-and-drop |
| 37 // enabled web application. |
| 38 INITIATED_BY_DRAG_N_DROP_COUNT, |
| 39 |
| 40 // The download was initiated by explicit RPC from the renderer process |
| 41 // (e.g. by Alt-click). |
| 42 INITIATED_BY_RENDERER_COUNT, |
| 43 |
| 44 // Downloads that made it to DownloadResourceHandler -- all of the |
| 45 // above minus those blocked by DownloadThrottlingResourceHandler. |
| 46 UNTHROTTLED_COUNT, |
| 47 |
| 48 // Downloads that actually complete. |
| 49 COMPLETED_COUNT, |
| 50 |
| 51 // Downloads that are cancelled before completion (user action or error). |
| 52 CANCELLED_COUNT, |
| 53 |
| 54 // Downloads that are started. Should be equal to UNTHROTTLED_COUNT. |
| 55 START_COUNT, |
| 56 |
| 57 // Downloads that were interrupted by the OS. |
| 58 INTERRUPTED_COUNT, |
| 59 |
| 60 DOWNLOAD_COUNT_TYPES_LAST_ENTRY |
| 61 }; |
| 62 |
| 63 // Increment one of the above counts. |
| 64 void RecordDownloadCount(DownloadCountTypes type); |
| 65 |
| 66 // Record COMPLETED_COUNT and how long the download took. |
| 67 void RecordDownloadCompleted(const base::TimeTicks& start); |
| 68 |
| 69 // Record INTERRUPTED_COUNT, |error|, |received| and |total| bytes. |
| 70 void RecordDownloadInterrupted(int error, int64 received, int64 total); |
| 71 |
| 72 // Records the mime type of the download. |
| 73 void RecordDownloadMimeType(const std::string& mime_type); |
| 74 |
| 75 } // namespace download_util |
| 76 |
| 77 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_STATS_H_ |
OLD | NEW |