Commit fa5e7f0d authored by Gabriel Charette's avatar Gabriel Charette Committed by Commit Bot

Add a developer hint to an otherwise cryptic error when accidently registering...

Add a developer hint to an otherwise cryptic error when accidently registering a second RunLoop::Delegate on a thread.

While Runloop::Delegate isn't aware of MessageLoop/ScopedTaskEnvironment:
I find useful to add developer hints about the typical developer mistake
a DCHECK catches. This avoids multiple developers wasting time figuring
out the same thing. Started doing this in a few places in //base and this
is another instance recently surfaced by chrisha @
https://groups.google.com/a/google.com/d/topic/lucky-luke-dev/9_eZ6pnvo7Y/discussion

R=chrisha@chromium.org

Bug: Cryptic error when creating a ScopedTaskEnvironment over an
existing MessageLoop.

Change-Id: I427e0400b2a2b91ab9b175fa2427014bc8fc4406
Reviewed-on: https://chromium-review.googlesource.com/890174
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532402}
parent 92ffe77a
...@@ -63,7 +63,10 @@ void RunLoop::RegisterDelegateForCurrentThread(Delegate* delegate) { ...@@ -63,7 +63,10 @@ void RunLoop::RegisterDelegateForCurrentThread(Delegate* delegate) {
DCHECK_CALLED_ON_VALID_THREAD(delegate->bound_thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(delegate->bound_thread_checker_);
// There can only be one RunLoop::Delegate per thread. // There can only be one RunLoop::Delegate per thread.
DCHECK(!tls_delegate.Get().Get()); DCHECK(!tls_delegate.Get().Get())
<< "Error: Multiple RunLoop::Delegates registered on the same thread.\n\n"
"Hint: You perhaps instantiated a second "
"MessageLoop/ScopedTaskEnvironment on a thread that already had one?";
tls_delegate.Get().Set(delegate); tls_delegate.Get().Set(delegate);
delegate->bound_ = true; delegate->bound_ = true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment