Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(987)

Unified Diff: base/timer/timer.cc

Issue 2916693002: DetachFromSequence in Timer::Stop() (Closed)
Patch Set: comment nit Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/timer/timer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/timer/timer.cc
diff --git a/base/timer/timer.cc b/base/timer/timer.cc
index abcd70aefa1c31212945b01867e6c039c27a3b9e..1f6efcc7e3db704b60f2740f36e92b277734f1fd 100644
--- a/base/timer/timer.cc
+++ b/base/timer/timer.cc
@@ -99,8 +99,7 @@ Timer::Timer(const tracked_objects::Location& posted_from,
}
Timer::~Timer() {
- // TODO(gab): Enable this once Stop() properly detaches from sequence.
- // DCHECK(origin_sequence_checker_.CalledOnValidSequence());
+ DCHECK(origin_sequence_checker_.CalledOnValidSequence());
AbandonAndStop();
}
@@ -144,6 +143,10 @@ void Timer::Stop() {
// DCHECK(origin_sequence_checker_.CalledOnValidSequence());
is_running_ = false;
+
+ // It's safe to destroy or restart Timer on another sequence after Stop().
+ origin_sequence_checker_.DetachFromSequence();
+
if (!retain_user_task_)
user_task_.Reset();
// No more member accesses here: |this| could be deleted after freeing
« no previous file with comments | « base/timer/timer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698