summaryrefslogtreecommitdiffstats
path: root/content/browser/download/download_stats.h
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-16 23:55:46 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-16 23:55:46 +0000
commit8bd9e5623c17e845acbc182772b63f818f1d0bd5 (patch)
tree9e93966555cc92acb9799fd2a94ad07155691ec0 /content/browser/download/download_stats.h
parent8e9424b48974b88422d873dab17058f53506437a (diff)
downloadchromium_src-8bd9e5623c17e845acbc182772b63f818f1d0bd5.zip
chromium_src-8bd9e5623c17e845acbc182772b63f818f1d0bd5.tar.gz
chromium_src-8bd9e5623c17e845acbc182772b63f818f1d0bd5.tar.bz2
Move download UMA functions to their own file in content. Also fire the chrome-only notification for download initiated in chrome code from the chrome delegate.
BUG=82782 Review URL: http://codereview.chromium.org/7664019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97059 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/download/download_stats.h')
-rw-r--r--content/browser/download/download_stats.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/content/browser/download/download_stats.h b/content/browser/download/download_stats.h
new file mode 100644
index 0000000..b1e7624
--- /dev/null
+++ b/content/browser/download/download_stats.h
@@ -0,0 +1,77 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// Holds helpers for gathering UMA stats about downloads.
+
+#ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_STATS_H_
+#define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_STATS_H_
+#pragma once
+
+#include <string>
+
+#include "base/basictypes.h"
+
+namespace base {
+class TimeTicks;
+}
+
+namespace download_stats {
+
+// We keep a count of how often various events occur in the
+// histogram "Download.Counts".
+enum DownloadCountTypes {
+ // The download was initiated by navigating to a URL (e.g. by user
+ // click).
+ INITIATED_BY_NAVIGATION_COUNT = 0,
+
+ // The download was initiated by invoking a context menu within a page.
+ INITIATED_BY_CONTEXT_MENU_COUNT,
+
+ // The download was initiated when the SavePackage system rejected
+ // a Save Page As ... by returning false from
+ // SavePackage::IsSaveableContents().
+ INITIATED_BY_SAVE_PACKAGE_FAILURE_COUNT,
+
+ // The download was initiated by a drag and drop from a drag-and-drop
+ // enabled web application.
+ INITIATED_BY_DRAG_N_DROP_COUNT,
+
+ // The download was initiated by explicit RPC from the renderer process
+ // (e.g. by Alt-click).
+ INITIATED_BY_RENDERER_COUNT,
+
+ // Downloads that made it to DownloadResourceHandler -- all of the
+ // above minus those blocked by DownloadThrottlingResourceHandler.
+ UNTHROTTLED_COUNT,
+
+ // Downloads that actually complete.
+ COMPLETED_COUNT,
+
+ // Downloads that are cancelled before completion (user action or error).
+ CANCELLED_COUNT,
+
+ // Downloads that are started. Should be equal to UNTHROTTLED_COUNT.
+ START_COUNT,
+
+ // Downloads that were interrupted by the OS.
+ INTERRUPTED_COUNT,
+
+ DOWNLOAD_COUNT_TYPES_LAST_ENTRY
+};
+
+// Increment one of the above counts.
+void RecordDownloadCount(DownloadCountTypes type);
+
+// Record COMPLETED_COUNT and how long the download took.
+void RecordDownloadCompleted(const base::TimeTicks& start);
+
+// Record INTERRUPTED_COUNT, |error|, |received| and |total| bytes.
+void RecordDownloadInterrupted(int error, int64 received, int64 total);
+
+// Records the mime type of the download.
+void RecordDownloadMimeType(const std::string& mime_type);
+
+} // namespace download_stats
+
+#endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_STATS_H_