diff options
author | benwells@chromium.org <benwells@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-08 00:06:23 +0000 |
---|---|---|
committer | benwells@chromium.org <benwells@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-08 00:06:23 +0000 |
commit | d96ee58230265ed1c61a1e728caee735e5564d40 (patch) | |
tree | e235e30deb46dc1cec878c80401c16321ee05a68 /content | |
parent | db2b146b7fcbc7ba59c9dd0c469b34e67caa93ae (diff) | |
download | chromium_src-d96ee58230265ed1c61a1e728caee735e5564d40.zip chromium_src-d96ee58230265ed1c61a1e728caee735e5564d40.tar.gz chromium_src-d96ee58230265ed1c61a1e728caee735e5564d40.tar.bz2 |
Removed progress timer from DownloadItem
This timer is redundant - all state changes which need to be updated immediately
call UpdateObservers directly, and there is already a central timer in the
download file manager which updates progress.
Testing has been done manually to ensure the download shelf and the downloads UI
get updated properly when downloading items. Also unit testing has been added
for DownloadItem's public interface to check that state-changing functions
generate notifications.
BUG=None
TEST=See above.
Review URL: http://codereview.chromium.org/8463003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108947 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/download/download_item.cc | 24 | ||||
-rw-r--r-- | content/browser/download/download_item.h | 8 |
2 files changed, 0 insertions, 32 deletions
diff --git a/content/browser/download/download_item.cc b/content/browser/download/download_item.cc index 25e7ead..b993a6d 100644 --- a/content/browser/download/download_item.cc +++ b/content/browser/download/download_item.cc @@ -15,7 +15,6 @@ #include "base/logging.h" #include "base/metrics/histogram.h" #include "base/stringprintf.h" -#include "base/timer.h" #include "base/utf_string_conversions.h" #include "content/browser/download/download_create_info.h" #include "content/browser/download/download_file.h" @@ -52,9 +51,6 @@ using content::BrowserThread; namespace { -// Update frequency (milliseconds). -const int kUpdateTimeMs = 1000; - static void DeleteDownloadedFile(const FilePath& path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); @@ -334,22 +330,6 @@ void DownloadItem::UpdateSize(int64 bytes_so_far) { total_bytes_ = 0; } -void DownloadItem::StartProgressTimer() { - // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. - CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - - update_timer_.Start(FROM_HERE, - base::TimeDelta::FromMilliseconds(kUpdateTimeMs), this, - &DownloadItem::UpdateObservers); -} - -void DownloadItem::StopProgressTimer() { - // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. - CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - - update_timer_.Stop(); -} - // Updates from the download thread may have been posted while this download // was being cancelled in the UI thread, so we'll accept them unless we're // complete. @@ -384,7 +364,6 @@ void DownloadItem::Cancel(bool user_cancel) { download_stats::RecordDownloadCount(download_stats::CANCELLED_COUNT); TransitionTo(CANCELLED); - StopProgressTimer(); if (user_cancel) download_manager_->DownloadCancelledInternal(this); } @@ -410,7 +389,6 @@ void DownloadItem::OnAllDataSaved(int64 size) { DCHECK(!all_data_saved_); all_data_saved_ = true; UpdateSize(size); - StopProgressTimer(); } void DownloadItem::OnDownloadedFileRemoved() { @@ -481,7 +459,6 @@ void DownloadItem::Interrupted(int64 size, InterruptReason reason) { last_reason_ = reason; UpdateSize(size); - StopProgressTimer(); download_stats::RecordDownloadInterrupted(reason, received_bytes_, total_bytes_); @@ -743,7 +720,6 @@ void DownloadItem::Init(bool active) { UpdateTarget(); if (active) { - StartProgressTimer(); download_stats::RecordDownloadCount(download_stats::START_COUNT); } VLOG(20) << __FUNCTION__ << "() " << DebugString(true); diff --git a/content/browser/download/download_item.h b/content/browser/download/download_item.h index 24a367f..14f873a 100644 --- a/content/browser/download/download_item.h +++ b/content/browser/download/download_item.h @@ -25,7 +25,6 @@ #include "base/memory/scoped_ptr.h" #include "base/observer_list.h" #include "base/time.h" -#include "base/timer.h" #include "content/browser/download/download_id.h" #include "content/browser/download/download_request_handle.h" #include "content/browser/download/download_state_info.h" @@ -359,10 +358,6 @@ class CONTENT_EXPORT DownloadItem { // is completed. void Completed(); - // Start/stop sending periodic updates to our observers - void StartProgressTimer(); - void StopProgressTimer(); - // Call to transition state; all state transitions should go through this. void TransitionTo(DownloadState new_state); @@ -445,9 +440,6 @@ class CONTENT_EXPORT DownloadItem { // Our persistent store handle int64 db_handle_; - // Timer for regularly updating our observers - base::RepeatingTimer<DownloadItem> update_timer_; - // Our owning object DownloadManager* download_manager_; |