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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 class CONTENT_EXPORT BrowserThreadImpl | 16 class CONTENT_EXPORT BrowserThreadImpl |
17 : public BrowserThread, public base::Thread { | 17 : public BrowserThread, public base::Thread { |
18 public: | 18 public: |
19 // Construct a BrowserThreadImpl with the supplied identifier. It is an error | 19 // Construct a BrowserThreadImpl with the supplied identifier. It is an error |
20 // to construct a BrowserThreadImpl that already exists. | 20 // to construct a BrowserThreadImpl that already exists. |
21 explicit BrowserThreadImpl(BrowserThread::ID identifier); | 21 explicit BrowserThreadImpl(BrowserThread::ID identifier); |
22 | 22 |
23 // Special constructor for the main (UI) thread and unittests. We use a dummy | 23 // Special constructor for the main (UI) thread and unittests. We use a dummy |
24 // thread here since the main thread already exists. | 24 // thread here since the main thread already exists. |
25 BrowserThreadImpl(BrowserThread::ID identifier, MessageLoop* message_loop); | 25 BrowserThreadImpl(BrowserThread::ID identifier, MessageLoop* message_loop); |
26 virtual ~BrowserThreadImpl(); | 26 virtual ~BrowserThreadImpl(); |
27 | 27 |
28 static void ShutdownThreadPool(); | |
29 | |
30 protected: | 28 protected: |
31 virtual void Init() OVERRIDE; | 29 virtual void Init() OVERRIDE; |
32 virtual void CleanUp() OVERRIDE; | 30 virtual void CleanUp() OVERRIDE; |
33 | 31 |
34 private: | 32 private: |
35 // We implement all the functionality of the public BrowserThread | 33 // We implement all the functionality of the public BrowserThread |
36 // functions, but state is stored in the BrowserThreadImpl to keep | 34 // functions, but state is stored in the BrowserThreadImpl to keep |
37 // the API cleaner. Therefore make BrowserThread a friend class. | 35 // the API cleaner. Therefore make BrowserThread a friend class. |
38 friend class BrowserThread; | 36 friend class BrowserThread; |
39 | 37 |
40 static bool PostTaskHelper( | 38 static bool PostTaskHelper( |
41 BrowserThread::ID identifier, | 39 BrowserThread::ID identifier, |
42 const tracked_objects::Location& from_here, | 40 const tracked_objects::Location& from_here, |
43 const base::Closure& task, | 41 const base::Closure& task, |
44 int64 delay_ms, | 42 int64 delay_ms, |
45 bool nestable); | 43 bool nestable); |
46 | 44 |
47 // Common initialization code for the constructors. | 45 // Common initialization code for the constructors. |
48 void Initialize(); | 46 void Initialize(); |
49 | 47 |
50 // The identifier of this thread. Only one thread can exist with a given | 48 // The identifier of this thread. Only one thread can exist with a given |
51 // identifier at a given time. | 49 // identifier at a given time. |
52 ID identifier_; | 50 ID identifier_; |
53 }; | 51 }; |
54 | 52 |
55 } // namespace content | 53 } // namespace content |
56 | 54 |
57 #endif // CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_ | 55 #endif // CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_ |
OLD | NEW |