| 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..4054fe079744120ef874b6d012893b85c470488b 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;
|
| @@ -30,6 +27,13 @@ namespace content {
|
| class BrowserThreadDelegate;
|
| class BrowserThreadImpl;
|
|
|
| +// Use DCHECK_CURRENTLY_ON(BrowserThread::ID) to assert that a function can only
|
| +// be called on the named BrowserThread.
|
| +#define DCHECK_CURRENTLY_ON(thread_identifier) \
|
| + (DCHECK(::content::BrowserThread::CurrentlyOn(thread_identifier)) \
|
| + << ::content::BrowserThread::GetDCheckCurrentlyOnErrorMessage( \
|
| + thread_identifier))
|
| +
|
| ///////////////////////////////////////////////////////////////////////////////
|
| // BrowserThread
|
| //
|
| @@ -188,7 +192,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, use the DCHECK_CURRENTLY_ON() macro above.
|
| static bool CurrentlyOn(ID identifier);
|
|
|
| // Callable on any thread. Returns whether the threads message loop is valid.
|
| @@ -266,6 +270,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;
|
|
|
|
|