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

Unified Diff: base/threading/thread.cc

Issue 2337253003: Add FlushForTesting to base::Thread. (Closed)
Patch Set: Created 4 years, 3 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/threading/thread.h ('k') | base/threading/thread_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/thread.cc
diff --git a/base/threading/thread.cc b/base/threading/thread.cc
index 6181ba66918304d713d79dcbc3e0970276e9ea07..761bc871885ede525866ca4a6c3e6226cb0e3005 100644
--- a/base/threading/thread.cc
+++ b/base/threading/thread.cc
@@ -144,6 +144,18 @@ bool Thread::WaitUntilThreadStarted() const {
return true;
}
+void Thread::FlushForTesting() {
danakj 2016/09/15 18:09:33 I'd prefer a free function in base/test/ actually.
gab 2016/09/15 20:18:33 Maybe discoverability is a reason? i.e. I just rea
+ DCHECK(owning_sequence_checker_.CalledOnValidSequence());
+ if (!message_loop_)
+ return;
+
+ WaitableEvent done(WaitableEvent::ResetPolicy::AUTOMATIC,
+ WaitableEvent::InitialState::NOT_SIGNALED);
+ task_runner()->PostTask(FROM_HERE,
+ Bind(&WaitableEvent::Signal, Unretained(&done)));
+ done.Wait();
+}
+
void Thread::Stop() {
DCHECK(joinable_);
« no previous file with comments | « base/threading/thread.h ('k') | base/threading/thread_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698