OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 IOS_WEB_WEB_THREAD_IMPL_H_ | 5 #ifndef IOS_WEB_WEB_THREAD_IMPL_H_ |
6 #define IOS_WEB_WEB_THREAD_IMPL_H_ | 6 #define IOS_WEB_WEB_THREAD_IMPL_H_ |
7 | 7 |
8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
9 #include "ios/web/public/web_thread.h" | 9 #include "ios/web/public/web_thread.h" |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 // Special constructor for the main (UI) thread and unittests. If a | 21 // Special constructor for the main (UI) thread and unittests. If a |
22 // |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 |
23 // thread already exists. | 23 // thread already exists. |
24 WebThreadImpl(WebThread::ID identifier, base::MessageLoop* message_loop); | 24 WebThreadImpl(WebThread::ID identifier, base::MessageLoop* message_loop); |
25 ~WebThreadImpl() override; | 25 ~WebThreadImpl() override; |
26 | 26 |
27 static void ShutdownThreadPool(); | 27 static void ShutdownThreadPool(); |
28 | 28 |
29 protected: | 29 protected: |
30 void Init() override; | 30 void Init() override; |
31 void Run(base::MessageLoop* message_loop) override; | 31 void Run(base::RunLoop* run_loop) override; |
32 void CleanUp() override; | 32 void CleanUp() override; |
33 | 33 |
34 private: | 34 private: |
35 // This class implements all the functionality of the public WebThread | 35 // This class implements all the functionality of the public WebThread |
36 // functions, but state is stored in the WebThreadImpl to keep | 36 // functions, but state is stored in the WebThreadImpl to keep |
37 // the API cleaner. Therefore make WebThread a friend class. | 37 // the API cleaner. Therefore make WebThread a friend class. |
38 friend class WebThread; | 38 friend class WebThread; |
39 | 39 |
40 // The following are unique function names that makes it possible to tell | 40 // The following are unique function names that makes it possible to tell |
41 // the thread id from the callstack alone in crash dumps. | 41 // the thread id from the callstack alone in crash dumps. |
42 void UIThreadRun(base::MessageLoop* message_loop); | 42 void UIThreadRun(base::RunLoop* run_loop); |
43 void DBThreadRun(base::MessageLoop* message_loop); | 43 void DBThreadRun(base::RunLoop* run_loop); |
44 void FileThreadRun(base::MessageLoop* message_loop); | 44 void FileThreadRun(base::RunLoop* run_loop); |
45 void FileUserBlockingThreadRun(base::MessageLoop* message_loop); | 45 void FileUserBlockingThreadRun(base::RunLoop* run_loop); |
46 void CacheThreadRun(base::MessageLoop* message_loop); | 46 void CacheThreadRun(base::RunLoop* run_loop); |
47 void IOThreadRun(base::MessageLoop* message_loop); | 47 void IOThreadRun(base::RunLoop* run_loop); |
48 | 48 |
49 static bool PostTaskHelper(WebThread::ID identifier, | 49 static bool PostTaskHelper(WebThread::ID identifier, |
50 const tracked_objects::Location& from_here, | 50 const tracked_objects::Location& from_here, |
51 const base::Closure& task, | 51 const base::Closure& task, |
52 base::TimeDelta delay, | 52 base::TimeDelta delay, |
53 bool nestable); | 53 bool nestable); |
54 | 54 |
55 // Common initialization code for the constructors. | 55 // Common initialization code for the constructors. |
56 void Initialize(); | 56 void Initialize(); |
57 | 57 |
58 // Performs cleanup that needs to happen on the IO thread before calling the | 58 // Performs cleanup that needs to happen on the IO thread before calling the |
59 // embedder's CleanUp function. | 59 // embedder's CleanUp function. |
60 void IOThreadPreCleanUp(); | 60 void IOThreadPreCleanUp(); |
61 | 61 |
62 // For testing. | 62 // For testing. |
63 friend class TestWebThreadBundle; | 63 friend class TestWebThreadBundle; |
64 friend class TestWebThreadBundleImpl; | 64 friend class TestWebThreadBundleImpl; |
65 friend class WebTestSuiteListener; | 65 friend class WebTestSuiteListener; |
66 static void FlushThreadPoolHelperForTesting(); | 66 static void FlushThreadPoolHelperForTesting(); |
67 | 67 |
68 // 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 |
69 // identifier at a given time. | 69 // identifier at a given time. |
70 ID identifier_; | 70 ID identifier_; |
71 }; | 71 }; |
72 | 72 |
73 } // namespace web | 73 } // namespace web |
74 | 74 |
75 #endif // IOS_WEB_WEB_THREAD_IMPL_H_ | 75 #endif // IOS_WEB_WEB_THREAD_IMPL_H_ |
OLD | NEW |