|
|
Created:
6 years, 9 months ago by Jeffrey Yasskin Modified:
6 years, 9 months ago CC:
chromium-reviews, michaeln, jsbell+serviceworker_chromium.org, tzik, serviceworker-reviews, nhiroki, joi+watch-content_chromium.org, darin-cc_chromium.org, horo+watch_chromium.org, kinuko+watch, alecflett+watch_chromium.org, scheib Base URL:
svn://svn.chromium.org/chrome/trunk/src Visibility:
Public. |
DescriptionAdd a DCHECK_CURRENTLY_ON(BrowserThread::ID) macro.
I've often lost time when a DCHECK(BrowserThread::CurrentlyOn(id)) fails,
because I needed to re-run the program in gdb to figure out which thread was
actually running the function. This new wrapper macro should make that clearer.
I've converted one file in service_worker to make sure everything works.
It changes:
[...:FATAL:service_worker_context_core.cc(75)] Check failed: BrowserThread::CurrentlyOn(BrowserThread::IO).
into
[...:FATAL:service_worker_context_core.cc(75)] Check failed: ::content::BrowserThread::CurrentlyOn(BrowserThread::IO). Must be called on Chrome_IOThread; actually called on Chrome_UIThread.
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=256913
Patch Set 1 #Patch Set 2 : Use a macro instead of a function #Patch Set 3 : Use MessageLoop::thread_name when possible, and g_browser_thread_names otherwise #
Total comments: 2
Patch Set 4 : Fix Jói's nit #
Messages
Total messages: 25 (0 generated)
Also note that I do still get the usual stack trace including the function containing the call: [...:FATAL:browser_thread.h(281)] Check failed: CurrentlyOn(identifier). Must be called on IO thread; actually called on UI thread. [0x7f46ef8f319e] base::debug::StackTrace::StackTrace() [0x7f46ef975f55] logging::LogMessage::~LogMessage() [0x7f46e67336b6] content::BrowserThread::DCheckCurrentlyOn() [0x7f46e6732250] content::ServiceWorkerContextCore::RegisterServiceWorker() [0x000000af929f] content::ServiceWorkerContextTest_Register_Test::TestBody() [0x000001175673] testing::internal::HandleSehExceptionsInMethodIfSupported<>() [0x00000116297e] testing::internal::HandleExceptionsInMethodIfSupported<>() [0x000001158fb5] testing::Test::Run() ... this might not be present for every time the DCHECK is hit, but it should be present for most developers, afaik.
I'd suggest a macro to preserve the functionality that logs show the right file and line number. I'd also suggest following up with a change where you try to replace as many as possible of the existing invocations of DCHECK(BrowserThread::CurrentlyOn(...)) with this. Other than that, this looks like a good idea.
On 2014/03/10 13:54:09, Jói wrote: > I'd suggest a macro to preserve the functionality that logs show the right file > and line number. > > I'd also suggest following up with a change where you try to replace as many as > possible of the existing invocations of DCHECK(BrowserThread::CurrentlyOn(...)) > with this. +1, if we add this, please convert all the existing instances so that there are no other examples to use. of course, over many changes to make it easy for you (also you can tbr all of them) > > Other than that, this looks like a good idea.
'k. Would DCHECK_CURRENTLY_ON(BrowserThread::IO) be a good spelling? On Mon, Mar 10, 2014 at 6:54 AM, <joi@chromium.org> wrote: > I'd suggest a macro to preserve the functionality that logs show the right > file > and line number. > > I'd also suggest following up with a change where you try to replace as many > as > possible of the existing invocations of > DCHECK(BrowserThread::CurrentlyOn(...)) > with this. > > Other than that, this looks like a good idea. > > https://codereview.chromium.org/191763002/ To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
Since it's a macro, and this will only ever deal with BrowserThread IDs, I would suggest just DCHECK_CURRENTLY_ON(IO). On Mon, Mar 10, 2014 at 5:15 PM, Jeffrey Yasskin <jyasskin@chromium.org> wrote: > 'k. Would DCHECK_CURRENTLY_ON(BrowserThread::IO) be a good spelling? > > On Mon, Mar 10, 2014 at 6:54 AM, <joi@chromium.org> wrote: >> I'd suggest a macro to preserve the functionality that logs show the right >> file >> and line number. >> >> I'd also suggest following up with a change where you try to replace as many >> as >> possible of the existing invocations of >> DCHECK(BrowserThread::CurrentlyOn(...)) >> with this. >> >> Other than that, this looks like a good idea. >> >> https://codereview.chromium.org/191763002/ To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
That's certainly implementable, but I'm worried that it'll be harder to read because it doesn't mention threads at all. I was actually wondering if I should use DCHECK_CURRENTLY_ON_BROWSER_THREAD(IO) to avoid colliding with any macros in codebases using content/. But now that I've mentioned those concerns, I'm happy to update the CL to whichever spelling you prefer. On Mon, Mar 10, 2014 at 10:16 AM, Jói Sigurðsson <joi@chromium.org> wrote: > Since it's a macro, and this will only ever deal with BrowserThread > IDs, I would suggest just DCHECK_CURRENTLY_ON(IO). > > On Mon, Mar 10, 2014 at 5:15 PM, Jeffrey Yasskin <jyasskin@chromium.org> wrote: >> 'k. Would DCHECK_CURRENTLY_ON(BrowserThread::IO) be a good spelling? >> >> On Mon, Mar 10, 2014 at 6:54 AM, <joi@chromium.org> wrote: >>> I'd suggest a macro to preserve the functionality that logs show the right >>> file >>> and line number. >>> >>> I'd also suggest following up with a change where you try to replace as many >>> as >>> possible of the existing invocations of >>> DCHECK(BrowserThread::CurrentlyOn(...)) >>> with this. >>> >>> Other than that, this looks like a good idea. >>> >>> https://codereview.chromium.org/191763002/ To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
I'm fine with your original proposal DCHECK_CURRENTLY_ON(BrowserThread::IO) On Mon, Mar 10, 2014 at 5:21 PM, Jeffrey Yasskin <jyasskin@chromium.org> wrote: > That's certainly implementable, but I'm worried that it'll be harder > to read because it doesn't mention threads at all. I was actually > wondering if I should use DCHECK_CURRENTLY_ON_BROWSER_THREAD(IO) to > avoid colliding with any macros in codebases using content/. But now > that I've mentioned those concerns, I'm happy to update the CL to > whichever spelling you prefer. > > On Mon, Mar 10, 2014 at 10:16 AM, Jói Sigurðsson <joi@chromium.org> wrote: >> Since it's a macro, and this will only ever deal with BrowserThread >> IDs, I would suggest just DCHECK_CURRENTLY_ON(IO). >> >> On Mon, Mar 10, 2014 at 5:15 PM, Jeffrey Yasskin <jyasskin@chromium.org> wrote: >>> 'k. Would DCHECK_CURRENTLY_ON(BrowserThread::IO) be a good spelling? >>> >>> On Mon, Mar 10, 2014 at 6:54 AM, <joi@chromium.org> wrote: >>>> I'd suggest a macro to preserve the functionality that logs show the right >>>> file >>>> and line number. >>>> >>>> I'd also suggest following up with a change where you try to replace as many >>>> as >>>> possible of the existing invocations of >>>> DCHECK(BrowserThread::CurrentlyOn(...)) >>>> with this. >>>> >>>> Other than that, this looks like a good idea. >>>> >>>> https://codereview.chromium.org/191763002/ To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
Ok, switched to a macro. PTAL. I'll send a bunch of update CLs once this looks stable, as requested.
LGTM
Sorry for the extra round-trip: Vince noticed that I could use base::MessageLoop::current()->thread_name() to get better messages for some non-browser threads. That doesn't work in the test I tried where the thread is named "", but it also led me to notice g_browser_thread_names which has names for the non-UI threads, which let me shorten GetThreadName considerably.
LGTM w/a nit. https://codereview.chromium.org/191763002/diff/40001/content/public/browser/b... File content/public/browser/browser_thread.h (right): https://codereview.chromium.org/191763002/diff/40001/content/public/browser/b... content/public/browser/browser_thread.h:276: #define DCHECK_CURRENTLY_ON(thread_identifier) \ nit: This would be more discoverable if placed at the top of this header. A sentence of documentation would also help.
https://codereview.chromium.org/191763002/diff/40001/content/public/browser/b... File content/public/browser/browser_thread.h (right): https://codereview.chromium.org/191763002/diff/40001/content/public/browser/b... content/public/browser/browser_thread.h:276: #define DCHECK_CURRENTLY_ON(thread_identifier) \ On 2014/03/11 08:41:25, Jói wrote: > nit: This would be more discoverable if placed at the top of this header. A > sentence of documentation would also help. SG. Done, thanks.
lgtm for service_worker
The CQ bit was checked by jyasskin@chromium.org
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jyasskin@chromium.org/191763002/50001
The CQ bit was unchecked by commit-bot@chromium.org
Retried try job too often on chromium_presubmit for step(s) presubmit http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=chromium_p...
+sky for content/browser: sorry for leaving you off before
You have John on this review, and he knows the code better than I, so I'm removing myself.
OK, then John, can I get an lgtm from you? On Mar 11, 2014 7:32 PM, <sky@chromium.org> wrote: > You have John on this review, and he knows the code better than I, so I'm > removing myself. > > https://codereview.chromium.org/191763002/ > To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
lgtm
The CQ bit was checked by jyasskin@chromium.org
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jyasskin@chromium.org/191763002/50001
Message was sent while issue was closed.
Change committed as 256913 |