summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-02 06:02:18 +0000
committernsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-02 06:02:18 +0000
commitaa9be60bf5ddd299ea216b958097fc550242c013 (patch)
tree556e2b25b897baf31eb457a3634b369086ac5b38
parent2a94d560f4b0e2e8e99c8c98a0695820a08309af (diff)
downloadchromium_src-aa9be60bf5ddd299ea216b958097fc550242c013.zip
chromium_src-aa9be60bf5ddd299ea216b958097fc550242c013.tar.gz
chromium_src-aa9be60bf5ddd299ea216b958097fc550242c013.tar.bz2
Revert 6190 to see if it's the cause of the 100+ new regressions
on the distributed tests. TBR Review URL: http://codereview.chromium.org/13042 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6205 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/timer.h33
-rw-r--r--base/timer_unittest.cc21
2 files changed, 6 insertions, 48 deletions
diff --git a/base/timer.h b/base/timer.h
index f449d2a..5361130 100644
--- a/base/timer.h
+++ b/base/timer.h
@@ -135,42 +135,21 @@ class BaseTimer : public BaseTimer_Helper {
receiver_(receiver),
method_(method) {
}
-
- virtual ~TimerTask() {
- ClearBaseTimer();
- }
-
virtual void Run() {
if (!timer_) // timer_ is null if we were orphaned.
return;
- if (kIsRepeating)
- ResetBaseTimer();
- else
- ClearBaseTimer();
+ SelfType* self = static_cast<SelfType*>(timer_);
+ if (kIsRepeating) {
+ self->Reset();
+ } else {
+ self->delayed_task_ = NULL;
+ }
DispatchToMethod(receiver_, method_, Tuple0());
}
-
TimerTask* Clone() const {
return new TimerTask(delay_, receiver_, method_);
}
-
private:
- // Inform the Base that the timer is no longer active.
- void ClearBaseTimer() {
- if (timer_) {
- SelfType* self = static_cast<SelfType*>(timer_);
- self->delayed_task_ = NULL;
- }
- }
-
- // Inform the Base that we're resetting the timer.
- void ResetBaseTimer() {
- DCHECK(timer_);
- DCHECK(kIsRepeating);
- SelfType* self = static_cast<SelfType*>(timer_);
- self->Reset();
- }
-
Receiver* receiver_;
ReceiverMethod method_;
};
diff --git a/base/timer_unittest.cc b/base/timer_unittest.cc
index 1fb44a3..face9c8 100644
--- a/base/timer_unittest.cc
+++ b/base/timer_unittest.cc
@@ -145,24 +145,3 @@ TEST(TimerTest, RepeatingTimer_Cancel) {
RunTest_RepeatingTimer_Cancel(MessageLoop::TYPE_UI);
RunTest_RepeatingTimer_Cancel(MessageLoop::TYPE_IO);
}
-
-TEST(TimerTest, MessageLoopShutdown) {
- // This test is designed to verify that shutdown of the
- // message loop does not cause crashes if there were pending
- // timers not yet fired. It may only trigger exceptions
- // if debug heap checking (or purify) is enabled.
- bool did_run = false;
- {
- OneShotTimerTester a(&did_run);
- OneShotTimerTester b(&did_run);
- OneShotTimerTester c(&did_run);
- OneShotTimerTester d(&did_run);
- {
- MessageLoop loop(MessageLoop::TYPE_DEFAULT);
- a.Start();
- b.Start();
- } // MessageLoop destructs by falling out of scope.
- } // OneShotTimers destruct. SHOULD NOT CRASH, of course.
-
- EXPECT_EQ(false, did_run);
-}