| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_ |
| 6 #define CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_ | 6 #define CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
| 9 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 class CONTENT_EXPORT BrowserThreadImpl | 14 class CONTENT_EXPORT BrowserThreadImpl |
| 15 : public BrowserThread, public base::Thread { | 15 : public BrowserThread, public base::Thread { |
| 16 public: | 16 public: |
| 17 // Construct a BrowserThreadImpl with the supplied identifier. It is an error | 17 // Construct a BrowserThreadImpl with the supplied identifier. It is an error |
| 18 // to construct a BrowserThreadImpl that already exists. | 18 // to construct a BrowserThreadImpl that already exists. |
| 19 explicit BrowserThreadImpl(BrowserThread::ID identifier); | 19 explicit BrowserThreadImpl(BrowserThread::ID identifier); |
| 20 | 20 |
| 21 // Special constructor for the main (UI) thread and unittests. We use a dummy | 21 // Special constructor for the main (UI) thread and unittests. We use a dummy |
| 22 // thread here since the main thread already exists. | 22 // thread here since the main thread already exists. |
| 23 BrowserThreadImpl(BrowserThread::ID identifier, MessageLoop* message_loop); | 23 BrowserThreadImpl(BrowserThread::ID identifier, MessageLoop* message_loop); |
| 24 virtual ~BrowserThreadImpl(); | 24 virtual ~BrowserThreadImpl(); |
| 25 | 25 |
| 26 static void ShutdownThreadPool(); | 26 static void ShutdownThreadPool(); |
| 27 | 27 |
| 28 protected: | 28 protected: |
| 29 virtual void Init() OVERRIDE; | 29 virtual void Init() OVERRIDE; |
| 30 virtual void Run(MessageLoop* message_loop) OVERRIDE; |
| 30 virtual void CleanUp() OVERRIDE; | 31 virtual void CleanUp() OVERRIDE; |
| 31 | 32 |
| 32 private: | 33 private: |
| 33 // We implement all the functionality of the public BrowserThread | 34 // We implement all the functionality of the public BrowserThread |
| 34 // functions, but state is stored in the BrowserThreadImpl to keep | 35 // functions, but state is stored in the BrowserThreadImpl to keep |
| 35 // the API cleaner. Therefore make BrowserThread a friend class. | 36 // the API cleaner. Therefore make BrowserThread a friend class. |
| 36 friend class BrowserThread; | 37 friend class BrowserThread; |
| 37 | 38 |
| 39 // The following are unique function names that makes it possible to tell |
| 40 // the thread id from the callstack alone in crash dumps. |
| 41 void UIThreadRun(MessageLoop* message_loop); |
| 42 void DBThreadRun(MessageLoop* message_loop); |
| 43 void WebKitThreadRun(MessageLoop* message_loop); |
| 44 void FileThreadRun(MessageLoop* message_loop); |
| 45 void FileUserBlockingThreadRun(MessageLoop* message_loop); |
| 46 void ProcessLauncherThreadRun(MessageLoop* message_loop); |
| 47 void CacheThreadRun(MessageLoop* message_loop); |
| 48 void IOThreadRun(MessageLoop* message_loop); |
| 49 |
| 38 static bool PostTaskHelper( | 50 static bool PostTaskHelper( |
| 39 BrowserThread::ID identifier, | 51 BrowserThread::ID identifier, |
| 40 const tracked_objects::Location& from_here, | 52 const tracked_objects::Location& from_here, |
| 41 const base::Closure& task, | 53 const base::Closure& task, |
| 42 base::TimeDelta delay, | 54 base::TimeDelta delay, |
| 43 bool nestable); | 55 bool nestable); |
| 44 | 56 |
| 45 // Common initialization code for the constructors. | 57 // Common initialization code for the constructors. |
| 46 void Initialize(); | 58 void Initialize(); |
| 47 | 59 |
| 48 // The identifier of this thread. Only one thread can exist with a given | 60 // The identifier of this thread. Only one thread can exist with a given |
| 49 // identifier at a given time. | 61 // identifier at a given time. |
| 50 ID identifier_; | 62 ID identifier_; |
| 51 }; | 63 }; |
| 52 | 64 |
| 53 } // namespace content | 65 } // namespace content |
| 54 | 66 |
| 55 #endif // CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_ | 67 #endif // CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_ |
| OLD | NEW |