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/tabs | |
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/tabs')
-rw-r--r-- | chrome/browser/tabs/tab_strip.cc | 30 | ||||
-rw-r--r-- | chrome/browser/tabs/tab_strip.h | 8 |
2 files changed, 7 insertions, 31 deletions
diff --git a/chrome/browser/tabs/tab_strip.cc b/chrome/browser/tabs/tab_strip.cc index d38be5a..03f6c2e 100644 --- a/chrome/browser/tabs/tab_strip.cc +++ b/chrome/browser/tabs/tab_strip.cc @@ -462,10 +462,6 @@ TabStrip::~TabStrip() { // TODO(beng): remove this if it doesn't work to fix the TabSelectedAt bug. drag_controller_.reset(NULL); - // Stop any existing Loading Animation timer. - MessageLoop::current()->timer_manager()->StopTimer( - loading_animation_timer_.get()); - // Make sure we unhook ourselves as a message loop observer so that we don't // crash in the case where the user closes the window after closing a tab // but before moving the mouse. @@ -849,18 +845,18 @@ void TabStrip::TabChangedAt(TabContents* contents, int index) { } void TabStrip::TabValidateAnimations() { - TimerManager* tm = MessageLoop::current()->timer_manager(); - Timer* timer = loading_animation_timer_.get(); if (model_->TabsAreLoading()) { - if (!tm->IsTimerRunning(timer)) { + if (!loading_animation_timer_.IsRunning()) { // Loads are happening, and the timer isn't running, so start it. - tm->ResetTimer(timer); + loading_animation_timer_.Start( + TimeDelta::FromMilliseconds(kLoadingAnimationFrameTimeMs), this, + &TabStrip::LoadingAnimationCallback); } } else { - if (tm->IsTimerRunning(timer)) { + if (loading_animation_timer_.IsRunning()) { + loading_animation_timer_.Stop(); // Loads are now complete, update the state if a task was scheduled. LoadingAnimationCallback(); - tm->StopTimer(timer); } } } @@ -1000,15 +996,6 @@ void TabStrip::ButtonPressed(ChromeViews::BaseButton* sender) { } /////////////////////////////////////////////////////////////////////////////// -// TabStrip, Task implementation: - -void TabStrip::Run() { - // Loading Animation frame advancement timer has fired, update all of the - // loading animations as applicable... - LoadingAnimationCallback(); -} - -/////////////////////////////////////////////////////////////////////////////// // TabStrip, MessageLoop::Observer implementation: void TabStrip::WillProcessMessage(const MSG& msg) { @@ -1085,11 +1072,6 @@ void TabStrip::Init() { newtab_button_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_NEWTAB)); AddChildView(newtab_button_); - // Creating the Timer directly instead of using StartTimer() ensures it won't - // actually start running until we use ResetTimer(); - loading_animation_timer_.reset( - new Timer(kLoadingAnimationFrameTimeMs, this, true)); - if (drop_indicator_width == 0) { // Direction doesn't matter, both images are the same size. SkBitmap* drop_image = GetDropArrowImage(true); diff --git a/chrome/browser/tabs/tab_strip.h b/chrome/browser/tabs/tab_strip.h index 9d2ed08..11f6f64 100644 --- a/chrome/browser/tabs/tab_strip.h +++ b/chrome/browser/tabs/tab_strip.h @@ -6,7 +6,6 @@ #define CHROME_BROWSER_TABS_TAB_STRIP_H__ #include "base/gfx/point.h" -#include "base/task.h" #include "chrome/browser/tabs/tab.h" #include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/views/button.h" @@ -17,7 +16,6 @@ class DraggedTabController; class ScopedMouseCloseWidthCalculator; class TabStripModel; -class Timer; namespace ChromeViews { class ImageView; @@ -40,7 +38,6 @@ class TabStrip : public ChromeViews::View, public TabStripModelObserver, public Tab::TabDelegate, public ChromeViews::Button::ButtonListener, - public Task, public MessageLoopForUI::Observer { public: TabStrip(TabStripModel* model); @@ -153,9 +150,6 @@ class TabStrip : public ChromeViews::View, // ChromeViews::Button::ButtonListener implementation: virtual void ButtonPressed(ChromeViews::BaseButton* sender); - // Task implementation: - virtual void Run(); - // MessageLoop::Observer implementation: virtual void WillProcessMessage(const MSG& msg); virtual void DidProcessMessage(const MSG& msg); @@ -303,7 +297,7 @@ class TabStrip : public ChromeViews::View, bool resize_layout_scheduled_; // The timer used to update frames for the Loading Animation. - scoped_ptr<Timer> loading_animation_timer_; + base::RepeatingTimer<TabStrip> loading_animation_timer_; // The "New Tab" button. ChromeViews::Button* newtab_button_; |