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

Unified Diff: base/timer/timer.cc

Issue 2916693002: DetachFromSequence in Timer::Stop() (Closed)
Patch Set: Created 3 years, 7 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
« base/timer/timer.h ('K') | « 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().
danakj 2017/06/06 20:07:12 Did you intentionally do this before running the u
gab 2017/06/07 13:28:54 Yes, see comment at the end of this method, it's n
+ origin_sequence_checker_.DetachFromSequence();
+
if (!retain_user_task_)
user_task_.Reset();
// No more member accesses here: |this| could be deleted after freeing
« base/timer/timer.h ('K') | « base/timer/timer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698