| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 // Holds helpers for gathering UMA stats about downloads. | 5 // Holds helpers for gathering UMA stats about downloads. |
| 6 | 6 |
| 7 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_STATS_H_ | 7 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_STATS_H_ |
| 8 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_STATS_H_ | 8 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_STATS_H_ |
| 9 #pragma once | 9 #pragma once |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
| 15 #include "content/browser/download/interrupt_reasons.h" | 15 #include "content/browser/download/interrupt_reasons.h" |
| 16 | 16 |
| 17 namespace base { | 17 namespace base { |
| 18 class Time; | 18 class Time; |
| 19 class TimeTicks; | 19 class TimeTicks; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace download_stats { | 22 namespace download_stats { |
| 23 | 23 |
| 24 // We keep a count of how often various events occur in the | 24 // We keep a count of how often various events occur in the |
| 25 // histogram "Download.Counts". | 25 // histogram "Download.Counts". |
| 26 enum DownloadCountTypes { | 26 enum DownloadCountTypes { |
| 27 // The download was initiated by navigating to a URL (e.g. by user | 27 // Stale enum values left around so that values passed to UMA don't |
| 28 // click). | 28 // change. |
| 29 // This is now unused, but left around so that the values don't change. | 29 DOWNLOAD_COUNT_UNUSED_0 = 0, |
| 30 INITIATED_BY_NAVIGATION_COUNT = 0, | 30 DOWNLOAD_COUNT_UNUSED_1, |
| 31 DOWNLOAD_COUNT_UNUSED_2, |
| 32 DOWNLOAD_COUNT_UNUSED_3, |
| 33 DOWNLOAD_COUNT_UNUSED_4, |
| 31 | 34 |
| 32 // The download was initiated by invoking a context menu within a page. | 35 // Downloads that made it to DownloadResourceHandler |
| 33 // This is now unused, but left around so that the values don't change. | |
| 34 INITIATED_BY_CONTEXT_MENU_COUNT, | |
| 35 | |
| 36 // The download was initiated when the SavePackage system rejected | |
| 37 // a Save Page As ... by returning false from | |
| 38 // SavePackage::IsSaveableContents(). | |
| 39 INITIATED_BY_SAVE_PACKAGE_FAILURE_COUNT, | |
| 40 | |
| 41 // The download was initiated by a drag and drop from a drag-and-drop | |
| 42 // enabled web application. | |
| 43 INITIATED_BY_DRAG_N_DROP_COUNT, | |
| 44 | |
| 45 // The download was initiated by explicit RPC from the renderer process | |
| 46 // (e.g. by Alt-click). | |
| 47 INITIATED_BY_RENDERER_COUNT, | |
| 48 | |
| 49 // Downloads that made it to DownloadResourceHandler -- all of the | |
| 50 // above minus those blocked by DownloadThrottlingResourceHandler. | |
| 51 UNTHROTTLED_COUNT, | 36 UNTHROTTLED_COUNT, |
| 52 | 37 |
| 53 // Downloads that actually complete. | 38 // Downloads that actually complete. |
| 54 COMPLETED_COUNT, | 39 COMPLETED_COUNT, |
| 55 | 40 |
| 56 // Downloads that are cancelled before completion (user action or error). | 41 // Downloads that are cancelled before completion (user action or error). |
| 57 CANCELLED_COUNT, | 42 CANCELLED_COUNT, |
| 58 | 43 |
| 59 // Downloads that are started. Should be equal to UNTHROTTLED_COUNT. | 44 // Downloads that are started. Should be equal to UNTHROTTLED_COUNT. |
| 60 START_COUNT, | 45 START_COUNT, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 74 // Counts errors due to writes to BaseFiles that have been detached already. | 59 // Counts errors due to writes to BaseFiles that have been detached already. |
| 75 // This can happen when saving web pages as complete packages. It happens | 60 // This can happen when saving web pages as complete packages. It happens |
| 76 // when we get messages to append data to files that have already finished and | 61 // when we get messages to append data to files that have already finished and |
| 77 // been detached, but haven't yet been removed from the list of files in | 62 // been detached, but haven't yet been removed from the list of files in |
| 78 // progress. | 63 // progress. |
| 79 APPEND_TO_DETACHED_FILE_COUNT, | 64 APPEND_TO_DETACHED_FILE_COUNT, |
| 80 | 65 |
| 81 DOWNLOAD_COUNT_TYPES_LAST_ENTRY | 66 DOWNLOAD_COUNT_TYPES_LAST_ENTRY |
| 82 }; | 67 }; |
| 83 | 68 |
| 69 enum DownloadSource { |
| 70 // The download was initiated when the SavePackage system rejected |
| 71 // a Save Page As ... by returning false from |
| 72 // SavePackage::IsSaveableContents(). |
| 73 INITIATED_BY_SAVE_PACKAGE_ON_NON_HTML = 0, |
| 74 |
| 75 // The download was initiated by a drag and drop from a drag-and-drop |
| 76 // enabled web application. |
| 77 INITIATED_BY_DRAG_N_DROP, |
| 78 |
| 79 // The download was initiated by explicit RPC from the renderer process |
| 80 // (e.g. by Alt-click) through the IPC ViewHostMsg_DownloadUrl. |
| 81 INITIATED_BY_RENDERER, |
| 82 |
| 83 // The download was initiated by a renderer or plugin process through |
| 84 // the IPC ViewHostMsg_SaveURLAs; currently this is only used by the |
| 85 // Pepper plugin API. |
| 86 INITIATED_BY_PEPPER_SAVE, |
| 87 |
| 88 DOWNLOAD_SOURCE_LAST_ENTRY |
| 89 }; |
| 90 |
| 91 |
| 84 // Increment one of the above counts. | 92 // Increment one of the above counts. |
| 85 CONTENT_EXPORT void RecordDownloadCount(DownloadCountTypes type); | 93 void RecordDownloadCount(DownloadCountTypes type); |
| 94 |
| 95 // Record initiation of a download from a specific source. |
| 96 void RecordDownloadSource(DownloadSource source); |
| 86 | 97 |
| 87 // Record COMPLETED_COUNT and how long the download took. | 98 // Record COMPLETED_COUNT and how long the download took. |
| 88 void RecordDownloadCompleted(const base::TimeTicks& start, int64 download_len); | 99 void RecordDownloadCompleted(const base::TimeTicks& start, int64 download_len); |
| 89 | 100 |
| 90 // Record INTERRUPTED_COUNT, |reason|, |received| and |total| bytes. | 101 // Record INTERRUPTED_COUNT, |reason|, |received| and |total| bytes. |
| 91 void RecordDownloadInterrupted(InterruptReason reason, | 102 void RecordDownloadInterrupted(InterruptReason reason, |
| 92 int64 received, | 103 int64 received, |
| 93 int64 total); | 104 int64 total); |
| 94 | 105 |
| 95 // Records the mime type of the download. | 106 // Records the mime type of the download. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 122 | 133 |
| 123 // Record the number of downloads removed by ClearAll. | 134 // Record the number of downloads removed by ClearAll. |
| 124 void RecordClearAllSize(int size); | 135 void RecordClearAllSize(int size); |
| 125 | 136 |
| 126 // Record the number of completed unopened downloads when a download is opened. | 137 // Record the number of completed unopened downloads when a download is opened. |
| 127 void RecordOpensOutstanding(int size); | 138 void RecordOpensOutstanding(int size); |
| 128 | 139 |
| 129 } // namespace download_stats | 140 } // namespace download_stats |
| 130 | 141 |
| 131 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_STATS_H_ | 142 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_STATS_H_ |
| OLD | NEW |