| Index: content/public/browser/browser_thread.h
|
| diff --git a/content/public/browser/browser_thread.h b/content/public/browser/browser_thread.h
|
| index 66dc009beaf26dbf8f08a81d828fba11cc2777b6..4478558452aeb6fc8fe8a77081cbc9166158e8dc 100644
|
| --- a/content/public/browser/browser_thread.h
|
| +++ b/content/public/browser/browser_thread.h
|
| @@ -6,11 +6,21 @@
|
| #define CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_
|
| #pragma once
|
|
|
| +#include "base/basictypes.h"
|
| #include "base/callback.h"
|
| -#include "base/synchronization/lock.h"
|
| #include "base/task.h"
|
| -#include "base/threading/thread.h"
|
| +#include "base/tracked_objects.h"
|
| #include "content/common/content_export.h"
|
| +#include "content/public/browser/browser_thread_delegate.h"
|
| +
|
| +// TODO(joi): Remove these in a follow-up change and IWYU in files
|
| +// that were getting them directly or indirectly from here.
|
| +#include "base/memory/ref_counted.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "base/message_loop.h"
|
| +#include "base/message_loop_proxy.h"
|
| +#include "base/synchronization/lock.h"
|
| +#include "base/threading/thread.h"
|
|
|
| #if defined(UNIT_TEST)
|
| #include "base/logging.h"
|
| @@ -18,12 +28,12 @@
|
|
|
| namespace base {
|
| class MessageLoopProxy;
|
| +class Thread;
|
| }
|
|
|
| namespace content {
|
|
|
| class BrowserThreadImpl;
|
| -class DeprecatedBrowserThread;
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
| // BrowserThread
|
| @@ -47,7 +57,7 @@ class DeprecatedBrowserThread;
|
| // task is posted to is guaranteed to outlive the current thread, then no locks
|
| // are used. You should never need to cache pointers to MessageLoops, since
|
| // they're not thread safe.
|
| -class CONTENT_EXPORT BrowserThread : public base::Thread {
|
| +class CONTENT_EXPORT BrowserThread {
|
| public:
|
| // An enumeration of the well-known threads.
|
| // NOTE: threads must be listed in the order of their life-time, with each
|
| @@ -170,6 +180,33 @@ class CONTENT_EXPORT BrowserThread : public base::Thread {
|
| static scoped_refptr<base::MessageLoopProxy> GetMessageLoopProxyForThread(
|
| ID identifier);
|
|
|
| + // Gets the Thread object for the specified thread, or NULL if the
|
| + // thread has not been created (or has been destroyed during
|
| + // shutdown).
|
| + //
|
| + // Before calling this, you must have called content::ContentMain
|
| + // with a command-line that would specify a browser process (e.g. an
|
| + // empty command line).
|
| + //
|
| + // This is unsafe as your pointer may become invalid close to
|
| + // shutdown.
|
| + //
|
| + // TODO(joi): Remove this once clients such as BrowserProcessImpl
|
| + // (and classes that call things like
|
| + // g_browser_process->file_thread()) are switched to using
|
| + // MessageLoopProxy.
|
| + static base::Thread* UnsafeGetBrowserThread(ID identifier);
|
| +
|
| + // Sets the delegate for the specified BrowserThread.
|
| + //
|
| + // Only one delegate may be registered at a time. Delegates may be
|
| + // unregistered by providing a NULL pointer.
|
| + //
|
| + // If the caller unregisters a delegate before CleanUp has been
|
| + // called, it must perform its own locking to ensure the delegate is
|
| + // not deleted while unregistering.
|
| + static void SetDelegate(ID identifier, BrowserThreadDelegate* delegate);
|
| +
|
| // Use these templates in conjuction with RefCountedThreadSafe when you want
|
| // to ensure that an object is deleted on a specific thread. This is needed
|
| // when an object can hop between threads (i.e. IO -> FILE -> IO), and thread
|
| @@ -213,40 +250,10 @@ class CONTENT_EXPORT BrowserThread : public base::Thread {
|
| struct DeleteOnWebKitThread : public DeleteOnThread<WEBKIT> { };
|
|
|
| private:
|
| - // Construct a BrowserThread with the supplied identifier. It is an error
|
| - // to construct a BrowserThread that already exists.
|
| - explicit BrowserThread(ID identifier);
|
| -
|
| - // Special constructor for the main (UI) thread and unittests. We use a dummy
|
| - // thread here since the main thread already exists.
|
| - BrowserThread(ID identifier, MessageLoop* message_loop);
|
| -
|
| - virtual ~BrowserThread();
|
| -
|
| - // Common initialization code for the constructors.
|
| - void Initialize();
|
| -
|
| - // Constructors are only available through this subclass.
|
| - friend class content::BrowserThreadImpl;
|
| + friend class BrowserThreadImpl;
|
|
|
| - // TODO(joi): Remove.
|
| - friend class DeprecatedBrowserThread;
|
| -
|
| - // The identifier of this thread. Only one thread can exist with a given
|
| - // identifier at a given time.
|
| - // TODO(joi): Move to BrowserThreadImpl, and make constructors here
|
| - // do-nothing.
|
| - ID identifier_;
|
| -};
|
| -
|
| -// Temporary escape hatch for chrome/ to construct BrowserThread,
|
| -// until we make content/ construct its own threads.
|
| -class CONTENT_EXPORT DeprecatedBrowserThread : public BrowserThread {
|
| - public:
|
| - explicit DeprecatedBrowserThread(BrowserThread::ID identifier);
|
| - DeprecatedBrowserThread(BrowserThread::ID identifier,
|
| - MessageLoop* message_loop);
|
| - virtual ~DeprecatedBrowserThread();
|
| + BrowserThread() {}
|
| + DISALLOW_COPY_AND_ASSIGN(BrowserThread);
|
| };
|
|
|
| } // namespace content
|
|
|