summaryrefslogtreecommitdiffstats
path: root/base/timer_unittest.cc
Commit message (Collapse)AuthorAgeFilesLines
* Redo fix from yesterday.mbelshe@google.com2008-12-021-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Post Mortem on why yesterday's fix was bogus: The motivation for this change was because a separate CL had a OneShotTimer<> as part of a Singleton class. The Singleton is cleaned up in the AtExit manager, which currently runs after the MessageLoop is destroyed. The following sequence left a dangling pointer: 1) Start a OneShotTimer - Creates a task and registers on the MessageLoop 2) Destroy MessageLoop (this deletes all Pending Tasks) 3) Destroy your OneShotTimer - Tries to reference a dangling pointer for the already-deleted task. The fix was to modify the Task such that at destruction it would zero-out the wrapper's pointer to the Task. Now step 3 would not reference a bogus pointer. Unfortunately, the fix is broken. The timers work by having a wrapper Timer class (BaseTimer_Helper) and a Task. The Task has a pointer back to its wrapper and the wrapper has a pointer to the task. For the case where a timer is re-started from within its Run() loop, things fail: 1) Start a RepeatingTimer 2) Timer fires via the MessageLoop MessageLoop calls Run() 3) Run() restarts the timer, which creates a new Task but reuses the same BaseTimer_Helper. BaseTimer_Helper's timer pointer now points to the NEW timer 4) The MessageLoop destroys the Task The new code zeroes out the task pointer in the BaseTimer_Helper, breaking the newly restarted timer. This fix is the same as yesterday's fix, except: 1) More comments 2) Added extra check at line 169. Don't reset the Task pointer when destroying the Task if the Timer does not point to the Task being destroyed. I'm confident, but not 100% positive that this fixes the problem. I did reproduce *something* using PageHeap which now seems to be gone, but I can't quite confirm. Review URL: http://codereview.chromium.org/13067 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6251 0039d316-1c4b-4281-b951-d872f2087c98
* Revert the timer code again because even after relandingnsylvain@chromium.org2008-12-021-21/+0
| | | | | | | | | it on a clean and clobbered tree, it caused all the failures Review URL: http://codereview.chromium.org/12870 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6220 0039d316-1c4b-4281-b951-d872f2087c98
* Reland 6190 now that the tree is green to see ifnsylvain@chromium.org2008-12-021-0/+21
| | | | | | | it's still breaking the tests Review URL: http://codereview.chromium.org/12868 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6218 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 6190 to see if it's the cause of the 100+ new regressionsnsylvain@chromium.org2008-12-021-21/+0
| | | | | | | | | 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
* Found a bug in the BaseTimer (used by OneShotTimer).mbelshe@google.com2008-12-021-0/+21
| | | | | | | | | | | | | | | | | | | | | If you have a OneShotTimer pending, and you destroy your message loop, the cleanup of the timer will use memory which was already freed by the MessageLoop. When the MessageLoop shuts down, it deletes pending tasks. BaseTimer did not provide a virtual destructor to cleanup its "base". Thus, when the actual OneShotTimer cleaned up, it would use deleted memory. This manifested for me when I had accidentally had cleanup of a oneshottimer occurring through the Singleton, which occurs AtExit, after the messageloop is already gone. Created a unit test for this, which does trip the assert due to heap corruption. Review URL: http://codereview.chromium.org/13023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6190 0039d316-1c4b-4281-b951-d872f2087c98
* Move Time, TimeDelta and TimeTicks into namespace base.dsh@google.com2008-10-271-0/+2
| | | | | | Review URL: http://codereview.chromium.org/7995 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4022 0039d316-1c4b-4281-b951-d872f2087c98
* Eliminate the TimerManager by pulling its priority queue into MessageLoop. ↵darin@google.com2008-09-071-356/+0
| | | | | | | | | | This CL also eliminates TaskBase by creating a simple PendingTask struct that is allocated inline within a std::queue used to implement the queues in the MessageLoop class. R=jar Review URL: http://codereview.chromium.org/483 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1825 0039d316-1c4b-4281-b951-d872f2087c98
* Revert r1648 in timer_unittest.cc, this was for testing and should have nevermmentovai@google.com2008-09-041-24/+0
| | | | | | | escaped my working copy. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1712 0039d316-1c4b-4281-b951-d872f2087c98
* Minor cleanup to OneShotTimer and RepeatingTimer: moves more of the member ↵darin@google.com2008-09-031-5/+6
| | | | | | | | | | | 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
* Set svn:eol-style = LF on files in base from which it is missingmmentovai@google.com2008-09-021-0/+24
| | | | git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1648 0039d316-1c4b-4281-b951-d872f2087c98
* Simplify OneShotTimer and RepeatingTimer. Fix up all consumers.darin@google.com2008-08-281-0/+135
| | | | | | | | | | | | | | | | | | | | | | | | Major changes: OneShotTimer and RepeatingTimer become template classes that no longer require a Task or a Timer object. They just use PostDelayedTask. Under the hood that still uses a Timer object. The API is much simpler for consumers as they now no longer need to worry about allocating a Task or managing the lifetime of the object pointer held by the Task. I added some new unit tests to timer_unittest.cc to cover the API. I preserved the old TimerManager / Timer API for now, but I plan to soon kill it. R=brettw BUG=1346553 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1502 0039d316-1c4b-4281-b951-d872f2087c98
* fix broken test that assumed it could cache MessageLoop::current() in a ↵darin@google.com2008-08-261-2/+1
| | | | | | static variable git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1369 0039d316-1c4b-4281-b951-d872f2087c98
* Allow consumers of MessageLoop to specify the type of MessageLoop they want.darin@google.com2008-08-261-9/+64
| | | | | | | | | | | | | | | | This CL introduces a Type enum to MessageLoop, and I also created subclasses of MessageLoop corresponding to the non-default types: MessageLoopForIO and MessageLoopForUI. I moved all of the platform-specific MessageLoop APIs onto either MessageLoopForIO or MessageLoopForUI. MessageLoopForIO gets the Watcher API, and MessageLoopForUI gets the Observer and Dispatcher APIs. Under the hood, both are implemented in terms of MessagePumpWin, but that will change in a future CL. The Thread class is changed to allow the consumer to specify the Type of MessageLoop they want to have setup on the created thread. I re-organized message_loop_unittest.cc and timer_unittest.cc so that I could exercise all (or most) of the tests against each type of MessageLoop. Note: I know that "explicit MessageLoop(Type type = TYPE_DEFAULT);" is in violation to the style-guide's restriction against default arguments. I'm working on finding a decent solution to that problem. Please ignore this issue for now. The corresponding chrome/ changes are coming in a separate CL due to Reitveld data size limitations. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1362 0039d316-1c4b-4281-b951-d872f2087c98
* Use a more compact license header in source files.license.bot2008-08-241-28/+4
| | | | git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1287 0039d316-1c4b-4281-b951-d872f2087c98
* Enable -Werror on the Mac. Fix two more warnings just added to our build. ↵mmentovai@google.com2008-08-221-3/+3
| | | | | | Note that the targets for libskia and libicuuc still exclude themselves from -Werror. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1205 0039d316-1c4b-4281-b951-d872f2087c98
* Add a trailing EOL to source files. This eliminates warnings in GCC.deanm@google.com2008-08-141-1/+1
| | | | | | No code change. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@865 0039d316-1c4b-4281-b951-d872f2087c98
* git-svn-id: svn://svn.chromium.org/chrome/trunk/src@760 ↵darin@google.com2008-08-121-0/+3
| | | | 0039d316-1c4b-4281-b951-d872f2087c98
* git-svn-id: svn://svn.chromium.org/chrome/trunk/src@739 ↵darin@google.com2008-08-121-3/+0
| | | | 0039d316-1c4b-4281-b951-d872f2087c98
* Make timer.cc portable by factoring its Windows bits into MessageLoop.darin@google.com2008-08-121-0/+3
| | | | | | Please note that the goal of this CL is merely to move the Windowisms out of timer.cc and into message_loop.cc. Next up will be to refactor message_loop.cc so that the Windowisms are further isolated. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@734 0039d316-1c4b-4281-b951-d872f2087c98
* Add base to the repository.initial.commit2008-07-261-0/+332
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8 0039d316-1c4b-4281-b951-d872f2087c98