[email protected] | ef2bf42 | 2012-05-11 03:27:09 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | b0f146f | 2011-09-15 22:14:25 | [diff] [blame] | 5 | #ifndef CONTENT_BROWSER_BROWSER_PROCESS_SUB_THREAD_H_ |
6 | #define CONTENT_BROWSER_BROWSER_PROCESS_SUB_THREAD_H_ | ||||
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 7 | |
dcheng | 5971627 | 2016-04-09 05:19:08 | [diff] [blame] | 8 | #include <memory> |
9 | |||||
avi | b734894 | 2015-12-25 20:57:10 | [diff] [blame] | 10 | #include "base/macros.h" |
11 | #include "build/build_config.h" | ||||
[email protected] | c38831a1 | 2011-10-28 12:44:49 | [diff] [blame] | 12 | #include "content/browser/browser_thread_impl.h" |
[email protected] | 84c13c03 | 2011-09-23 00:12:22 | [diff] [blame] | 13 | #include "content/common/content_export.h" |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 14 | |
[email protected] | 451fd90 | 2012-10-03 17:14:48 | [diff] [blame] | 15 | #if defined(OS_WIN) |
16 | namespace base { | ||||
17 | namespace win { | ||||
18 | class ScopedCOMInitializer; | ||||
19 | } | ||||
20 | } | ||||
21 | #endif | ||||
22 | |||||
[email protected] | ad50def5 | 2011-10-19 23:17:07 | [diff] [blame] | 23 | namespace content { |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 24 | class NotificationService; |
[email protected] | ad50def5 | 2011-10-19 23:17:07 | [diff] [blame] | 25 | } |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 26 | |
[email protected] | c38831a1 | 2011-10-28 12:44:49 | [diff] [blame] | 27 | namespace content { |
28 | |||||
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 29 | // ---------------------------------------------------------------------------- |
30 | // BrowserProcessSubThread | ||||
31 | // | ||||
32 | // This simple thread object is used for the specialized threads that the | ||||
33 | // BrowserProcess spins up. | ||||
34 | // | ||||
35 | // Applications must initialize the COM library before they can call | ||||
36 | // COM library functions other than CoGetMalloc and memory allocation | ||||
37 | // functions, so this class initializes COM for those users. | ||||
[email protected] | c38831a1 | 2011-10-28 12:44:49 | [diff] [blame] | 38 | class CONTENT_EXPORT BrowserProcessSubThread : public BrowserThreadImpl { |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 39 | public: |
[email protected] | d04e766 | 2010-10-10 22:24:48 | [diff] [blame] | 40 | explicit BrowserProcessSubThread(BrowserThread::ID identifier); |
boliu | 61687ec5 | 2017-03-29 20:09:34 | [diff] [blame] | 41 | BrowserProcessSubThread(BrowserThread::ID identifier, |
42 | base::MessageLoop* message_loop); | ||||
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 43 | ~BrowserProcessSubThread() override; |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 44 | |
45 | protected: | ||||
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 46 | void Init() override; |
47 | void CleanUp() override; | ||||
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 48 | |
49 | private: | ||||
[email protected] | af66993 | 2012-01-17 19:26:58 | [diff] [blame] | 50 | // These methods encapsulate cleanup that needs to happen on the IO thread |
[email protected] | ef2bf42 | 2012-05-11 03:27:09 | [diff] [blame] | 51 | // before we call the embedder's CleanUp function. |
[email protected] | af66993 | 2012-01-17 19:26:58 | [diff] [blame] | 52 | void IOThreadPreCleanUp(); |
[email protected] | af66993 | 2012-01-17 19:26:58 | [diff] [blame] | 53 | |
[email protected] | 451fd90 | 2012-10-03 17:14:48 | [diff] [blame] | 54 | #if defined (OS_WIN) |
dcheng | 5971627 | 2016-04-09 05:19:08 | [diff] [blame] | 55 | std::unique_ptr<base::win::ScopedCOMInitializer> com_initializer_; |
[email protected] | 451fd90 | 2012-10-03 17:14:48 | [diff] [blame] | 56 | #endif |
57 | |||||
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 58 | // Each specialized thread has its own notification service. |
dcheng | 5971627 | 2016-04-09 05:19:08 | [diff] [blame] | 59 | std::unique_ptr<NotificationService> notification_service_; |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 60 | |
61 | DISALLOW_COPY_AND_ASSIGN(BrowserProcessSubThread); | ||||
62 | }; | ||||
63 | |||||
[email protected] | c38831a1 | 2011-10-28 12:44:49 | [diff] [blame] | 64 | } // namespace content |
65 | |||||
[email protected] | b0f146f | 2011-09-15 22:14:25 | [diff] [blame] | 66 | #endif // CONTENT_BROWSER_BROWSER_PROCESS_SUB_THREAD_H_ |