diff options
author | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-03 18:18:14 +0000 |
---|---|---|
committer | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-03 18:18:14 +0000 |
commit | 2d31666a58e746b7a1d415c99e5f68ad9256d236 (patch) | |
tree | 144c99d4b80df0f0f9a3ded83f9d21a8b36f17cc /chrome/browser/views | |
parent | 90d6958fe2374a00d3c8583cf4d3b8a509ae8e90 (diff) | |
download | chromium_src-2d31666a58e746b7a1d415c99e5f68ad9256d236.zip chromium_src-2d31666a58e746b7a1d415c99e5f68ad9256d236.tar.gz chromium_src-2d31666a58e746b7a1d415c99e5f68ad9256d236.tar.bz2 |
Minor cleanup to OneShotTimer and RepeatingTimer: moves more of the member variables into the Task subclass.
Also included in this change: deprecate MessageLoop::timer_manager(), and change consumers over to use OneShotTimer or RepeatingTimer.
R=beng
BUG=1346553
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1684 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/constrained_window_impl.cc | 29 | ||||
-rw-r--r-- | chrome/browser/views/download_item_view.cc | 21 | ||||
-rw-r--r-- | chrome/browser/views/download_item_view.h | 6 |
3 files changed, 15 insertions, 41 deletions
diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc index 8c66ad3..86f5677 100644 --- a/chrome/browser/views/constrained_window_impl.cc +++ b/chrome/browser/views/constrained_window_impl.cc @@ -208,8 +208,7 @@ ChromeFont OTRWindowResources::title_font_; class ConstrainedWindowNonClientView : public ChromeViews::NonClientView, public ChromeViews::BaseButton::ButtonListener, - public LocationBarView::Delegate, - public Task { + public LocationBarView::Delegate { public: ConstrainedWindowNonClientView(ConstrainedWindowImpl* container, TabContents* owner); @@ -256,9 +255,6 @@ class ConstrainedWindowNonClientView virtual TabContents* GetTabContents(); virtual void OnInputInProgress(bool in_progress); - // Overridden from Task: - virtual void Run(); - // Updates the current throbber animation frame; called from the // overloaded Run() and from SetShowThrobber(). void UpdateThrobber(); @@ -319,7 +315,7 @@ class ConstrainedWindowNonClientView bool show_throbber_; // The timer used to update frames for the throbber. - scoped_ptr<Timer> throbber_animation_timer_; + base::RepeatingTimer<ConstrainedWindowNonClientView> throbber_timer_; // The current index into the throbber image strip. int current_throbber_frame_; @@ -395,9 +391,6 @@ ConstrainedWindowNonClientView::ConstrainedWindowNonClientView( close_button_->SetListener(this, 0); AddChildView(close_button_); - throbber_animation_timer_.reset( - new Timer(kThrobberFrameTimeMs, this, true)); - // Note: we don't need for a controller because no input event will be ever // processed from a constrained window. location_bar_ = new LocationBarView(owner->profile(), @@ -409,8 +402,6 @@ ConstrainedWindowNonClientView::ConstrainedWindowNonClientView( } ConstrainedWindowNonClientView::~ConstrainedWindowNonClientView() { - MessageLoop::current()->timer_manager()->StopTimer( - throbber_animation_timer_.get()); } void ConstrainedWindowNonClientView::UpdateLocationBar() { @@ -483,25 +474,21 @@ void ConstrainedWindowNonClientView::UpdateWindowTitle() { void ConstrainedWindowNonClientView::SetShowThrobber(bool show_throbber) { show_throbber_ = show_throbber; - TimerManager* tm = MessageLoop::current()->timer_manager(); - Timer* timer = throbber_animation_timer_.get(); if (show_throbber) { - if (!tm->IsTimerRunning(timer)) - tm->ResetTimer(timer); + if (!throbber_timer_.IsRunning()) + throbber_timer_.Start( + TimeDelta::FromMilliseconds(kThrobberFrameTimeMs), this, + &ConstrainedWindowNonClientView::UpdateThrobber); } else { - if (tm->IsTimerRunning(timer)) { + if (throbber_timer_.IsRunning()) { + throbber_timer_.Stop(); UpdateThrobber(); - tm->StopTimer(timer); } } Layout(); } -void ConstrainedWindowNonClientView::Run() { - UpdateThrobber(); -} - //////////////////////////////////////////////////////////////////////////////// // ConstrainedWindowNonClientView, ChromeViews::NonClientView implementation: diff --git a/chrome/browser/views/download_item_view.cc b/chrome/browser/views/download_item_view.cc index 923752e..bde72f2 100644 --- a/chrome/browser/views/download_item_view.cc +++ b/chrome/browser/views/download_item_view.cc @@ -46,8 +46,6 @@ DownloadItemView::DownloadItemView(DownloadItem* download, parent_(parent), model_(model), progress_angle_(download_util::kStartAngleDegrees), - progress_timer_(NULL), - progress_task_(NULL), body_state_(NORMAL), drop_down_state_(NORMAL), drop_down_pressed_(false), @@ -175,24 +173,15 @@ void DownloadItemView::UpdateDownloadProgress() { } void DownloadItemView::StartDownloadProgress() { - if (progress_task_ || progress_timer_) + if (progress_timer_.IsRunning()) return; - progress_task_ = - new download_util::DownloadProgressTask<DownloadItemView>(this); - progress_timer_ = - MessageLoop::current()->timer_manager()-> - StartTimer(download_util::kProgressRateMs, progress_task_, true); + progress_timer_.Start( + TimeDelta::FromMilliseconds(download_util::kProgressRateMs), this, + &DownloadItemView::UpdateDownloadProgress); } void DownloadItemView::StopDownloadProgress() { - if (progress_timer_) { - DCHECK(progress_task_); - MessageLoop::current()->timer_manager()->StopTimer(progress_timer_); - delete progress_timer_; - progress_timer_ = NULL; - delete progress_task_; - progress_task_ = NULL; - } + progress_timer_.Stop(); } // DownloadObserver interface diff --git a/chrome/browser/views/download_item_view.h b/chrome/browser/views/download_item_view.h index 619c5ea..ab42fd5 100644 --- a/chrome/browser/views/download_item_view.h +++ b/chrome/browser/views/download_item_view.h @@ -20,6 +20,7 @@ #include "base/basictypes.h" #include "base/scoped_ptr.h" +#include "base/timer.h" #include "chrome/common/slide_animation.h" #include "chrome/browser/cancelable_request.h" #include "chrome/browser/download_manager.h" @@ -30,8 +31,6 @@ class DownloadShelfView; class SkBitmap; -class Task; -class Timer; class DownloadItemView : public ChromeViews::View, public DownloadItem::Observer, @@ -188,8 +187,7 @@ class DownloadItemView : public ChromeViews::View, scoped_ptr<SlideAnimation> complete_animation_; // Progress animation - Timer* progress_timer_; - Task* progress_task_; + base::RepeatingTimer<DownloadItemView> progress_timer_; DISALLOW_EVIL_CONSTRUCTORS(DownloadItemView); }; |