OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_IO_THREAD_H_ | 5 #ifndef CHROME_BROWSER_IO_THREAD_H_ |
6 #define CHROME_BROWSER_IO_THREAD_H_ | 6 #define CHROME_BROWSER_IO_THREAD_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
14 #include "chrome/browser/net/ssl_config_service_manager.h" | 16 #include "chrome/browser/net/ssl_config_service_manager.h" |
15 #include "chrome/browser/prefs/pref_member.h" | 17 #include "chrome/browser/prefs/pref_member.h" |
16 #include "content/browser/browser_process_sub_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/browser_thread_delegate.h" |
17 #include "net/base/network_change_notifier.h" | 20 #include "net/base/network_change_notifier.h" |
18 | 21 |
| 22 // TODO(joi): Remove these in a follow-up change and IWYU in files |
| 23 // that were getting them directly or indirectly from here. |
| 24 #include "base/memory/ref_counted.h" |
| 25 #include "base/memory/scoped_ptr.h" |
| 26 #include "base/message_loop.h" |
| 27 #include "base/message_loop_proxy.h" |
| 28 #include "base/synchronization/lock.h" |
| 29 #include "base/threading/thread.h" |
| 30 |
| 31 class BrowserProcessImpl; |
19 class ChromeNetLog; | 32 class ChromeNetLog; |
20 class ExtensionEventRouterForwarder; | 33 class ExtensionEventRouterForwarder; |
21 class MediaInternals; | 34 class MediaInternals; |
22 class PrefProxyConfigTrackerImpl; | 35 class PrefProxyConfigTrackerImpl; |
23 class PrefService; | 36 class PrefService; |
24 class SystemURLRequestContextGetter; | 37 class SystemURLRequestContextGetter; |
25 | 38 |
26 namespace net { | 39 namespace net { |
27 class CertVerifier; | 40 class CertVerifier; |
28 class CookieStore; | 41 class CookieStore; |
29 class DnsRRResolver; | 42 class DnsRRResolver; |
30 class FtpTransactionFactory; | 43 class FtpTransactionFactory; |
31 class HostResolver; | 44 class HostResolver; |
32 class HttpAuthHandlerFactory; | 45 class HttpAuthHandlerFactory; |
33 class HttpServerProperties; | 46 class HttpServerProperties; |
34 class HttpTransactionFactory; | 47 class HttpTransactionFactory; |
35 class NetworkDelegate; | 48 class NetworkDelegate; |
36 class OriginBoundCertService; | 49 class OriginBoundCertService; |
37 class ProxyConfigService; | 50 class ProxyConfigService; |
38 class ProxyService; | 51 class ProxyService; |
39 class SdchManager; | 52 class SdchManager; |
40 class SSLConfigService; | 53 class SSLConfigService; |
41 class URLRequestContext; | 54 class URLRequestContext; |
42 class URLRequestContextGetter; | 55 class URLRequestContextGetter; |
43 class URLSecurityManager; | 56 class URLSecurityManager; |
44 } // namespace net | 57 } // namespace net |
45 | 58 |
46 class IOThread : public content::BrowserProcessSubThread { | 59 // Contains state associated with, initialized and cleaned up on, and |
| 60 // primarily used on, the IO thread. Also acts as a convenience |
| 61 // accessor to the Thread object for the IO thread. |
| 62 class IOThread : public content::BrowserThreadDelegate { |
47 public: | 63 public: |
48 struct Globals { | 64 struct Globals { |
49 Globals(); | 65 Globals(); |
50 ~Globals(); | 66 ~Globals(); |
51 | 67 |
52 struct MediaGlobals { | 68 struct MediaGlobals { |
53 MediaGlobals(); | 69 MediaGlobals(); |
54 ~MediaGlobals(); | 70 ~MediaGlobals(); |
55 // MediaInternals singleton used to aggregate media information. | 71 // MediaInternals singleton used to aggregate media information. |
56 scoped_ptr<MediaInternals> media_internals; | 72 scoped_ptr<MediaInternals> media_internals; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 ChromeNetLog* net_log(); | 118 ChromeNetLog* net_log(); |
103 | 119 |
104 // Returns a getter for the URLRequestContext. Only called on the UI thread. | 120 // Returns a getter for the URLRequestContext. Only called on the UI thread. |
105 net::URLRequestContextGetter* system_url_request_context_getter(); | 121 net::URLRequestContextGetter* system_url_request_context_getter(); |
106 | 122 |
107 // Clears the host cache. Intended to be used to prevent exposing recently | 123 // Clears the host cache. Intended to be used to prevent exposing recently |
108 // visited sites on about:net-internals/#dns and about:dns pages. Must be | 124 // visited sites on about:net-internals/#dns and about:dns pages. Must be |
109 // called on the IO thread. | 125 // called on the IO thread. |
110 void ClearHostCache(); | 126 void ClearHostCache(); |
111 | 127 |
112 protected: | 128 // Convenience method similar to base::Thread, giving access to the |
| 129 // actual IO thread. |
| 130 // TODO(joi): Remove this in follow-up changes. |
| 131 MessageLoop* message_loop() const; |
| 132 |
| 133 private: |
| 134 // BrowserThreadDelegate implementation, runs on the IO thread. |
| 135 // This handles initialization and destruction of state that must |
| 136 // live on the IO thread. |
113 virtual void Init() OVERRIDE; | 137 virtual void Init() OVERRIDE; |
114 virtual void CleanUp() OVERRIDE; | 138 virtual void CleanUp() OVERRIDE; |
115 | 139 |
116 private: | |
117 // Provide SystemURLRequestContextGetter with access to | 140 // Provide SystemURLRequestContextGetter with access to |
118 // InitSystemRequestContext(). | 141 // InitSystemRequestContext(). |
119 friend class SystemURLRequestContextGetter; | 142 friend class SystemURLRequestContextGetter; |
120 | 143 |
| 144 // Global state must be initialized on the IO thread, then this |
| 145 // method must be invoked on the UI thread. |
| 146 void InitSystemRequestContext(); |
| 147 |
| 148 // Lazy initialization of system request context for |
| 149 // SystemURLRequestContextGetter. To be called on IO thread only |
| 150 // after global state has been initialized on the IO thread, and |
| 151 // SystemRequestContext state has been initialized on the UI thread. |
| 152 void InitSystemRequestContextOnIOThread(); |
| 153 |
121 static void RegisterPrefs(PrefService* local_state); | 154 static void RegisterPrefs(PrefService* local_state); |
122 | 155 |
123 net::HttpAuthHandlerFactory* CreateDefaultAuthHandlerFactory( | 156 net::HttpAuthHandlerFactory* CreateDefaultAuthHandlerFactory( |
124 net::HostResolver* resolver); | 157 net::HostResolver* resolver); |
125 | 158 |
126 void InitSystemRequestContext(); | |
127 | |
128 // Lazy initialization of system request context for | |
129 // SystemURLRequestContextGetter. To be called on IO thread. | |
130 void InitSystemRequestContextOnIOThread(); | |
131 | |
132 // Returns an SSLConfigService instance. | 159 // Returns an SSLConfigService instance. |
133 net::SSLConfigService* GetSSLConfigService(); | 160 net::SSLConfigService* GetSSLConfigService(); |
134 | 161 |
135 // The NetLog is owned by the browser process, to allow logging from other | 162 // The NetLog is owned by the browser process, to allow logging from other |
136 // threads during shutdown, but is used most frequently on the IOThread. | 163 // threads during shutdown, but is used most frequently on the IOThread. |
137 ChromeNetLog* net_log_; | 164 ChromeNetLog* net_log_; |
138 | 165 |
139 // The ExtensionEventRouterForwarder allows for sending events to extensions | 166 // The ExtensionEventRouterForwarder allows for sending events to extensions |
140 // from the IOThread. | 167 // from the IOThread. |
141 ExtensionEventRouterForwarder* extension_event_router_forwarder_; | 168 ExtensionEventRouterForwarder* extension_event_router_forwarder_; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 system_url_request_context_getter_; | 205 system_url_request_context_getter_; |
179 | 206 |
180 net::SdchManager* sdch_manager_; | 207 net::SdchManager* sdch_manager_; |
181 | 208 |
182 base::WeakPtrFactory<IOThread> weak_factory_; | 209 base::WeakPtrFactory<IOThread> weak_factory_; |
183 | 210 |
184 DISALLOW_COPY_AND_ASSIGN(IOThread); | 211 DISALLOW_COPY_AND_ASSIGN(IOThread); |
185 }; | 212 }; |
186 | 213 |
187 #endif // CHROME_BROWSER_IO_THREAD_H_ | 214 #endif // CHROME_BROWSER_IO_THREAD_H_ |
OLD | NEW |