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

Side by Side Diff: content/browser/download/download_manager.cc

Issue 8008021: Add new UMA stats to get a handle on Downloads UI Usage (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: uma Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
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 #include "content/browser/download/download_manager.h" 5 #include "content/browser/download/download_manager.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/i18n/case_conversion.h" 12 #include "base/i18n/case_conversion.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
16 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
17 #include "base/sys_string_conversions.h" 17 #include "base/sys_string_conversions.h"
18 #include "base/task.h" 18 #include "base/task.h"
19 #include "build/build_config.h" 19 #include "build/build_config.h"
20 #include "content/browser/browser_context.h" 20 #include "content/browser/browser_context.h"
21 #include "content/browser/browser_thread.h" 21 #include "content/browser/browser_thread.h"
22 #include "content/browser/content_browser_client.h" 22 #include "content/browser/content_browser_client.h"
23 #include "content/browser/download/download_create_info.h" 23 #include "content/browser/download/download_create_info.h"
24 #include "content/browser/download/download_file_manager.h" 24 #include "content/browser/download/download_file_manager.h"
25 #include "content/browser/download/download_item.h" 25 #include "content/browser/download/download_item.h"
26 #include "content/browser/download/download_manager_delegate.h" 26 #include "content/browser/download/download_manager_delegate.h"
27 #include "content/browser/download/download_persistent_store_info.h" 27 #include "content/browser/download/download_persistent_store_info.h"
28 #include "content/browser/download/download_stats.h"
28 #include "content/browser/download/download_status_updater.h" 29 #include "content/browser/download/download_status_updater.h"
29 #include "content/browser/renderer_host/render_process_host.h" 30 #include "content/browser/renderer_host/render_process_host.h"
30 #include "content/browser/renderer_host/render_view_host.h" 31 #include "content/browser/renderer_host/render_view_host.h"
31 #include "content/browser/renderer_host/resource_dispatcher_host.h" 32 #include "content/browser/renderer_host/resource_dispatcher_host.h"
32 #include "content/browser/tab_contents/tab_contents.h" 33 #include "content/browser/tab_contents/tab_contents.h"
33 #include "content/common/content_notification_types.h" 34 #include "content/common/content_notification_types.h"
34 #include "content/common/notification_service.h" 35 #include "content/common/notification_service.h"
35 36
36 namespace { 37 namespace {
37 38
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 SelectFileDialogDisplayed(download_id)); 320 SelectFileDialogDisplayed(download_id));
320 } else { 321 } else {
321 // No prompting for download, just continue with the suggested name. 322 // No prompting for download, just continue with the suggested name.
322 ContinueDownloadWithPath(download, suggested_path); 323 ContinueDownloadWithPath(download, suggested_path);
323 } 324 }
324 } 325 }
325 326
326 void DownloadManager::CreateDownloadItem(DownloadCreateInfo* info) { 327 void DownloadManager::CreateDownloadItem(DownloadCreateInfo* info) {
327 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 328 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
328 329
330 download_stats::RecordHistorySize2(history_downloads_.size());
331
329 DownloadItem* download = new DownloadItem(this, *info, 332 DownloadItem* download = new DownloadItem(this, *info,
330 browser_context_->IsOffTheRecord()); 333 browser_context_->IsOffTheRecord());
331 int32 download_id = info->download_id; 334 int32 download_id = info->download_id;
332 DCHECK(!ContainsKey(in_progress_, download_id)); 335 DCHECK(!ContainsKey(in_progress_, download_id));
333 336
334 // TODO(rdsmith): Remove after http://crbug.com/85408 resolved. 337 // TODO(rdsmith): Remove after http://crbug.com/85408 resolved.
335 CHECK(!ContainsKey(active_downloads_, download_id)); 338 CHECK(!ContainsKey(active_downloads_, download_id));
336 downloads_.insert(download); 339 downloads_.insert(download);
337 active_downloads_[download_id] = download; 340 active_downloads_[download_id] = download;
338 } 341 }
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 } 678 }
676 } 679 }
677 return RemoveDownloadItems(pending_deletes); 680 return RemoveDownloadItems(pending_deletes);
678 } 681 }
679 682
680 int DownloadManager::RemoveDownloads(const base::Time remove_begin) { 683 int DownloadManager::RemoveDownloads(const base::Time remove_begin) {
681 return RemoveDownloadsBetween(remove_begin, base::Time()); 684 return RemoveDownloadsBetween(remove_begin, base::Time());
682 } 685 }
683 686
684 int DownloadManager::RemoveAllDownloads() { 687 int DownloadManager::RemoveAllDownloads() {
688 download_stats::RecordClearAllSize(history_downloads_.size());
685 // The null times make the date range unbounded. 689 // The null times make the date range unbounded.
686 return RemoveDownloadsBetween(base::Time(), base::Time()); 690 return RemoveDownloadsBetween(base::Time(), base::Time());
687 } 691 }
688 692
689 // Initiate a download of a specific URL. We send the request to the 693 // Initiate a download of a specific URL. We send the request to the
690 // ResourceDispatcherHost, and let it send us responses like a regular 694 // ResourceDispatcherHost, and let it send us responses like a regular
691 // download. 695 // download.
692 void DownloadManager::DownloadUrl(const GURL& url, 696 void DownloadManager::DownloadUrl(const GURL& url,
693 const GURL& referrer, 697 const GURL& referrer,
694 const std::string& referrer_charset, 698 const std::string& referrer_charset,
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 // Operations posted to us from the history service ---------------------------- 814 // Operations posted to us from the history service ----------------------------
811 815
812 // The history service has retrieved all download entries. 'entries' contains 816 // The history service has retrieved all download entries. 'entries' contains
813 // 'DownloadPersistentStoreInfo's in sorted order (by ascending start_time). 817 // 'DownloadPersistentStoreInfo's in sorted order (by ascending start_time).
814 void DownloadManager::OnPersistentStoreQueryComplete( 818 void DownloadManager::OnPersistentStoreQueryComplete(
815 std::vector<DownloadPersistentStoreInfo>* entries) { 819 std::vector<DownloadPersistentStoreInfo>* entries) {
816 // TODO(rdsmith): Remove this and related logic when 820 // TODO(rdsmith): Remove this and related logic when
817 // http://crbug.com/84508 is fixed. 821 // http://crbug.com/84508 is fixed.
818 largest_db_handle_in_history_ = 0; 822 largest_db_handle_in_history_ = 0;
819 823
824 download_stats::RecordHistorySize(entries->size());
825
820 for (size_t i = 0; i < entries->size(); ++i) { 826 for (size_t i = 0; i < entries->size(); ++i) {
821 DownloadItem* download = new DownloadItem(this, entries->at(i)); 827 DownloadItem* download = new DownloadItem(this, entries->at(i));
822 // TODO(rdsmith): Remove after http://crbug.com/85408 resolved. 828 // TODO(rdsmith): Remove after http://crbug.com/85408 resolved.
823 CHECK(!ContainsKey(history_downloads_, download->db_handle())); 829 CHECK(!ContainsKey(history_downloads_, download->db_handle()));
824 downloads_.insert(download); 830 downloads_.insert(download);
825 history_downloads_[download->db_handle()] = download; 831 history_downloads_[download->db_handle()] = download;
826 VLOG(20) << __FUNCTION__ << "()" << i << ">" 832 VLOG(20) << __FUNCTION__ << "()" << i << ">"
827 << " download = " << download->DebugString(true); 833 << " download = " << download->DebugString(true);
828 834
829 if (download->db_handle() > largest_db_handle_in_history_) 835 if (download->db_handle() > largest_db_handle_in_history_)
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 DCHECK(ContainsKey(save_page_downloads_, download->id())); 1067 DCHECK(ContainsKey(save_page_downloads_, download->id()));
1062 save_page_downloads_.erase(download->id()); 1068 save_page_downloads_.erase(download->id());
1063 1069
1064 if (download->IsComplete()) 1070 if (download->IsComplete())
1065 NotificationService::current()->Notify( 1071 NotificationService::current()->Notify(
1066 content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED, 1072 content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED,
1067 Source<DownloadManager>(this), 1073 Source<DownloadManager>(this),
1068 Details<DownloadItem>(download)); 1074 Details<DownloadItem>(download));
1069 } 1075 }
1070 } 1076 }
1077
1078 void DownloadManager::MarkDownloadOpened(int64 db_handle) {
1079 delegate_->MarkDownloadOpened(db_handle);
1080 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698