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/platform_thread.h" | |
9 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
10 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
11 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
12 | 11 |
13 namespace content { | 12 namespace content { |
14 | 13 |
15 class CONTENT_EXPORT BrowserThreadImpl : public BrowserThread, | 14 class CONTENT_EXPORT BrowserThreadImpl : public BrowserThread, |
16 public base::Thread { | 15 public base::Thread { |
17 public: | 16 public: |
18 // Construct a BrowserThreadImpl with the supplied identifier. It is an error | 17 // Construct a BrowserThreadImpl with the supplied identifier. It is an error |
19 // to construct a BrowserThreadImpl that already exists. | 18 // to construct a BrowserThreadImpl that already exists. |
20 explicit BrowserThreadImpl(BrowserThread::ID identifier); | 19 explicit BrowserThreadImpl(BrowserThread::ID identifier); |
21 | 20 |
22 // Special constructor for the main (UI) thread and unittests. If a | 21 // Special constructor for the main (UI) thread and unittests. If a |
23 // |message_loop| is provied, we use a dummy thread here since the main | 22 // |message_loop| is provied, we use a dummy thread here since the main |
24 // thread already exists. | 23 // thread already exists. |
25 BrowserThreadImpl(BrowserThread::ID identifier, | 24 BrowserThreadImpl(BrowserThread::ID identifier, |
26 base::MessageLoop* message_loop); | 25 base::MessageLoop* message_loop); |
27 ~BrowserThreadImpl() override; | 26 ~BrowserThreadImpl() override; |
28 | 27 |
29 bool Start(); | |
30 bool StartWithOptions(const Options& options); | 28 bool StartWithOptions(const Options& options); |
31 bool StartAndWaitForTesting(); | |
32 | 29 |
33 static void ShutdownThreadPool(); | 30 static void ShutdownThreadPool(); |
34 | 31 |
35 protected: | 32 protected: |
36 void Init() override; | 33 void Init() override; |
37 void Run(base::RunLoop* run_loop) override; | 34 void Run(base::RunLoop* run_loop) override; |
38 void CleanUp() override; | 35 void CleanUp() override; |
39 | 36 |
40 private: | 37 private: |
41 // We implement all the functionality of the public BrowserThread | 38 // We implement all the functionality of the public BrowserThread |
(...skipping 27 matching lines...) Expand all Loading... |
69 static void FlushThreadPoolHelperForTesting(); | 66 static void FlushThreadPoolHelperForTesting(); |
70 | 67 |
71 // The identifier of this thread. Only one thread can exist with a given | 68 // The identifier of this thread. Only one thread can exist with a given |
72 // identifier at a given time. | 69 // identifier at a given time. |
73 ID identifier_; | 70 ID identifier_; |
74 }; | 71 }; |
75 | 72 |
76 } // namespace content | 73 } // namespace content |
77 | 74 |
78 #endif // CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_ | 75 #endif // CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_ |
OLD | NEW |