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 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/task.h" | 13 #include "base/task.h" |
14 #include "chrome/browser/browser_process_sub_thread.h" | 14 #include "chrome/browser/browser_process_sub_thread.h" |
15 #include "chrome/browser/net/ssl_config_service_manager.h" | 15 #include "chrome/browser/net/ssl_config_service_manager.h" |
16 #include "chrome/browser/prefs/pref_member.h" | 16 #include "chrome/browser/prefs/pref_member.h" |
| 17 #include "chrome/common/net/predictor_common.h" |
17 #include "net/base/network_change_notifier.h" | 18 #include "net/base/network_change_notifier.h" |
18 | 19 |
19 class ChromeNetLog; | 20 class ChromeNetLog; |
20 class ChromeURLRequestContextGetter; | 21 class ChromeURLRequestContextGetter; |
21 class ExtensionEventRouterForwarder; | 22 class ExtensionEventRouterForwarder; |
22 class MediaInternals; | 23 class MediaInternals; |
23 class PrefProxyConfigTracker; | 24 class PrefProxyConfigTracker; |
24 class PrefService; | 25 class PrefService; |
25 class SystemURLRequestContextGetter; | 26 class SystemURLRequestContextGetter; |
26 | 27 |
27 namespace base { | 28 namespace base { |
28 class ListValue; | 29 class ListValue; |
29 } | 30 } |
30 | 31 |
| 32 namespace chrome_browser_net { |
| 33 class ConnectInterceptor; |
| 34 class Predictor; |
| 35 } // namespace chrome_browser_net |
| 36 |
31 namespace net { | 37 namespace net { |
32 class CertVerifier; | 38 class CertVerifier; |
33 class CookieStore; | 39 class CookieStore; |
34 class DnsRRResolver; | 40 class DnsRRResolver; |
35 class FtpTransactionFactory; | 41 class FtpTransactionFactory; |
36 class HostResolver; | 42 class HostResolver; |
37 class HttpAuthHandlerFactory; | 43 class HttpAuthHandlerFactory; |
38 class HttpTransactionFactory; | 44 class HttpTransactionFactory; |
39 class NetworkDelegate; | 45 class NetworkDelegate; |
40 class OriginBoundCertService; | 46 class OriginBoundCertService; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 ChromeNetLog* net_log, | 102 ChromeNetLog* net_log, |
97 ExtensionEventRouterForwarder* extension_event_router_forwarder); | 103 ExtensionEventRouterForwarder* extension_event_router_forwarder); |
98 | 104 |
99 virtual ~IOThread(); | 105 virtual ~IOThread(); |
100 | 106 |
101 // Can only be called on the IO thread. | 107 // Can only be called on the IO thread. |
102 Globals* globals(); | 108 Globals* globals(); |
103 | 109 |
104 ChromeNetLog* net_log(); | 110 ChromeNetLog* net_log(); |
105 | 111 |
| 112 // Initializes the network predictor, which induces DNS pre-resolution and/or |
| 113 // TCP/IP preconnections. |prefetching_enabled| indicates whether or not DNS |
| 114 // prefetching should be enabled, and |preconnect_enabled| controls whether |
| 115 // TCP/IP preconnection is enabled. This should be called by the UI thread. |
| 116 // It will post a task to the IO thread to perform the actual initialization. |
| 117 void InitNetworkPredictor(bool prefetching_enabled, |
| 118 base::TimeDelta max_dns_queue_delay, |
| 119 size_t max_speculative_parallel_resolves, |
| 120 const chrome_common_net::UrlList& startup_urls, |
| 121 base::ListValue* referral_list, |
| 122 bool preconnect_enabled); |
| 123 |
| 124 // Handles changing to On The Record mode, discarding confidential data. |
| 125 void ChangedToOnTheRecord(); |
| 126 |
106 // Returns a getter for the URLRequestContext. Only called on the UI thread. | 127 // Returns a getter for the URLRequestContext. Only called on the UI thread. |
107 net::URLRequestContextGetter* system_url_request_context_getter(); | 128 net::URLRequestContextGetter* system_url_request_context_getter(); |
108 | 129 |
109 // Clears the host cache. Intended to be used to prevent exposing recently | 130 // Clear all network stack history, including the host cache, as well as |
110 // visited sites on about:net-internals/#dns and about:dns pages. Must be | 131 // speculative data about subresources of visited sites, and startup-time |
111 // called on the IO thread. | 132 // navigations. |
112 void ClearHostCache(); | 133 void ClearNetworkingHistory(); |
113 | 134 |
114 protected: | 135 protected: |
115 virtual void Init(); | 136 virtual void Init(); |
116 virtual void CleanUp(); | 137 virtual void CleanUp(); |
117 | 138 |
118 private: | 139 private: |
119 // Provide SystemURLRequestContextGetter with access to | 140 // Provide SystemURLRequestContextGetter with access to |
120 // InitSystemRequestContext(). | 141 // InitSystemRequestContext(). |
121 friend class SystemURLRequestContextGetter; | 142 friend class SystemURLRequestContextGetter; |
122 | 143 |
123 static void RegisterPrefs(PrefService* local_state); | 144 static void RegisterPrefs(PrefService* local_state); |
124 | 145 |
125 net::HttpAuthHandlerFactory* CreateDefaultAuthHandlerFactory( | 146 net::HttpAuthHandlerFactory* CreateDefaultAuthHandlerFactory( |
126 net::HostResolver* resolver); | 147 net::HostResolver* resolver); |
127 | 148 |
128 void InitSystemRequestContext(); | 149 void InitSystemRequestContext(); |
129 | 150 |
130 // Lazy initialization of system request context for | 151 // Lazy initialization of system request context for |
131 // SystemURLRequestContextGetter. To be called on IO thread. | 152 // SystemURLRequestContextGetter. To be called on IO thread. |
132 void InitSystemRequestContextOnIOThread(); | 153 void InitSystemRequestContextOnIOThread(); |
133 | 154 |
| 155 void InitNetworkPredictorOnIOThread( |
| 156 bool prefetching_enabled, |
| 157 base::TimeDelta max_dns_queue_delay, |
| 158 size_t max_speculative_parallel_resolves, |
| 159 const chrome_common_net::UrlList& startup_urls, |
| 160 base::ListValue* referral_list, |
| 161 bool preconnect_enabled); |
| 162 |
| 163 void ChangedToOnTheRecordOnIOThread(); |
| 164 |
| 165 // Clears the host cache. Intended to be used to prevent exposing recently |
| 166 // visited sites on about:net-internals/#dns and about:dns pages. Must be |
| 167 // called on the IO thread. |
| 168 void ClearHostCache(); |
| 169 |
134 // Returns an SSLConfigService instance. | 170 // Returns an SSLConfigService instance. |
135 net::SSLConfigService* GetSSLConfigService(); | 171 net::SSLConfigService* GetSSLConfigService(); |
136 | 172 |
137 // The NetLog is owned by the browser process, to allow logging from other | 173 // The NetLog is owned by the browser process, to allow logging from other |
138 // threads during shutdown, but is used most frequently on the IOThread. | 174 // threads during shutdown, but is used most frequently on the IOThread. |
139 ChromeNetLog* net_log_; | 175 ChromeNetLog* net_log_; |
140 | 176 |
141 // The ExtensionEventRouterForwarder allows for sending events to extensions | 177 // The ExtensionEventRouterForwarder allows for sending events to extensions |
142 // from the IOThread. | 178 // from the IOThread. |
143 ExtensionEventRouterForwarder* extension_event_router_forwarder_; | 179 ExtensionEventRouterForwarder* extension_event_router_forwarder_; |
(...skipping 21 matching lines...) Expand all Loading... |
165 std::string auth_server_whitelist_; | 201 std::string auth_server_whitelist_; |
166 std::string auth_delegate_whitelist_; | 202 std::string auth_delegate_whitelist_; |
167 std::string gssapi_library_name_; | 203 std::string gssapi_library_name_; |
168 | 204 |
169 // This is an instance of the default SSLConfigServiceManager for the current | 205 // This is an instance of the default SSLConfigServiceManager for the current |
170 // platform and it gets SSL preferences from local_state object. | 206 // platform and it gets SSL preferences from local_state object. |
171 scoped_ptr<SSLConfigServiceManager> ssl_config_service_manager_; | 207 scoped_ptr<SSLConfigServiceManager> ssl_config_service_manager_; |
172 | 208 |
173 // These member variables are initialized by a task posted to the IO thread, | 209 // These member variables are initialized by a task posted to the IO thread, |
174 // which gets posted by calling certain member functions of IOThread. | 210 // which gets posted by calling certain member functions of IOThread. |
| 211 |
| 212 // Note: we user explicit pointers rather than smart pointers to be more |
| 213 // explicit about destruction order, and ensure that there is no chance that |
| 214 // these observers would be used accidentally after we have begun to tear |
| 215 // down. |
| 216 chrome_browser_net::ConnectInterceptor* speculative_interceptor_; |
| 217 chrome_browser_net::Predictor* predictor_; |
| 218 |
175 scoped_ptr<net::ProxyConfigService> system_proxy_config_service_; | 219 scoped_ptr<net::ProxyConfigService> system_proxy_config_service_; |
176 | 220 |
177 scoped_refptr<PrefProxyConfigTracker> pref_proxy_config_tracker_; | 221 scoped_refptr<PrefProxyConfigTracker> pref_proxy_config_tracker_; |
178 | 222 |
179 scoped_refptr<net::URLRequestContextGetter> | 223 scoped_refptr<net::URLRequestContextGetter> |
180 system_url_request_context_getter_; | 224 system_url_request_context_getter_; |
181 | 225 |
182 ScopedRunnableMethodFactory<IOThread> method_factory_; | 226 ScopedRunnableMethodFactory<IOThread> method_factory_; |
183 | 227 |
184 DISALLOW_COPY_AND_ASSIGN(IOThread); | 228 DISALLOW_COPY_AND_ASSIGN(IOThread); |
185 }; | 229 }; |
186 | 230 |
187 #endif // CHROME_BROWSER_IO_THREAD_H_ | 231 #endif // CHROME_BROWSER_IO_THREAD_H_ |
OLD | NEW |