Index: content/browser/browser_thread_impl.h |
diff --git a/content/browser/browser_thread_impl.h b/content/browser/browser_thread_impl.h |
index 45dce5fcc9bc24c69b6d238c74a17868c368011d..27f5122f1bc50e1753680b7c32c7a2f146d17e25 100644 |
--- a/content/browser/browser_thread_impl.h |
+++ b/content/browser/browser_thread_impl.h |
@@ -6,22 +6,29 @@ |
#define CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_ |
#pragma once |
+#include "base/synchronization/lock.h" |
+#include "base/threading/thread.h" |
#include "content/common/content_export.h" |
#include "content/public/browser/browser_thread.h" |
namespace content { |
-class CONTENT_EXPORT BrowserThreadImpl : public BrowserThread { |
+class CONTENT_EXPORT BrowserThreadImpl |
+ : public BrowserThread, public base::Thread { |
public: |
+ // Construct a BrowserThreadImpl with the supplied identifier. It is an error |
+ // to construct a BrowserThreadImpl that already exists. |
explicit BrowserThreadImpl(BrowserThread::ID identifier); |
+ |
+ // Special constructor for the main (UI) thread and unittests. We use a dummy |
+ // thread here since the main thread already exists. |
BrowserThreadImpl(BrowserThread::ID identifier, MessageLoop* message_loop); |
virtual ~BrowserThreadImpl(); |
private: |
- // We implement most functionality on the public set of |
- // BrowserThread functions, but state is stored in the |
- // BrowserThreadImpl to keep the public API cleaner. Therefore make |
- // BrowserThread a friend class. |
+ // We implement all the functionality of the public BrowserThread |
+ // functions, but state is stored in the BrowserThreadImpl to keep |
+ // the API cleaner. Therefore make BrowserThread a friend class. |
friend class BrowserThread; |
// TODO(brettw) remove this variant when Task->Closure migration is complete. |
@@ -42,11 +49,19 @@ class CONTENT_EXPORT BrowserThreadImpl : public BrowserThread { |
// without holding this lock. Do not block while holding this lock. |
static base::Lock lock_; |
- // An array of the BrowserThread objects. This array is protected by |lock_|. |
- // The threads are not owned by this array. Typically, the threads are owned |
- // on the UI thread by the g_browser_process object. BrowserThreads remove |
- // themselves from this array upon destruction. |
- static BrowserThread* browser_threads_[ID_COUNT]; |
+ // An array of the BrowserThreadImpl objects. This array is |
+ // protected by |lock_|. The threads are not owned by this array. |
+ // Typically, the threads are owned on the UI thread by the |
+ // g_browser_process object. BrowserThreadImpls remove themselves |
+ // from this array upon destruction. |
+ static BrowserThreadImpl* browser_threads_[ID_COUNT]; |
+ |
+ // Common initialization code for the constructors. |
+ void Initialize(); |
+ |
+ // The identifier of this thread. Only one thread can exist with a given |
+ // identifier at a given time. |
+ ID identifier_; |
}; |
} // namespace content |