| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 IOS_CHROME_BROWSER_IOS_CHROME_IO_THREAD_H_ |
| 6 #define CHROME_BROWSER_IO_THREAD_H_ | 6 #define IOS_CHROME_BROWSER_IOS_CHROME_IO_THREAD_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/prefs/pref_member.h" | 18 #include "base/prefs/pref_member.h" |
| 19 #include "base/strings/string_piece.h" | 19 #include "base/strings/string_piece.h" |
| 20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 21 #include "chrome/browser/net/chrome_network_delegate.h" | |
| 22 #include "components/ssl_config/ssl_config_service_manager.h" | 21 #include "components/ssl_config/ssl_config_service_manager.h" |
| 23 #include "content/public/browser/browser_thread.h" | 22 #include "ios/web/public/web_thread_delegate.h" |
| 24 #include "content/public/browser/browser_thread_delegate.h" | |
| 25 #include "net/base/network_change_notifier.h" | 23 #include "net/base/network_change_notifier.h" |
| 26 #include "net/http/http_network_session.h" | 24 #include "net/http/http_network_session.h" |
| 27 #include "net/socket/next_proto.h" | 25 #include "net/socket/next_proto.h" |
| 28 | 26 |
| 29 class PrefProxyConfigTracker; | 27 class PrefProxyConfigTracker; |
| 30 class PrefService; | 28 class PrefService; |
| 31 class PrefRegistrySimple; | |
| 32 class SystemURLRequestContextGetter; | 29 class SystemURLRequestContextGetter; |
| 33 | 30 |
| 34 namespace base { | 31 namespace base { |
| 35 class CommandLine; | 32 class CommandLine; |
| 36 } | 33 } // namespace base |
| 37 | |
| 38 #if defined(OS_ANDROID) | |
| 39 namespace chrome { | |
| 40 namespace android { | |
| 41 class ExternalDataUseObserver; | |
| 42 } | |
| 43 } | |
| 44 #endif // defined(OS_ANDROID) | |
| 45 | |
| 46 namespace chrome_browser_net { | |
| 47 class DnsProbeService; | |
| 48 } | |
| 49 | |
| 50 namespace data_usage { | |
| 51 class DataUseAggregator; | |
| 52 } | |
| 53 | |
| 54 namespace extensions { | |
| 55 class EventRouterForwarder; | |
| 56 } | |
| 57 | 34 |
| 58 namespace net { | 35 namespace net { |
| 59 class CertPolicyEnforcer; | 36 class CertPolicyEnforcer; |
| 60 class CertVerifier; | 37 class CertVerifier; |
| 61 class ChannelIDService; | 38 class ChannelIDService; |
| 62 class CookieStore; | 39 class CookieStore; |
| 63 class CTVerifier; | 40 class CTVerifier; |
| 64 class FtpTransactionFactory; | |
| 65 class HostMappingRules; | |
| 66 class HostResolver; | 41 class HostResolver; |
| 67 class HttpAuthHandlerFactory; | 42 class HttpAuthHandlerFactory; |
| 68 class HttpNetworkSession; | 43 class HttpNetworkSession; |
| 69 class HttpServerProperties; | 44 class HttpServerProperties; |
| 70 class HttpTransactionFactory; | 45 class HttpTransactionFactory; |
| 71 class HttpUserAgentSettings; | 46 class HttpUserAgentSettings; |
| 72 class NetworkDelegate; | 47 class NetworkDelegate; |
| 73 class NetworkQualityEstimator; | 48 class NetworkQualityEstimator; |
| 74 class ProxyConfigService; | 49 class ProxyConfigService; |
| 75 class ProxyService; | 50 class ProxyService; |
| 76 class SSLConfigService; | 51 class SSLConfigService; |
| 77 class TransportSecurityState; | 52 class TransportSecurityState; |
| 78 class URLRequestBackoffManager; | 53 class URLRequestBackoffManager; |
| 79 class URLRequestContext; | 54 class URLRequestContext; |
| 80 class URLRequestContextGetter; | 55 class URLRequestContextGetter; |
| 81 class URLRequestJobFactory; | 56 class URLRequestJobFactory; |
| 82 class URLSecurityManager; | 57 class URLSecurityManager; |
| 83 } // namespace net | 58 } // namespace net |
| 84 | 59 |
| 85 namespace net_log { | 60 namespace net_log { |
| 86 class ChromeNetLog; | 61 class ChromeNetLog; |
| 87 } | 62 } // namespace net_log |
| 88 | |
| 89 namespace policy { | |
| 90 class PolicyService; | |
| 91 } // namespace policy | |
| 92 | |
| 93 namespace test { | |
| 94 class IOThreadPeer; | |
| 95 } // namespace test | |
| 96 | 63 |
| 97 // Contains state associated with, initialized and cleaned up on, and | 64 // Contains state associated with, initialized and cleaned up on, and |
| 98 // primarily used on, the IO thread. | 65 // primarily used on, the IO thread. |
| 99 // | 66 // |
| 100 // If you are looking to interact with the IO thread (e.g. post tasks | 67 // If you are looking to interact with the IO thread (e.g. post tasks |
| 101 // to it or check if it is the current thread), see | 68 // to it or check if it is the current thread), see web::WebThread. |
| 102 // content::BrowserThread. | 69 class IOSChromeIOThread : public web::WebThreadDelegate { |
| 103 class IOThread : public content::BrowserThreadDelegate { | |
| 104 public: | 70 public: |
| 105 struct Globals { | 71 struct Globals { |
| 106 template <typename T> | 72 template <typename T> |
| 107 class Optional { | 73 class Optional { |
| 108 public: | 74 public: |
| 109 Optional() : set_(false) {} | 75 Optional() : set_(false) {} |
| 110 | 76 |
| 111 void set(T value) { | 77 void set(T value) { |
| 112 set_ = true; | 78 set_ = true; |
| 113 value_ = value; | 79 value_ = value; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 128 explicit SystemRequestContextLeakChecker(Globals* globals); | 94 explicit SystemRequestContextLeakChecker(Globals* globals); |
| 129 ~SystemRequestContextLeakChecker(); | 95 ~SystemRequestContextLeakChecker(); |
| 130 | 96 |
| 131 private: | 97 private: |
| 132 Globals* const globals_; | 98 Globals* const globals_; |
| 133 }; | 99 }; |
| 134 | 100 |
| 135 Globals(); | 101 Globals(); |
| 136 ~Globals(); | 102 ~Globals(); |
| 137 | 103 |
| 138 // Global aggregator of data use. It must outlive the | 104 // The "system" NetworkDelegate, used for BrowserState-agnostic network |
| 139 // |system_network_delegate|. | 105 // events. |
| 140 scoped_ptr<data_usage::DataUseAggregator> data_use_aggregator; | |
| 141 #if defined(OS_ANDROID) | |
| 142 // An external observer of data use. | |
| 143 scoped_ptr<chrome::android::ExternalDataUseObserver> | |
| 144 external_data_use_observer; | |
| 145 #endif // defined(OS_ANDROID) | |
| 146 // The "system" NetworkDelegate, used for Profile-agnostic network events. | |
| 147 scoped_ptr<net::NetworkDelegate> system_network_delegate; | 106 scoped_ptr<net::NetworkDelegate> system_network_delegate; |
| 148 scoped_ptr<net::HostResolver> host_resolver; | 107 scoped_ptr<net::HostResolver> host_resolver; |
| 149 scoped_ptr<net::CertVerifier> cert_verifier; | 108 scoped_ptr<net::CertVerifier> cert_verifier; |
| 150 // The ChannelIDService must outlive the HttpTransactionFactory. | 109 // The ChannelIDService must outlive the HttpTransactionFactory. |
| 151 scoped_ptr<net::ChannelIDService> system_channel_id_service; | 110 scoped_ptr<net::ChannelIDService> system_channel_id_service; |
| 152 // This TransportSecurityState doesn't load or save any state. It's only | 111 // This TransportSecurityState doesn't load or save any state. It's only |
| 153 // used to enforce pinning for system requests and will only use built-in | 112 // used to enforce pinning for system requests and will only use built-in |
| 154 // pins. | 113 // pins. |
| 155 scoped_ptr<net::TransportSecurityState> transport_security_state; | 114 scoped_ptr<net::TransportSecurityState> transport_security_state; |
| 156 scoped_ptr<net::CTVerifier> cert_transparency_verifier; | 115 scoped_ptr<net::CTVerifier> cert_transparency_verifier; |
| 157 scoped_ptr<net::CertPolicyEnforcer> cert_policy_enforcer; | 116 scoped_ptr<net::CertPolicyEnforcer> cert_policy_enforcer; |
| 158 scoped_refptr<net::SSLConfigService> ssl_config_service; | 117 scoped_refptr<net::SSLConfigService> ssl_config_service; |
| 159 scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory; | 118 scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory; |
| 160 scoped_ptr<net::HttpServerProperties> http_server_properties; | 119 scoped_ptr<net::HttpServerProperties> http_server_properties; |
| 161 scoped_ptr<net::ProxyService> proxy_script_fetcher_proxy_service; | |
| 162 scoped_ptr<net::HttpNetworkSession> | |
| 163 proxy_script_fetcher_http_network_session; | |
| 164 scoped_ptr<net::HttpTransactionFactory> | |
| 165 proxy_script_fetcher_http_transaction_factory; | |
| 166 scoped_ptr<net::FtpTransactionFactory> | |
| 167 proxy_script_fetcher_ftp_transaction_factory; | |
| 168 scoped_ptr<net::URLRequestJobFactory> | |
| 169 proxy_script_fetcher_url_request_job_factory; | |
| 170 scoped_ptr<net::URLRequestBackoffManager> url_request_backoff_manager; | 120 scoped_ptr<net::URLRequestBackoffManager> url_request_backoff_manager; |
| 171 scoped_ptr<net::URLSecurityManager> url_security_manager; | 121 scoped_ptr<net::URLSecurityManager> url_security_manager; |
| 172 // TODO(willchan): Remove proxy script fetcher context since it's not | |
| 173 // necessary now that I got rid of refcounting URLRequestContexts. | |
| 174 // | |
| 175 // The first URLRequestContext is |system_url_request_context|. We introduce | |
| 176 // |proxy_script_fetcher_context| for the second context. It has a direct | |
| 177 // ProxyService, since we always directly connect to fetch the PAC script. | |
| 178 scoped_ptr<net::URLRequestContext> proxy_script_fetcher_context; | |
| 179 scoped_ptr<net::ProxyService> system_proxy_service; | 122 scoped_ptr<net::ProxyService> system_proxy_service; |
| 180 scoped_ptr<net::HttpNetworkSession> system_http_network_session; | 123 scoped_ptr<net::HttpNetworkSession> system_http_network_session; |
| 181 scoped_ptr<net::HttpTransactionFactory> system_http_transaction_factory; | 124 scoped_ptr<net::HttpTransactionFactory> system_http_transaction_factory; |
| 182 scoped_ptr<net::URLRequestJobFactory> system_url_request_job_factory; | 125 scoped_ptr<net::URLRequestJobFactory> system_url_request_job_factory; |
| 183 scoped_ptr<net::URLRequestContext> system_request_context; | 126 scoped_ptr<net::URLRequestContext> system_request_context; |
| 184 SystemRequestContextLeakChecker system_request_context_leak_checker; | 127 SystemRequestContextLeakChecker system_request_context_leak_checker; |
| 185 // |system_cookie_store| and |system_channel_id_service| are shared | |
| 186 // between |proxy_script_fetcher_context| and |system_request_context|. | |
| 187 scoped_refptr<net::CookieStore> system_cookie_store; | 128 scoped_refptr<net::CookieStore> system_cookie_store; |
| 188 #if defined(ENABLE_EXTENSIONS) | |
| 189 scoped_refptr<extensions::EventRouterForwarder> | |
| 190 extension_event_router_forwarder; | |
| 191 #endif | |
| 192 scoped_ptr<net::HostMappingRules> host_mapping_rules; | |
| 193 scoped_ptr<net::HttpUserAgentSettings> http_user_agent_settings; | 129 scoped_ptr<net::HttpUserAgentSettings> http_user_agent_settings; |
| 194 scoped_ptr<net::NetworkQualityEstimator> network_quality_estimator; | 130 scoped_ptr<net::NetworkQualityEstimator> network_quality_estimator; |
| 195 bool ignore_certificate_errors; | |
| 196 uint16 testing_fixed_http_port; | 131 uint16 testing_fixed_http_port; |
| 197 uint16 testing_fixed_https_port; | 132 uint16 testing_fixed_https_port; |
| 198 Optional<bool> enable_tcp_fast_open_for_ssl; | 133 Optional<bool> enable_tcp_fast_open_for_ssl; |
| 199 | 134 |
| 200 Optional<size_t> initial_max_spdy_concurrent_streams; | 135 Optional<size_t> initial_max_spdy_concurrent_streams; |
| 201 Optional<bool> enable_spdy_compression; | 136 Optional<bool> enable_spdy_compression; |
| 202 Optional<bool> enable_spdy_ping_based_connection_checking; | 137 Optional<bool> enable_spdy_ping_based_connection_checking; |
| 203 Optional<net::NextProto> spdy_default_protocol; | |
| 204 net::NextProtoVector next_protos; | 138 net::NextProtoVector next_protos; |
| 205 Optional<std::string> trusted_spdy_proxy; | |
| 206 std::set<net::HostPortPair> forced_spdy_exclusions; | 139 std::set<net::HostPortPair> forced_spdy_exclusions; |
| 207 Optional<bool> use_alternative_services; | 140 Optional<bool> use_alternative_services; |
| 208 Optional<double> alternative_service_probability_threshold; | 141 Optional<double> alternative_service_probability_threshold; |
| 209 | 142 |
| 210 Optional<bool> enable_npn; | 143 Optional<bool> enable_npn; |
| 211 | 144 |
| 212 Optional<bool> enable_quic; | 145 Optional<bool> enable_quic; |
| 213 Optional<bool> enable_quic_for_proxies; | 146 Optional<bool> enable_quic_for_proxies; |
| 214 Optional<bool> enable_quic_port_selection; | |
| 215 Optional<bool> quic_always_require_handshake_confirmation; | 147 Optional<bool> quic_always_require_handshake_confirmation; |
| 216 Optional<bool> quic_disable_connection_pooling; | 148 Optional<bool> quic_disable_connection_pooling; |
| 217 Optional<float> quic_load_server_info_timeout_srtt_multiplier; | 149 Optional<float> quic_load_server_info_timeout_srtt_multiplier; |
| 218 Optional<bool> quic_enable_connection_racing; | 150 Optional<bool> quic_enable_connection_racing; |
| 219 Optional<bool> quic_enable_non_blocking_io; | 151 Optional<bool> quic_enable_non_blocking_io; |
| 220 Optional<bool> quic_disable_disk_cache; | 152 Optional<bool> quic_disable_disk_cache; |
| 221 Optional<bool> quic_prefer_aes; | 153 Optional<bool> quic_prefer_aes; |
| 222 Optional<int> quic_max_number_of_lossy_connections; | 154 Optional<int> quic_max_number_of_lossy_connections; |
| 223 Optional<float> quic_packet_loss_threshold; | 155 Optional<float> quic_packet_loss_threshold; |
| 224 Optional<int> quic_socket_receive_buffer_size; | 156 Optional<int> quic_socket_receive_buffer_size; |
| 225 Optional<bool> quic_delay_tcp_race; | 157 Optional<bool> quic_delay_tcp_race; |
| 226 Optional<size_t> quic_max_packet_length; | 158 Optional<size_t> quic_max_packet_length; |
| 227 net::QuicTagVector quic_connection_options; | 159 net::QuicTagVector quic_connection_options; |
| 228 Optional<std::string> quic_user_agent_id; | 160 Optional<std::string> quic_user_agent_id; |
| 229 Optional<net::QuicVersionVector> quic_supported_versions; | 161 Optional<net::QuicVersionVector> quic_supported_versions; |
| 230 Optional<net::HostPortPair> origin_to_force_quic_on; | |
| 231 Optional<bool> quic_close_sessions_on_ip_change; | 162 Optional<bool> quic_close_sessions_on_ip_change; |
| 232 bool enable_user_alternate_protocol_ports; | |
| 233 // NetErrorTabHelper uses |dns_probe_service| to send DNS probes when a | |
| 234 // main frame load fails with a DNS error in order to provide more useful | |
| 235 // information to the renderer so it can show a more specific error page. | |
| 236 scoped_ptr<chrome_browser_net::DnsProbeService> dns_probe_service; | |
| 237 }; | 163 }; |
| 238 | 164 |
| 239 // |net_log| must either outlive the IOThread or be NULL. | 165 // |net_log| must either outlive the IOSChromeIOThread or be NULL. |
| 240 IOThread(PrefService* local_state, | 166 IOSChromeIOThread(PrefService* local_state, net_log::ChromeNetLog* net_log); |
| 241 policy::PolicyService* policy_service, | |
| 242 net_log::ChromeNetLog* net_log, | |
| 243 extensions::EventRouterForwarder* extension_event_router_forwarder); | |
| 244 | 167 |
| 245 ~IOThread() override; | 168 ~IOSChromeIOThread() override; |
| 246 | |
| 247 static void RegisterPrefs(PrefRegistrySimple* registry); | |
| 248 | 169 |
| 249 // Can only be called on the IO thread. | 170 // Can only be called on the IO thread. |
| 250 Globals* globals(); | 171 Globals* globals(); |
| 251 | 172 |
| 252 // Allows overriding Globals in tests where IOThread::Init() and | 173 // Allows overriding Globals in tests where IOSChromeIOThread::Init() and |
| 253 // IOThread::CleanUp() are not called. This allows for injecting mocks into | 174 // IOSChromeIOThread::CleanUp() are not called. This allows for injecting |
| 254 // IOThread global objects. | 175 // mocks into IOSChromeIOThread global objects. |
| 255 void SetGlobalsForTesting(Globals* globals); | 176 void SetGlobalsForTesting(Globals* globals); |
| 256 | 177 |
| 257 net_log::ChromeNetLog* net_log(); | 178 net_log::ChromeNetLog* net_log(); |
| 258 | 179 |
| 259 // Handles changing to On The Record mode, discarding confidential data. | 180 // Handles changing to On The Record mode, discarding confidential data. |
| 260 void ChangedToOnTheRecord(); | 181 void ChangedToOnTheRecord(); |
| 261 | 182 |
| 262 // Returns a getter for the URLRequestContext. Only called on the UI thread. | 183 // Returns a getter for the URLRequestContext. Only called on the UI thread. |
| 263 net::URLRequestContextGetter* system_url_request_context_getter(); | 184 net::URLRequestContextGetter* system_url_request_context_getter(); |
| 264 | 185 |
| 265 // Clears the host cache. Intended to be used to prevent exposing recently | 186 // Clears the host cache. Intended to be used to prevent exposing recently |
| 266 // visited sites on about:net-internals/#dns and about:dns pages. Must be | 187 // visited sites on about:net-internals/#dns and about:dns pages. Must be |
| 267 // called on the IO thread. | 188 // called on the IO thread. |
| 268 void ClearHostCache(); | 189 void ClearHostCache(); |
| 269 | 190 |
| 270 void InitializeNetworkSessionParams(net::HttpNetworkSession::Params* params); | 191 void InitializeNetworkSessionParams(net::HttpNetworkSession::Params* params); |
| 271 | 192 |
| 272 base::TimeTicks creation_time() const; | 193 base::TimeTicks creation_time() const; |
| 273 | 194 |
| 274 // Returns true if QUIC should be enabled for data reduction proxy, either as | 195 // Returns true if QUIC should be enabled for data reduction proxy as a result |
| 275 // a result of a field trial or a command line flag. | 196 // of a field trial. |
| 276 static bool ShouldEnableQuicForDataReductionProxy(); | 197 static bool ShouldEnableQuicForDataReductionProxy(); |
| 277 | 198 |
| 278 private: | 199 private: |
| 279 // Map from name to value for all parameters associate with a field trial. | 200 // Map from name to value for all parameters associate with a field trial. |
| 280 typedef std::map<std::string, std::string> VariationParameters; | 201 typedef std::map<std::string, std::string> VariationParameters; |
| 281 | 202 |
| 282 // Provide SystemURLRequestContextGetter with access to | 203 // Provide SystemURLRequestContextGetter with access to |
| 283 // InitSystemRequestContext(). | 204 // InitSystemRequestContext(). |
| 284 friend class SystemURLRequestContextGetter; | 205 friend class SystemURLRequestContextGetter; |
| 285 | 206 |
| 286 friend class test::IOThreadPeer; | 207 // WebThreadDelegate implementation, runs on the IO thread. |
| 287 | |
| 288 // BrowserThreadDelegate implementation, runs on the IO thread. | |
| 289 // This handles initialization and destruction of state that must | 208 // This handles initialization and destruction of state that must |
| 290 // live on the IO thread. | 209 // live on the IO thread. |
| 291 void Init() override; | 210 void Init() override; |
| 211 void InitAsync() override; |
| 292 void CleanUp() override; | 212 void CleanUp() override; |
| 293 | 213 |
| 294 // Initializes |params| based on the settings in |globals|. | 214 // Initializes |params| based on the settings in |globals|. |
| 295 static void InitializeNetworkSessionParamsFromGlobals( | 215 static void InitializeNetworkSessionParamsFromGlobals( |
| 296 const Globals& globals, | 216 const Globals& globals, |
| 297 net::HttpNetworkSession::Params* params); | 217 net::HttpNetworkSession::Params* params); |
| 298 | 218 |
| 299 void InitializeNetworkOptions(const base::CommandLine& parsed_command_line); | 219 void InitializeNetworkOptions(); |
| 300 | 220 |
| 301 // Sets up TCP FastOpen if enabled via field trials or via the command line. | 221 // Sets up SSL TCP FastOpen if enabled via field trials. |
| 302 void ConfigureTCPFastOpen(const base::CommandLine& command_line); | 222 void ConfigureSSLTCPFastOpen(); |
| 303 | 223 |
| 304 // Configures available SPDY protocol versions in |globals| based on the flags | 224 // Configures available SPDY protocol versions in |globals| based on the SPDY |
| 305 // in |command_lin| as well as SPDY field trial group and parameters. Must be | 225 // field trial group and parameters. |
| 306 // called after ConfigureQuicGlobals. | 226 // Must be called after ConfigureQuicGlobals. |
| 307 static void ConfigureSpdyGlobals(const base::CommandLine& command_line, | 227 static void ConfigureSpdyGlobals(base::StringPiece quic_trial_group, |
| 308 base::StringPiece quic_trial_group, | |
| 309 const VariationParameters& quic_trial_params, | 228 const VariationParameters& quic_trial_params, |
| 310 Globals* globals); | 229 Globals* globals); |
| 311 | 230 |
| 312 // Configures NPN in |globals| based on the field trial group. | 231 // Configures NPN in |globals| based on the field trial group. |
| 313 static void ConfigureNPNGlobals(base::StringPiece npn_trial_group, | 232 static void ConfigureNPNGlobals(base::StringPiece npn_trial_group, |
| 314 Globals* globals); | 233 Globals* globals); |
| 315 | 234 |
| 316 // Global state must be initialized on the IO thread, then this | 235 // Global state must be initialized on the IO thread, then this |
| 317 // method must be invoked on the UI thread. | 236 // method must be invoked on the UI thread. |
| 318 void InitSystemRequestContext(); | 237 void InitSystemRequestContext(); |
| 319 | 238 |
| 320 // Lazy initialization of system request context for | 239 // Lazy initialization of system request context for |
| 321 // SystemURLRequestContextGetter. To be called on IO thread only | 240 // SystemURLRequestContextGetter. To be called on IO thread only |
| 322 // after global state has been initialized on the IO thread, and | 241 // after global state has been initialized on the IO thread, and |
| 323 // SystemRequestContext state has been initialized on the UI thread. | 242 // SystemRequestContext state has been initialized on the UI thread. |
| 324 void InitSystemRequestContextOnIOThread(); | 243 void InitSystemRequestContextOnIOThread(); |
| 325 | 244 |
| 326 net::HttpAuthHandlerFactory* CreateDefaultAuthHandlerFactory( | 245 net::HttpAuthHandlerFactory* CreateDefaultAuthHandlerFactory( |
| 327 net::HostResolver* resolver); | 246 net::HostResolver* resolver); |
| 328 | 247 |
| 329 // Returns an SSLConfigService instance. | 248 // Returns an SSLConfigService instance. |
| 330 net::SSLConfigService* GetSSLConfigService(); | 249 net::SSLConfigService* GetSSLConfigService(); |
| 331 | 250 |
| 332 void ChangedToOnTheRecordOnIOThread(); | 251 void ChangedToOnTheRecordOnIOThread(); |
| 333 | 252 |
| 334 void UpdateDnsClientEnabled(); | 253 // Configures QUIC options based on the QUIC field trial group. |
| 254 void ConfigureQuic(); |
| 335 | 255 |
| 336 // Configures QUIC options based on the flags in |command_line| as | 256 // Configures QUIC options in |globals| based on the flags in |command_line| |
| 337 // well as the QUIC field trial group. | 257 // as well as the QUIC field trial group and parameters. |
| 338 void ConfigureQuic(const base::CommandLine& command_line); | 258 // Must be called before ConfigureSpdyGlobals. |
| 259 static void ConfigureQuicGlobals(base::StringPiece quic_trial_group, |
| 260 const VariationParameters& quic_trial_params, |
| 261 Globals* globals); |
| 339 | 262 |
| 340 extensions::EventRouterForwarder* extension_event_router_forwarder() { | 263 // Returns true if QUIC should be enabled as a result of a field trial. |
| 341 #if defined(ENABLE_EXTENSIONS) | 264 static bool ShouldEnableQuic(base::StringPiece quic_trial_group); |
| 342 return extension_event_router_forwarder_; | |
| 343 #else | |
| 344 return NULL; | |
| 345 #endif | |
| 346 } | |
| 347 // Configures QUIC options in |globals| based on the flags in |command_line| | |
| 348 // as well as the QUIC field trial group and parameters. Must be called | |
| 349 // before ConfigureSpdyGlobals. | |
| 350 static void ConfigureQuicGlobals( | |
| 351 const base::CommandLine& command_line, | |
| 352 base::StringPiece quic_trial_group, | |
| 353 const VariationParameters& quic_trial_params, | |
| 354 bool quic_allowed_by_policy, | |
| 355 Globals* globals); | |
| 356 | 265 |
| 357 // Returns true if QUIC should be enabled, either as a result | 266 // Returns true if QUIC should be enabled for proxies as a result of a |
| 358 // of a field trial or a command line flag. | 267 // field trial. |
| 359 static bool ShouldEnableQuic( | 268 static bool ShouldEnableQuicForProxies(base::StringPiece quic_trial_group); |
| 360 const base::CommandLine& command_line, | |
| 361 base::StringPiece quic_trial_group, | |
| 362 bool quic_allowed_by_policy); | |
| 363 | |
| 364 // Returns true if QUIC should be enabled for proxies, either as a result | |
| 365 // of a field trial or a command line flag. | |
| 366 static bool ShouldEnableQuicForProxies( | |
| 367 const base::CommandLine& command_line, | |
| 368 base::StringPiece quic_trial_group, | |
| 369 bool quic_allowed_by_policy); | |
| 370 | |
| 371 // Returns true if the selection of the ephemeral port in bind() should be | |
| 372 // performed by Chromium, and false if the OS should select the port. The OS | |
| 373 // option is used to prevent Windows from posting a security security warning | |
| 374 // dialog. | |
| 375 static bool ShouldEnableQuicPortSelection( | |
| 376 const base::CommandLine& command_line); | |
| 377 | 269 |
| 378 // Returns true if QUIC should always require handshake confirmation during | 270 // Returns true if QUIC should always require handshake confirmation during |
| 379 // the QUIC handshake. | 271 // the QUIC handshake. |
| 380 static bool ShouldQuicAlwaysRequireHandshakeConfirmation( | 272 static bool ShouldQuicAlwaysRequireHandshakeConfirmation( |
| 381 const VariationParameters& quic_trial_params); | 273 const VariationParameters& quic_trial_params); |
| 382 | 274 |
| 383 // Returns true if QUIC should disable connection pooling. | 275 // Returns true if QUIC should disable connection pooling. |
| 384 static bool ShouldQuicDisableConnectionPooling( | 276 static bool ShouldQuicDisableConnectionPooling( |
| 385 const VariationParameters& quic_trial_params); | 277 const VariationParameters& quic_trial_params); |
| 386 | 278 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 401 // Returns true if QUIC shouldn't load QUIC server information from the disk | 293 // Returns true if QUIC shouldn't load QUIC server information from the disk |
| 402 // cache. | 294 // cache. |
| 403 static bool ShouldQuicDisableDiskCache( | 295 static bool ShouldQuicDisableDiskCache( |
| 404 const VariationParameters& quic_trial_params); | 296 const VariationParameters& quic_trial_params); |
| 405 | 297 |
| 406 // Returns true if QUIC should prefer AES-GCN even without hardware support. | 298 // Returns true if QUIC should prefer AES-GCN even without hardware support. |
| 407 static bool ShouldQuicPreferAes(const VariationParameters& quic_trial_params); | 299 static bool ShouldQuicPreferAes(const VariationParameters& quic_trial_params); |
| 408 | 300 |
| 409 // Returns true if QUIC should enable alternative services. | 301 // Returns true if QUIC should enable alternative services. |
| 410 static bool ShouldQuicEnableAlternativeServices( | 302 static bool ShouldQuicEnableAlternativeServices( |
| 411 const base::CommandLine& command_line, | |
| 412 const VariationParameters& quic_trial_params); | 303 const VariationParameters& quic_trial_params); |
| 413 | 304 |
| 414 // Returns the maximum number of QUIC connections with high packet loss in a | 305 // Returns the maximum number of QUIC connections with high packet loss in a |
| 415 // row after which QUIC should be disabled. Returns 0 if the default value | 306 // row after which QUIC should be disabled. Returns 0 if the default value |
| 416 // should be used. | 307 // should be used. |
| 417 static int GetQuicMaxNumberOfLossyConnections( | 308 static int GetQuicMaxNumberOfLossyConnections( |
| 418 const VariationParameters& quic_trial_params); | 309 const VariationParameters& quic_trial_params); |
| 419 | 310 |
| 420 // Returns the packet loss rate in fraction after which a QUIC connection is | 311 // Returns the packet loss rate in fraction after which a QUIC connection is |
| 421 // closed and is considered as a lossy connection. Returns 0 if the default | 312 // closed and is considered as a lossy connection. Returns 0 if the default |
| 422 // value should be used. | 313 // value should be used. |
| 423 static float GetQuicPacketLossThreshold( | 314 static float GetQuicPacketLossThreshold( |
| 424 const VariationParameters& quic_trial_params); | 315 const VariationParameters& quic_trial_params); |
| 425 | 316 |
| 426 // Returns the size of the QUIC receive buffer to use, or 0 if | 317 // Returns the size of the QUIC receive buffer to use, or 0 if |
| 427 // the default should be used. | 318 // the default should be used. |
| 428 static int GetQuicSocketReceiveBufferSize( | 319 static int GetQuicSocketReceiveBufferSize( |
| 429 const VariationParameters& quic_trial_params); | 320 const VariationParameters& quic_trial_params); |
| 430 | 321 |
| 431 // Returns true if QUIC should delay TCP connection when QUIC works. | 322 // Returns true if QUIC should delay TCP connection when QUIC works. |
| 432 static bool ShouldQuicDelayTcpRace( | 323 static bool ShouldQuicDelayTcpRace( |
| 433 const VariationParameters& quic_trial_params); | 324 const VariationParameters& quic_trial_params); |
| 434 | 325 |
| 435 // Returns true if QUIC should close sessions when any of the client's | 326 // Returns true if QUIC should close sessions when any of the client's |
| 436 // IP addresses change. | 327 // IP addresses change. |
| 437 static bool ShouldQuicCloseSessionsOnIpChange( | 328 static bool ShouldQuicCloseSessionsOnIpChange( |
| 438 const VariationParameters& quic_trial_params); | 329 const VariationParameters& quic_trial_params); |
| 439 | 330 |
| 440 // Returns the maximum length for QUIC packets, based on any flags in | 331 // Returns the maximum length for QUIC packets, based on any flags in the |
| 441 // |command_line| or the field trial. Returns 0 if there is an error | 332 // field trial. Returns 0 if there is an error parsing any of the options, |
| 442 // parsing any of the options, or if the default value should be used. | 333 // or if the default value should be used. |
| 443 static size_t GetQuicMaxPacketLength( | 334 static size_t GetQuicMaxPacketLength( |
| 444 const base::CommandLine& command_line, | |
| 445 const VariationParameters& quic_trial_params); | 335 const VariationParameters& quic_trial_params); |
| 446 | 336 |
| 447 // Returns the QUIC versions specified by any flags in |command_line| | 337 // Returns the QUIC versions specified by any flags in |quic_trial_params|. |
| 448 // or |quic_trial_params|. | |
| 449 static net::QuicVersion GetQuicVersion( | 338 static net::QuicVersion GetQuicVersion( |
| 450 const base::CommandLine& command_line, | |
| 451 const VariationParameters& quic_trial_params); | 339 const VariationParameters& quic_trial_params); |
| 452 | 340 |
| 453 // Returns the QUIC version specified by |quic_version| or | 341 // Returns the QUIC version specified by |quic_version| or |
| 454 // QUIC_VERSION_UNSUPPORTED if |quic_version| is invalid. | 342 // QUIC_VERSION_UNSUPPORTED if |quic_version| is invalid. |
| 455 static net::QuicVersion ParseQuicVersion(const std::string& quic_version); | 343 static net::QuicVersion ParseQuicVersion(const std::string& quic_version); |
| 456 | 344 |
| 457 // Returns the QUIC connection options specified by any flags in | 345 // Returns the QUIC connection options specified by any flags in |
| 458 // |command_line| or |quic_trial_params|. | 346 // |quic_trial_params|. |
| 459 static net::QuicTagVector GetQuicConnectionOptions( | 347 static net::QuicTagVector GetQuicConnectionOptions( |
| 460 const base::CommandLine& command_line, | |
| 461 const VariationParameters& quic_trial_params); | 348 const VariationParameters& quic_trial_params); |
| 462 | 349 |
| 463 // Returns the alternative service probability threshold specified by | 350 // Returns the alternative service probability threshold specified by |
| 464 // any flags in |command_line| or |quic_trial_params|. | 351 // any flags in |quic_trial_params|. |
| 465 static double GetAlternativeProtocolProbabilityThreshold( | 352 static double GetAlternativeProtocolProbabilityThreshold( |
| 466 const base::CommandLine& command_line, | |
| 467 const VariationParameters& quic_trial_params); | 353 const VariationParameters& quic_trial_params); |
| 468 | 354 |
| 469 static net::URLRequestContext* ConstructSystemRequestContext( | 355 static net::URLRequestContext* ConstructSystemRequestContext( |
| 470 IOThread::Globals* globals, | 356 Globals* globals, |
| 471 net::NetLog* net_log); | 357 net::NetLog* net_log); |
| 472 | 358 |
| 473 // TODO(willchan): Remove proxy script fetcher context since it's not | 359 // The NetLog is owned by the application context, to allow logging from other |
| 474 // necessary now that I got rid of refcounting URLRequestContexts. | 360 // threads during shutdown, but is used most frequently on the IO thread. |
| 475 // See IOThread::Globals for details. | |
| 476 static net::URLRequestContext* ConstructProxyScriptFetcherContext( | |
| 477 IOThread::Globals* globals, | |
| 478 net::NetLog* net_log); | |
| 479 | |
| 480 // The NetLog is owned by the browser process, to allow logging from other | |
| 481 // threads during shutdown, but is used most frequently on the IOThread. | |
| 482 net_log::ChromeNetLog* net_log_; | 361 net_log::ChromeNetLog* net_log_; |
| 483 | 362 |
| 484 #if defined(ENABLE_EXTENSIONS) | |
| 485 // The extensions::EventRouterForwarder allows for sending events to | |
| 486 // extensions from the IOThread. | |
| 487 extensions::EventRouterForwarder* extension_event_router_forwarder_; | |
| 488 #endif | |
| 489 | |
| 490 // These member variables are basically global, but their lifetimes are tied | 363 // These member variables are basically global, but their lifetimes are tied |
| 491 // to the IOThread. IOThread owns them all, despite not using scoped_ptr. | 364 // to the IOSChromeIOThread. IOSChromeIOThread owns them all, despite not |
| 492 // This is because the destructor of IOThread runs on the wrong thread. All | 365 // using scoped_ptr. This is because the destructor of IOSChromeIOThread runs |
| 493 // member variables should be deleted in CleanUp(). | 366 // on the wrong thread. All member variables should be deleted in CleanUp(). |
| 494 | 367 |
| 495 // These member variables are initialized in Init() and do not change for the | 368 // These member variables are initialized in Init() and do not change for the |
| 496 // lifetime of the IO thread. | 369 // lifetime of the IO thread. |
| 497 | 370 |
| 498 Globals* globals_; | 371 Globals* globals_; |
| 499 | 372 |
| 500 // Observer that logs network changes to the ChromeNetLog. | 373 // Observer that logs network changes to the ChromeNetLog. |
| 501 class LoggingNetworkChangeObserver; | 374 class LoggingNetworkChangeObserver; |
| 502 scoped_ptr<LoggingNetworkChangeObserver> network_change_observer_; | 375 scoped_ptr<LoggingNetworkChangeObserver> network_change_observer_; |
| 503 | 376 |
| 504 BooleanPrefMember system_enable_referrers_; | |
| 505 | |
| 506 BooleanPrefMember dns_client_enabled_; | |
| 507 | |
| 508 BooleanPrefMember quick_check_enabled_; | |
| 509 | |
| 510 // Store HTTP Auth-related policies in this thread. | |
| 511 std::string auth_schemes_; | |
| 512 bool negotiate_disable_cname_lookup_; | |
| 513 bool negotiate_enable_port_; | |
| 514 std::string auth_server_whitelist_; | |
| 515 std::string auth_delegate_whitelist_; | |
| 516 std::string gssapi_library_name_; | |
| 517 std::string auth_android_negotiate_account_type_; | |
| 518 | |
| 519 // This is an instance of the default SSLConfigServiceManager for the current | 377 // This is an instance of the default SSLConfigServiceManager for the current |
| 520 // platform and it gets SSL preferences from local_state object. | 378 // platform and it gets SSL preferences from local_state object. |
| 521 scoped_ptr<ssl_config::SSLConfigServiceManager> ssl_config_service_manager_; | 379 scoped_ptr<ssl_config::SSLConfigServiceManager> ssl_config_service_manager_; |
| 522 | 380 |
| 523 // These member variables are initialized by a task posted to the IO thread, | 381 // These member variables are initialized by a task posted to the IO thread, |
| 524 // which gets posted by calling certain member functions of IOThread. | 382 // which gets posted by calling certain member functions of IOSChromeIOThread. |
| 525 scoped_ptr<net::ProxyConfigService> system_proxy_config_service_; | 383 scoped_ptr<net::ProxyConfigService> system_proxy_config_service_; |
| 526 | 384 |
| 527 scoped_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_; | 385 scoped_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_; |
| 528 | 386 |
| 529 scoped_refptr<net::URLRequestContextGetter> | 387 scoped_refptr<net::URLRequestContextGetter> |
| 530 system_url_request_context_getter_; | 388 system_url_request_context_getter_; |
| 531 | 389 |
| 532 // True if SPDY is disabled by policy. | |
| 533 bool is_spdy_disabled_by_policy_; | |
| 534 | |
| 535 // True if QUIC is allowed by policy. | |
| 536 bool is_quic_allowed_by_policy_; | |
| 537 | |
| 538 const base::TimeTicks creation_time_; | 390 const base::TimeTicks creation_time_; |
| 539 | 391 |
| 540 base::WeakPtrFactory<IOThread> weak_factory_; | 392 base::WeakPtrFactory<IOSChromeIOThread> weak_factory_; |
| 541 | 393 |
| 542 DISALLOW_COPY_AND_ASSIGN(IOThread); | 394 DISALLOW_COPY_AND_ASSIGN(IOSChromeIOThread); |
| 543 }; | 395 }; |
| 544 | 396 |
| 545 #endif // CHROME_BROWSER_IO_THREAD_H_ | 397 #endif // IOS_CHROME_BROWSER_IOS_CHROME_IO_THREAD_H_ |
| OLD | NEW |