diff options
author | rdsmith@chromium.org <rdsmith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-13 21:52:36 +0000 |
---|---|---|
committer | rdsmith@chromium.org <rdsmith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-13 21:52:36 +0000 |
commit | 11b0e9db1d5ca140bfddcfdf061cbaa2ceabf840 (patch) | |
tree | 030684ff2da0811e641a960f0309b137502791d2 | |
parent | 8991546320ff9e55cf9c4464215e3b582ea92848 (diff) | |
download | chromium_src-11b0e9db1d5ca140bfddcfdf061cbaa2ceabf840.zip chromium_src-11b0e9db1d5ca140bfddcfdf061cbaa2ceabf840.tar.gz chromium_src-11b0e9db1d5ca140bfddcfdf061cbaa2ceabf840.tar.bz2 |
Count histograms initiated and finished by the download system.
BUG=None
TEST=Try bots, test several pathways by hand.
Review URL: http://codereview.chromium.org/6801029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81490 0039d316-1c4b-4281-b951-d872f2087c98
9 files changed, 72 insertions, 4 deletions
diff --git a/chrome/browser/download/download_item.cc b/chrome/browser/download/download_item.cc index 321b031..b6f9c3b 100644 --- a/chrome/browser/download/download_item.cc +++ b/chrome/browser/download/download_item.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// 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. @@ -344,6 +344,9 @@ void DownloadItem::Cancel(bool update_history) { // a chance to run. return; } + + download_util::RecordDownloadCount(download_util::CANCELLED_COUNT); + state_ = CANCELLED; UpdateObservers(); StopProgressTimer(); @@ -366,6 +369,9 @@ void DownloadItem::OnAllDataSaved(int64 size) { void DownloadItem::Finished() { VLOG(20) << " " << __FUNCTION__ << "() " << DebugString(false); + + download_util::RecordDownloadCount(download_util::COMPLETED_COUNT); + // Handle chrome extensions explicitly and skip the shell execute. if (is_extension_install()) { download_util::OpenChromeExtension(download_manager_->profile(), diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc index e85c0ce..74400ec 100644 --- a/chrome/browser/download/download_util.cc +++ b/chrome/browser/download/download_util.cc @@ -15,6 +15,7 @@ #include "base/i18n/rtl.h" #include "base/i18n/time_formatting.h" #include "base/lazy_instance.h" +#include "base/metrics/histogram.h" #include "base/path_service.h" #include "base/string16.h" #include "base/string_number_conversions.h" @@ -343,6 +344,11 @@ void OpenChromeExtension(Profile* profile, installer->set_allow_silent_install(is_gallery_download); } +void RecordDownloadCount(DownloadCountTypes type) { + UMA_HISTOGRAM_ENUMERATION( + "Download.Counts", type, DOWNLOAD_COUNT_TYPES_LAST_ENTRY); +} + // Download progress painting -------------------------------------------------- // Common bitmaps used for download progress animations. We load them once the diff --git a/chrome/browser/download/download_util.h b/chrome/browser/download/download_util.h index 8edf1ea..170b05c 100644 --- a/chrome/browser/download/download_util.h +++ b/chrome/browser/download/download_util.h @@ -118,6 +118,45 @@ enum PaintDownloadProgressSize { BIG }; +// 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, + + DOWNLOAD_COUNT_TYPES_LAST_ENTRY +}; + +// Increment one of the above counts. +void RecordDownloadCount(DownloadCountTypes type); + // Paint the common download animation progress foreground and background, // clipping the foreground to 'percent' full. If percent is -1, then we don't // know the total size, so we just draw a rotating segment until we're done. diff --git a/chrome/browser/download/drag_download_file.cc b/chrome/browser/download/drag_download_file.cc index 4f0dc85..e047100 100644 --- a/chrome/browser/download/drag_download_file.cc +++ b/chrome/browser/download/drag_download_file.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2010 The Chromium Authors. All rights reserved. +// 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. @@ -8,6 +8,7 @@ #include "base/message_loop.h" #include "chrome/browser/download/download_file.h" #include "chrome/browser/download/download_item.h" +#include "chrome/browser/download/download_util.h" #include "chrome/browser/profiles/profile.h" #include "content/browser/browser_thread.h" #include "content/browser/tab_contents/tab_contents.h" @@ -115,6 +116,8 @@ void DragDownloadFile::InitiateDownload() { referrer_encoding_, save_info, tab_contents_); + download_util::RecordDownloadCount( + download_util::INITIATED_BY_DRAG_N_DROP_COUNT); } void DragDownloadFile::DownloadCompleted(bool is_successful) { diff --git a/chrome/browser/renderer_host/download_resource_handler.cc b/chrome/browser/renderer_host/download_resource_handler.cc index ae353a1..8f46cfa 100644 --- a/chrome/browser/renderer_host/download_resource_handler.cc +++ b/chrome/browser/renderer_host/download_resource_handler.cc @@ -12,6 +12,7 @@ #include "base/stringprintf.h" #include "chrome/browser/download/download_item.h" #include "chrome/browser/download/download_file_manager.h" +#include "chrome/browser/download/download_util.h" #include "chrome/browser/history/download_create_info.h" #include "content/browser/browser_thread.h" #include "content/browser/renderer_host/global_request_id.h" @@ -45,6 +46,7 @@ DownloadResourceHandler::DownloadResourceHandler( buffer_(new DownloadBuffer), rdh_(rdh), is_paused_(false) { + download_util::RecordDownloadCount(download_util::UNTHROTTLED_COUNT); } bool DownloadResourceHandler::OnUploadProgress(int request_id, diff --git a/chrome/browser/renderer_host/download_throttling_resource_handler.cc b/chrome/browser/renderer_host/download_throttling_resource_handler.cc index b6c4998..34d90ae 100644 --- a/chrome/browser/renderer_host/download_throttling_resource_handler.cc +++ b/chrome/browser/renderer_host/download_throttling_resource_handler.cc @@ -29,6 +29,9 @@ DownloadThrottlingResourceHandler::DownloadThrottlingResourceHandler( tmp_buffer_length_(0), ignore_on_read_complete_(in_complete), request_closed_(false) { + download_util::RecordDownloadCount( + download_util::INITIATED_BY_NAVIGATION_COUNT); + // Pause the request. host_->PauseRequest(render_process_host_id_, request_id_, true); diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index ae99479..2006a41 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -22,6 +22,7 @@ #include "chrome/browser/debugger/devtools_manager.h" #include "chrome/browser/debugger/devtools_window.h" #include "chrome/browser/download/download_manager.h" +#include "chrome/browser/download/download_util.h" #include "chrome/browser/download/save_package.h" #include "chrome/browser/extensions/extension_event_router.h" #include "chrome/browser/extensions/extension_service.h" @@ -1209,6 +1210,8 @@ void RenderViewContextMenu::ExecuteCommand(int id) { case IDC_CONTENT_CONTEXT_SAVEAVAS: case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: case IDC_CONTENT_CONTEXT_SAVELINKAS: { + download_util::RecordDownloadCount( + download_util::INITIATED_BY_CONTEXT_MENU_COUNT); const GURL& referrer = params_.frame_url.is_empty() ? params_.page_url : params_.frame_url; const GURL& url = diff --git a/chrome/browser/ui/download/download_tab_helper.cc b/chrome/browser/ui/download/download_tab_helper.cc index 384baf4..16bb44b 100644 --- a/chrome/browser/ui/download/download_tab_helper.cc +++ b/chrome/browser/ui/download/download_tab_helper.cc @@ -5,6 +5,7 @@ #include "chrome/browser/ui/download/download_tab_helper.h" #include "chrome/browser/download/download_manager.h" +#include "chrome/browser/download/download_util.h" #include "chrome/browser/profiles/profile.h" #include "content/browser/tab_contents/tab_contents.h" @@ -21,8 +22,11 @@ void DownloadTabHelper::OnSavePage() { if (!SavePackage::IsSavableContents(tab_contents_->contents_mime_type())) { DownloadManager* dlm = tab_contents_->profile()->GetDownloadManager(); const GURL& current_page_url = tab_contents_->GetURL(); - if (dlm && current_page_url.is_valid()) + if (dlm && current_page_url.is_valid()) { dlm->DownloadUrl(current_page_url, GURL(), "", tab_contents_); + download_util::RecordDownloadCount( + download_util::INITIATED_BY_SAVE_PACKAGE_FAILURE_COUNT); + } return; } @@ -48,4 +52,3 @@ bool DownloadTabHelper::SavePage(const FilePath& main_file, new SavePackage(tab_contents_, save_type, main_file, dir_path); return save_package_->Init(); } - diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc index a7387e5..42a6e2e 100644 --- a/content/browser/renderer_host/render_message_filter.cc +++ b/content/browser/renderer_host/render_message_filter.cc @@ -15,6 +15,7 @@ #include "chrome/browser/automation/automation_resource_message_filter.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/download/download_types.h" +#include "chrome/browser/download/download_util.h" #include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/net/predictor_api.h" @@ -622,6 +623,8 @@ void RenderMessageFilter::OnDownloadUrl(const IPC::Message& message, render_process_id_, message.routing_id(), context); + download_util::RecordDownloadCount( + download_util::INITIATED_BY_RENDERER_COUNT); } void RenderMessageFilter::OnCheckNotificationPermission( |