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" | |
14 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
16 #include "chrome/browser/net/ssl_config_service_manager.h" | 14 #include "chrome/browser/net/ssl_config_service_manager.h" |
17 #include "chrome/browser/prefs/pref_member.h" | 15 #include "chrome/browser/prefs/pref_member.h" |
18 #include "content/public/browser/browser_thread.h" | 16 #include "content/browser/browser_process_sub_thread.h" |
19 #include "content/public/browser/browser_thread_delegate.h" | |
20 #include "net/base/network_change_notifier.h" | 17 #include "net/base/network_change_notifier.h" |
21 | 18 |
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; | |
32 class ChromeNetLog; | 19 class ChromeNetLog; |
33 class ExtensionEventRouterForwarder; | 20 class ExtensionEventRouterForwarder; |
34 class MediaInternals; | 21 class MediaInternals; |
35 class PrefProxyConfigTrackerImpl; | 22 class PrefProxyConfigTrackerImpl; |
36 class PrefService; | 23 class PrefService; |
37 class SystemURLRequestContextGetter; | 24 class SystemURLRequestContextGetter; |
38 | 25 |
39 namespace net { | 26 namespace net { |
40 class CertVerifier; | 27 class CertVerifier; |
41 class CookieStore; | 28 class CookieStore; |
42 class DnsRRResolver; | 29 class DnsRRResolver; |
43 class FtpTransactionFactory; | 30 class FtpTransactionFactory; |
44 class HostResolver; | 31 class HostResolver; |
45 class HttpAuthHandlerFactory; | 32 class HttpAuthHandlerFactory; |
46 class HttpServerProperties; | 33 class HttpServerProperties; |
47 class HttpTransactionFactory; | 34 class HttpTransactionFactory; |
48 class NetworkDelegate; | 35 class NetworkDelegate; |
49 class OriginBoundCertService; | 36 class OriginBoundCertService; |
50 class ProxyConfigService; | 37 class ProxyConfigService; |
51 class ProxyService; | 38 class ProxyService; |
52 class SdchManager; | 39 class SdchManager; |
53 class SSLConfigService; | 40 class SSLConfigService; |
54 class URLRequestContext; | 41 class URLRequestContext; |
55 class URLRequestContextGetter; | 42 class URLRequestContextGetter; |
56 class URLSecurityManager; | 43 class URLSecurityManager; |
57 } // namespace net | 44 } // namespace net |
58 | 45 |
59 // Contains state associated with, initialized and cleaned up on, and | 46 class IOThread : public content::BrowserProcessSubThread { |
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 { | |
63 public: | 47 public: |
64 struct Globals { | 48 struct Globals { |
65 Globals(); | 49 Globals(); |
66 ~Globals(); | 50 ~Globals(); |
67 | 51 |
68 struct MediaGlobals { | 52 struct MediaGlobals { |
69 MediaGlobals(); | 53 MediaGlobals(); |
70 ~MediaGlobals(); | 54 ~MediaGlobals(); |
71 // MediaInternals singleton used to aggregate media information. | 55 // MediaInternals singleton used to aggregate media information. |
72 scoped_ptr<MediaInternals> media_internals; | 56 scoped_ptr<MediaInternals> media_internals; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 ChromeNetLog* net_log(); | 102 ChromeNetLog* net_log(); |
119 | 103 |
120 // Returns a getter for the URLRequestContext. Only called on the UI thread. | 104 // Returns a getter for the URLRequestContext. Only called on the UI thread. |
121 net::URLRequestContextGetter* system_url_request_context_getter(); | 105 net::URLRequestContextGetter* system_url_request_context_getter(); |
122 | 106 |
123 // Clears the host cache. Intended to be used to prevent exposing recently | 107 // Clears the host cache. Intended to be used to prevent exposing recently |
124 // visited sites on about:net-internals/#dns and about:dns pages. Must be | 108 // visited sites on about:net-internals/#dns and about:dns pages. Must be |
125 // called on the IO thread. | 109 // called on the IO thread. |
126 void ClearHostCache(); | 110 void ClearHostCache(); |
127 | 111 |
128 // Convenience method similar to base::Thread, giving access to the | 112 protected: |
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. | |
137 virtual void Init() OVERRIDE; | 113 virtual void Init() OVERRIDE; |
138 virtual void CleanUp() OVERRIDE; | 114 virtual void CleanUp() OVERRIDE; |
139 | 115 |
| 116 private: |
140 // Provide SystemURLRequestContextGetter with access to | 117 // Provide SystemURLRequestContextGetter with access to |
141 // InitSystemRequestContext(). | 118 // InitSystemRequestContext(). |
142 friend class SystemURLRequestContextGetter; | 119 friend class SystemURLRequestContextGetter; |
143 | 120 |
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 | |
154 static void RegisterPrefs(PrefService* local_state); | 121 static void RegisterPrefs(PrefService* local_state); |
155 | 122 |
156 net::HttpAuthHandlerFactory* CreateDefaultAuthHandlerFactory( | 123 net::HttpAuthHandlerFactory* CreateDefaultAuthHandlerFactory( |
157 net::HostResolver* resolver); | 124 net::HostResolver* resolver); |
158 | 125 |
| 126 void InitSystemRequestContext(); |
| 127 |
| 128 // Lazy initialization of system request context for |
| 129 // SystemURLRequestContextGetter. To be called on IO thread. |
| 130 void InitSystemRequestContextOnIOThread(); |
| 131 |
159 // Returns an SSLConfigService instance. | 132 // Returns an SSLConfigService instance. |
160 net::SSLConfigService* GetSSLConfigService(); | 133 net::SSLConfigService* GetSSLConfigService(); |
161 | 134 |
162 // The NetLog is owned by the browser process, to allow logging from other | 135 // The NetLog is owned by the browser process, to allow logging from other |
163 // threads during shutdown, but is used most frequently on the IOThread. | 136 // threads during shutdown, but is used most frequently on the IOThread. |
164 ChromeNetLog* net_log_; | 137 ChromeNetLog* net_log_; |
165 | 138 |
166 // The ExtensionEventRouterForwarder allows for sending events to extensions | 139 // The ExtensionEventRouterForwarder allows for sending events to extensions |
167 // from the IOThread. | 140 // from the IOThread. |
168 ExtensionEventRouterForwarder* extension_event_router_forwarder_; | 141 ExtensionEventRouterForwarder* extension_event_router_forwarder_; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 system_url_request_context_getter_; | 178 system_url_request_context_getter_; |
206 | 179 |
207 net::SdchManager* sdch_manager_; | 180 net::SdchManager* sdch_manager_; |
208 | 181 |
209 base::WeakPtrFactory<IOThread> weak_factory_; | 182 base::WeakPtrFactory<IOThread> weak_factory_; |
210 | 183 |
211 DISALLOW_COPY_AND_ASSIGN(IOThread); | 184 DISALLOW_COPY_AND_ASSIGN(IOThread); |
212 }; | 185 }; |
213 | 186 |
214 #endif // CHROME_BROWSER_IO_THREAD_H_ | 187 #endif // CHROME_BROWSER_IO_THREAD_H_ |
OLD | NEW |