Chromium Code Reviews| Index: content/public/browser/browser_thread.h |
| diff --git a/content/public/browser/browser_thread.h b/content/public/browser/browser_thread.h |
| index 55cb62b22355d339822414f06874d2bd2695590f..47d3c1d90a7597693c506bb5bbfe542f7d795558 100644 |
| --- a/content/public/browser/browser_thread.h |
| +++ b/content/public/browser/browser_thread.h |
| @@ -10,15 +10,12 @@ |
| #include "base/basictypes.h" |
| #include "base/callback.h" |
| #include "base/location.h" |
| +#include "base/logging.h" |
| #include "base/message_loop/message_loop_proxy.h" |
| #include "base/task_runner_util.h" |
| #include "base/time/time.h" |
| #include "content/common/content_export.h" |
| -#if defined(UNIT_TEST) |
| -#include "base/logging.h" |
| -#endif // UNIT_TEST |
| - |
| namespace base { |
| class MessageLoop; |
| class SequencedWorkerPool; |
| @@ -188,7 +185,7 @@ class CONTENT_EXPORT BrowserThread { |
| static bool IsThreadInitialized(ID identifier); |
| // Callable on any thread. Returns whether you're currently on a particular |
| - // thread. |
| + // thread. To DCHECK this, see the DCHECK_CURRENTLY_ON() macro below. |
| static bool CurrentlyOn(ID identifier); |
| // Callable on any thread. Returns whether the threads message loop is valid. |
| @@ -266,6 +263,9 @@ class CONTENT_EXPORT BrowserThread { |
| struct DeleteOnFileThread : public DeleteOnThread<FILE> { }; |
| struct DeleteOnDBThread : public DeleteOnThread<DB> { }; |
| + // Returns an appropriate error message for when DCHECK_CURRENTLY_ON() fails. |
| + static std::string GetDCheckCurrentlyOnErrorMessage(ID expected); |
| + |
| private: |
| friend class BrowserThreadImpl; |
| @@ -273,6 +273,11 @@ class CONTENT_EXPORT BrowserThread { |
| DISALLOW_COPY_AND_ASSIGN(BrowserThread); |
| }; |
| +#define DCHECK_CURRENTLY_ON(thread_identifier) \ |
|
Jói
2014/03/11 08:41:25
nit: This would be more discoverable if placed at
Jeffrey Yasskin
2014/03/11 19:11:22
SG. Done, thanks.
|
| + (DCHECK(::content::BrowserThread::CurrentlyOn(thread_identifier)) \ |
| + << ::content::BrowserThread::GetDCheckCurrentlyOnErrorMessage( \ |
| + thread_identifier)) |
| + |
| } // namespace content |
| #endif // CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ |