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

Unified Diff: base/message_loop/message_loop.cc

Issue 1232573002: Fix a "benign" data race during thread construction (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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/message_loop/message_loop.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop/message_loop.cc
diff --git a/base/message_loop/message_loop.cc b/base/message_loop/message_loop.cc
index 4fecbc5a60383ac5c5a6cd84b92edac99afa6223..d4f9c546b58ae3e3ceabcd7e6b723ab85de81502 100644
--- a/base/message_loop/message_loop.cc
+++ b/base/message_loop/message_loop.cc
@@ -407,7 +407,8 @@ void MessageLoop::BindToCurrentThread() {
incoming_task_queue_->StartScheduling();
unbound_task_runner_->BindToCurrentThread();
- SetTaskRunner(unbound_task_runner_.Pass());
+ unbound_task_runner_ = nullptr;
danakj 2015/07/10 18:32:38 I'm feeling like this unbound_task_runner_ is prov
Sami 2015/07/13 10:43:31 Yes, it's not all that useful but I can't think of
danakj 2015/07/13 18:33:47 Ah, I see. LGTM then.
+ SetThreadTaskRunnerHandle();
}
void MessageLoop::SetTaskRunner(
@@ -416,6 +417,11 @@ void MessageLoop::SetTaskRunner(
DCHECK(task_runner->BelongsToCurrentThread());
DCHECK(!unbound_task_runner_);
task_runner_ = task_runner.Pass();
+ SetThreadTaskRunnerHandle();
+}
+
+void MessageLoop::SetThreadTaskRunnerHandle() {
+ DCHECK_EQ(this, current());
// Clear the previous thread task runner first because only one can exist at
// a time.
thread_task_runner_handle_.reset();
« no previous file with comments | « base/message_loop/message_loop.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698