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

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: merge Created 9 years, 2 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/download/interrupt_reasons.h" 30 #include "content/browser/download/interrupt_reasons.h"
30 #include "content/browser/renderer_host/render_process_host.h" 31 #include "content/browser/renderer_host/render_process_host.h"
31 #include "content/browser/renderer_host/render_view_host.h" 32 #include "content/browser/renderer_host/render_view_host.h"
32 #include "content/browser/renderer_host/resource_dispatcher_host.h" 33 #include "content/browser/renderer_host/resource_dispatcher_host.h"
33 #include "content/browser/tab_contents/tab_contents.h" 34 #include "content/browser/tab_contents/tab_contents.h"
34 #include "content/common/content_notification_types.h" 35 #include "content/common/content_notification_types.h"
35 #include "content/common/notification_service.h" 36 #include "content/common/notification_service.h"
36 37
37 namespace { 38 namespace {
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 } 683 }
683 } 684 }
684 return RemoveDownloadItems(pending_deletes); 685 return RemoveDownloadItems(pending_deletes);
685 } 686 }
686 687
687 int DownloadManager::RemoveDownloads(const base::Time remove_begin) { 688 int DownloadManager::RemoveDownloads(const base::Time remove_begin) {
688 return RemoveDownloadsBetween(remove_begin, base::Time()); 689 return RemoveDownloadsBetween(remove_begin, base::Time());
689 } 690 }
690 691
691 int DownloadManager::RemoveAllDownloads() { 692 int DownloadManager::RemoveAllDownloads() {
693 download_stats::RecordClearAllSize(history_downloads_.size());
692 // The null times make the date range unbounded. 694 // The null times make the date range unbounded.
693 return RemoveDownloadsBetween(base::Time(), base::Time()); 695 return RemoveDownloadsBetween(base::Time(), base::Time());
694 } 696 }
695 697
696 // Initiate a download of a specific URL. We send the request to the 698 // Initiate a download of a specific URL. We send the request to the
697 // ResourceDispatcherHost, and let it send us responses like a regular 699 // ResourceDispatcherHost, and let it send us responses like a regular
698 // download. 700 // download.
699 void DownloadManager::DownloadUrl(const GURL& url, 701 void DownloadManager::DownloadUrl(const GURL& url,
700 const GURL& referrer, 702 const GURL& referrer,
701 const std::string& referrer_charset, 703 const std::string& referrer_charset,
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 } 843 }
842 844
843 void DownloadManager::AddDownloadItemToHistory(DownloadItem* download, 845 void DownloadManager::AddDownloadItemToHistory(DownloadItem* download,
844 int64 db_handle) { 846 int64 db_handle) {
845 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 847 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
846 848
847 // TODO(rdsmith): Convert to DCHECK() when http://crbug.com/85408 849 // TODO(rdsmith): Convert to DCHECK() when http://crbug.com/85408
848 // is fixed. 850 // is fixed.
849 CHECK_NE(DownloadItem::kUninitializedHandle, db_handle); 851 CHECK_NE(DownloadItem::kUninitializedHandle, db_handle);
850 852
853 download_stats::RecordHistorySize(history_downloads_.size());
854
851 DCHECK(download->db_handle() == DownloadItem::kUninitializedHandle); 855 DCHECK(download->db_handle() == DownloadItem::kUninitializedHandle);
852 download->set_db_handle(db_handle); 856 download->set_db_handle(db_handle);
853 857
854 // TODO(rdsmith): Convert to DCHECK() when http://crbug.com/85408 858 // TODO(rdsmith): Convert to DCHECK() when http://crbug.com/85408
855 // is fixed. 859 // is fixed.
856 CHECK(!ContainsKey(history_downloads_, download->db_handle())); 860 CHECK(!ContainsKey(history_downloads_, download->db_handle()));
857 history_downloads_[download->db_handle()] = download; 861 history_downloads_[download->db_handle()] = download;
858 862
859 // Show in the appropriate browser UI. 863 // Show in the appropriate browser UI.
860 // This includes buttons to save or cancel, for a dangerous download. 864 // This includes buttons to save or cancel, for a dangerous download.
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 DCHECK(ContainsKey(save_page_downloads_, download->id())); 1072 DCHECK(ContainsKey(save_page_downloads_, download->id()));
1069 save_page_downloads_.erase(download->id()); 1073 save_page_downloads_.erase(download->id());
1070 1074
1071 if (download->IsComplete()) 1075 if (download->IsComplete())
1072 NotificationService::current()->Notify( 1076 NotificationService::current()->Notify(
1073 content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED, 1077 content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED,
1074 Source<DownloadManager>(this), 1078 Source<DownloadManager>(this),
1075 Details<DownloadItem>(download)); 1079 Details<DownloadItem>(download));
1076 } 1080 }
1077 } 1081 }
1082
1083 void DownloadManager::MarkDownloadOpened(DownloadItem* download) {
1084 delegate_->UpdateItemInPersistentStore(download);
1085 int num_unopened = 0;
1086 for (DownloadMap::iterator it = history_downloads_.begin();
1087 it != history_downloads_.end(); ++it) {
1088 if (it->second->IsComplete() && !it->second->opened())
1089 ++num_unopened;
1090 }
1091 download_stats::RecordOpensOutstanding(num_unopened);
1092 }
OLDNEW
« no previous file with comments | « content/browser/download/download_manager.h ('k') | content/browser/download/download_manager_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698