| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 class URLRequestContextGetter; | 62 class URLRequestContextGetter; |
| 63 class URLRequestJobFactory; | 63 class URLRequestJobFactory; |
| 64 class URLRequestThrottlerManager; | 64 class URLRequestThrottlerManager; |
| 65 class URLSecurityManager; | 65 class URLSecurityManager; |
| 66 } // namespace net | 66 } // namespace net |
| 67 | 67 |
| 68 namespace policy { | 68 namespace policy { |
| 69 class PolicyService; | 69 class PolicyService; |
| 70 } // namespace policy | 70 } // namespace policy |
| 71 | 71 |
| 72 namespace test { |
| 73 class IOThreadPeer; |
| 74 } // namespace test |
| 75 |
| 72 // Contains state associated with, initialized and cleaned up on, and | 76 // Contains state associated with, initialized and cleaned up on, and |
| 73 // primarily used on, the IO thread. | 77 // primarily used on, the IO thread. |
| 74 // | 78 // |
| 75 // If you are looking to interact with the IO thread (e.g. post tasks | 79 // If you are looking to interact with the IO thread (e.g. post tasks |
| 76 // to it or check if it is the current thread), see | 80 // to it or check if it is the current thread), see |
| 77 // content::BrowserThread. | 81 // content::BrowserThread. |
| 78 class IOThread : public content::BrowserThreadDelegate { | 82 class IOThread : public content::BrowserThreadDelegate { |
| 79 public: | 83 public: |
| 80 struct Globals { | 84 struct Globals { |
| 81 template <typename T> | 85 template <typename T> |
| 82 class Optional { | 86 class Optional { |
| 83 public: | 87 public: |
| 84 Optional() : set_(false) {} | 88 Optional() : set_(false) {} |
| 85 | 89 |
| 86 void set(T value) { | 90 void set(T value) { |
| 87 set_ = true; | 91 set_ = true; |
| 88 value_ = value; | 92 value_ = value; |
| 89 } | 93 } |
| 90 void CopyToIfSet(T* value) { | 94 void CopyToIfSet(T* value) const { |
| 91 if (set_) { | 95 if (set_) { |
| 92 *value = value_; | 96 *value = value_; |
| 93 } | 97 } |
| 94 } | 98 } |
| 95 | 99 |
| 96 private: | 100 private: |
| 97 bool set_; | 101 bool set_; |
| 98 T value_; | 102 T value_; |
| 99 }; | 103 }; |
| 100 | 104 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 Optional<string> trusted_spdy_proxy; | 169 Optional<string> trusted_spdy_proxy; |
| 166 Optional<bool> force_spdy_over_ssl; | 170 Optional<bool> force_spdy_over_ssl; |
| 167 Optional<bool> force_spdy_always; | 171 Optional<bool> force_spdy_always; |
| 168 std::set<net::HostPortPair> forced_spdy_exclusions; | 172 std::set<net::HostPortPair> forced_spdy_exclusions; |
| 169 Optional<bool> use_alternate_protocols; | 173 Optional<bool> use_alternate_protocols; |
| 170 Optional<bool> enable_websocket_over_spdy; | 174 Optional<bool> enable_websocket_over_spdy; |
| 171 | 175 |
| 172 Optional<bool> enable_quic; | 176 Optional<bool> enable_quic; |
| 173 Optional<bool> enable_quic_pacing; | 177 Optional<bool> enable_quic_pacing; |
| 174 Optional<bool> enable_quic_time_based_loss_detection; | 178 Optional<bool> enable_quic_time_based_loss_detection; |
| 175 Optional<bool> enable_quic_persist_server_info; | |
| 176 Optional<bool> enable_quic_port_selection; | 179 Optional<bool> enable_quic_port_selection; |
| 177 Optional<size_t> quic_max_packet_length; | 180 Optional<size_t> quic_max_packet_length; |
| 181 net::QuicTagVector quic_connection_options; |
| 178 Optional<std::string> quic_user_agent_id; | 182 Optional<std::string> quic_user_agent_id; |
| 179 Optional<net::QuicVersionVector> quic_supported_versions; | 183 Optional<net::QuicVersionVector> quic_supported_versions; |
| 180 Optional<net::HostPortPair> origin_to_force_quic_on; | 184 Optional<net::HostPortPair> origin_to_force_quic_on; |
| 181 bool enable_user_alternate_protocol_ports; | 185 bool enable_user_alternate_protocol_ports; |
| 182 // NetErrorTabHelper uses |dns_probe_service| to send DNS probes when a | 186 // NetErrorTabHelper uses |dns_probe_service| to send DNS probes when a |
| 183 // main frame load fails with a DNS error in order to provide more useful | 187 // main frame load fails with a DNS error in order to provide more useful |
| 184 // information to the renderer so it can show a more specific error page. | 188 // information to the renderer so it can show a more specific error page. |
| 185 scoped_ptr<chrome_browser_net::DnsProbeService> dns_probe_service; | 189 scoped_ptr<chrome_browser_net::DnsProbeService> dns_probe_service; |
| 186 scoped_ptr<data_reduction_proxy::DataReductionProxyParams> | 190 scoped_ptr<data_reduction_proxy::DataReductionProxyParams> |
| 187 data_reduction_proxy_params; | 191 data_reduction_proxy_params; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 216 // Clears the host cache. Intended to be used to prevent exposing recently | 220 // Clears the host cache. Intended to be used to prevent exposing recently |
| 217 // visited sites on about:net-internals/#dns and about:dns pages. Must be | 221 // visited sites on about:net-internals/#dns and about:dns pages. Must be |
| 218 // called on the IO thread. | 222 // called on the IO thread. |
| 219 void ClearHostCache(); | 223 void ClearHostCache(); |
| 220 | 224 |
| 221 void InitializeNetworkSessionParams(net::HttpNetworkSession::Params* params); | 225 void InitializeNetworkSessionParams(net::HttpNetworkSession::Params* params); |
| 222 | 226 |
| 223 base::TimeTicks creation_time() const; | 227 base::TimeTicks creation_time() const; |
| 224 | 228 |
| 225 private: | 229 private: |
| 230 // Map from name to value for all parameters associate with a field trial. |
| 231 typedef std::map<std::string, std::string> VariationParameters; |
| 232 |
| 226 // Provide SystemURLRequestContextGetter with access to | 233 // Provide SystemURLRequestContextGetter with access to |
| 227 // InitSystemRequestContext(). | 234 // InitSystemRequestContext(). |
| 228 friend class SystemURLRequestContextGetter; | 235 friend class SystemURLRequestContextGetter; |
| 229 | 236 |
| 237 friend class test::IOThreadPeer; |
| 238 |
| 230 // BrowserThreadDelegate implementation, runs on the IO thread. | 239 // BrowserThreadDelegate implementation, runs on the IO thread. |
| 231 // This handles initialization and destruction of state that must | 240 // This handles initialization and destruction of state that must |
| 232 // live on the IO thread. | 241 // live on the IO thread. |
| 233 virtual void Init() OVERRIDE; | 242 virtual void Init() OVERRIDE; |
| 234 virtual void InitAsync() OVERRIDE; | 243 virtual void InitAsync() OVERRIDE; |
| 235 virtual void CleanUp() OVERRIDE; | 244 virtual void CleanUp() OVERRIDE; |
| 236 | 245 |
| 246 // Initializes |params| based on the settings in |globals|. |
| 247 static void InitializeNetworkSessionParamsFromGlobals( |
| 248 const Globals& globals, |
| 249 net::HttpNetworkSession::Params* params); |
| 250 |
| 237 void InitializeNetworkOptions(const base::CommandLine& parsed_command_line); | 251 void InitializeNetworkOptions(const base::CommandLine& parsed_command_line); |
| 238 | 252 |
| 239 // Enable SPDY with the given mode, which may contain the following: | 253 // Enable SPDY with the given mode, which may contain the following: |
| 240 // | 254 // |
| 241 // "off" : Disables SPDY support entirely. | 255 // "off" : Disables SPDY support entirely. |
| 242 // "ssl" : Forces SPDY for all HTTPS requests. | 256 // "ssl" : Forces SPDY for all HTTPS requests. |
| 243 // "no-ssl" : Forces SPDY for all HTTP requests. | 257 // "no-ssl" : Forces SPDY for all HTTP requests. |
| 244 // "no-ping" : Disables SPDY ping connection testing. | 258 // "no-ping" : Disables SPDY ping connection testing. |
| 245 // "exclude=<host>" : Disables SPDY support for the host <host>. | 259 // "exclude=<host>" : Disables SPDY support for the host <host>. |
| 246 // "no-compress" : Disables SPDY header compression. | 260 // "no-compress" : Disables SPDY header compression. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 270 net::SSLConfigService* GetSSLConfigService(); | 284 net::SSLConfigService* GetSSLConfigService(); |
| 271 | 285 |
| 272 void ChangedToOnTheRecordOnIOThread(); | 286 void ChangedToOnTheRecordOnIOThread(); |
| 273 | 287 |
| 274 void UpdateDnsClientEnabled(); | 288 void UpdateDnsClientEnabled(); |
| 275 | 289 |
| 276 // Configures QUIC options based on the flags in |command_line| as | 290 // Configures QUIC options based on the flags in |command_line| as |
| 277 // well as the QUIC field trial group. | 291 // well as the QUIC field trial group. |
| 278 void ConfigureQuic(const base::CommandLine& command_line); | 292 void ConfigureQuic(const base::CommandLine& command_line); |
| 279 | 293 |
| 294 // Configures QUIC options in |globals| based on the flags in |command_line| |
| 295 // as well as the QUIC field trial group and parameters. |
| 296 static void ConfigureQuicGlobals( |
| 297 const base::CommandLine& command_line, |
| 298 base::StringPiece quic_trial_group, |
| 299 const VariationParameters& quic_trial_params, |
| 300 Globals* globals); |
| 301 |
| 280 // Returns true if QUIC should be enabled, either as a result | 302 // Returns true if QUIC should be enabled, either as a result |
| 281 // of a field trial or a command line flag. | 303 // of a field trial or a command line flag. |
| 282 bool ShouldEnableQuic(const base::CommandLine& command_line, | 304 static bool ShouldEnableQuic( |
| 283 base::StringPiece quic_trial_group); | 305 const base::CommandLine& command_line, |
| 306 base::StringPiece quic_trial_group); |
| 284 | 307 |
| 285 // Returns true if the selection of the ephemeral port in bind() should be | 308 // Returns true if the selection of the ephemeral port in bind() should be |
| 286 // performed by Chromium, and false if the OS should select the port. The OS | 309 // performed by Chromium, and false if the OS should select the port. The OS |
| 287 // option is used to prevent Windows from posting a security security warning | 310 // option is used to prevent Windows from posting a security security warning |
| 288 // dialog. | 311 // dialog. |
| 289 bool ShouldEnableQuicPortSelection(const base::CommandLine& command_line); | 312 static bool ShouldEnableQuicPortSelection( |
| 313 const base::CommandLine& command_line); |
| 290 | 314 |
| 291 // Returns true if QUIC packet pacing should be negotiated during the | 315 // Returns true if QUIC packet pacing should be negotiated during the |
| 292 // QUIC handshake. | 316 // QUIC handshake. |
| 293 bool ShouldEnableQuicPacing(const base::CommandLine& command_line, | 317 static bool ShouldEnableQuicPacing( |
| 294 base::StringPiece quic_trial_group); | 318 const base::CommandLine& command_line, |
| 319 base::StringPiece quic_trial_group, |
| 320 const VariationParameters& quic_trial_params); |
| 295 | 321 |
| 296 // Returns true if QUIC time-base loss detection should be negotiated during | 322 // Returns true if QUIC time-base loss detection should be negotiated during |
| 297 // the QUIC handshake. | 323 // the QUIC handshake. |
| 298 bool ShouldEnableQuicTimeBasedLossDetection( | 324 static bool ShouldEnableQuicTimeBasedLossDetection( |
| 299 const base::CommandLine& command_line, | 325 const base::CommandLine& command_line, |
| 300 base::StringPiece quic_trial_group); | 326 base::StringPiece quic_trial_group, |
| 301 | 327 const VariationParameters& quic_trial_params); |
| 302 // Returns true if Chromium should persist QUIC server config information to | |
| 303 // disk cache. | |
| 304 bool ShouldEnableQuicPersistServerInfo(const base::CommandLine& command_line); | |
| 305 | 328 |
| 306 // Returns the maximum length for QUIC packets, based on any flags in | 329 // Returns the maximum length for QUIC packets, based on any flags in |
| 307 // |command_line| or the field trial. Returns 0 if there is an error | 330 // |command_line| or the field trial. Returns 0 if there is an error |
| 308 // parsing any of the options, or if the default value should be used. | 331 // parsing any of the options, or if the default value should be used. |
| 309 size_t GetQuicMaxPacketLength(const base::CommandLine& command_line, | 332 static size_t GetQuicMaxPacketLength( |
| 310 base::StringPiece quic_trial_group); | 333 const base::CommandLine& command_line, |
| 334 base::StringPiece quic_trial_group, |
| 335 const VariationParameters& quic_trial_params); |
| 311 | 336 |
| 312 // Returns the quic versions specified by any flags in |command_line|. | 337 // Returns the QUIC versions specified by any flags in |command_line| |
| 313 net::QuicVersion GetQuicVersion(const base::CommandLine& command_line); | 338 // or |quic_trial_params|. |
| 339 static net::QuicVersion GetQuicVersion( |
| 340 const base::CommandLine& command_line, |
| 341 const VariationParameters& quic_trial_params); |
| 342 |
| 343 // Returns the QUIC version specified by |quic_version| or |
| 344 // QUIC_VERSION_UNSUPPORTED if |quic_version| is invalid. |
| 345 static net::QuicVersion ParseQuicVersion(const std::string& quic_version); |
| 346 |
| 347 // Returns the QUIC connection options specified by any flags in |
| 348 // |command_line| or |quic_trial_params|. |
| 349 static net::QuicTagVector GetQuicConnectionOptions( |
| 350 const base::CommandLine& command_line, |
| 351 const VariationParameters& quic_trial_params); |
| 352 |
| 353 // Returns the list of QUIC tags represented by the comma separated |
| 354 // string in |connection_options|. |
| 355 static net::QuicTagVector ParseQuicConnectionOptions( |
| 356 const std::string& connection_options); |
| 314 | 357 |
| 315 // The NetLog is owned by the browser process, to allow logging from other | 358 // The NetLog is owned by the browser process, to allow logging from other |
| 316 // threads during shutdown, but is used most frequently on the IOThread. | 359 // threads during shutdown, but is used most frequently on the IOThread. |
| 317 ChromeNetLog* net_log_; | 360 ChromeNetLog* net_log_; |
| 318 | 361 |
| 319 // The extensions::EventRouterForwarder allows for sending events to | 362 // The extensions::EventRouterForwarder allows for sending events to |
| 320 // extensions from the IOThread. | 363 // extensions from the IOThread. |
| 321 extensions::EventRouterForwarder* extension_event_router_forwarder_; | 364 extensions::EventRouterForwarder* extension_event_router_forwarder_; |
| 322 | 365 |
| 323 // These member variables are basically global, but their lifetimes are tied | 366 // These member variables are basically global, but their lifetimes are tied |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 bool is_spdy_disabled_by_policy_; | 408 bool is_spdy_disabled_by_policy_; |
| 366 | 409 |
| 367 base::WeakPtrFactory<IOThread> weak_factory_; | 410 base::WeakPtrFactory<IOThread> weak_factory_; |
| 368 | 411 |
| 369 const base::TimeTicks creation_time_; | 412 const base::TimeTicks creation_time_; |
| 370 | 413 |
| 371 DISALLOW_COPY_AND_ASSIGN(IOThread); | 414 DISALLOW_COPY_AND_ASSIGN(IOThread); |
| 372 }; | 415 }; |
| 373 | 416 |
| 374 #endif // CHROME_BROWSER_IO_THREAD_H_ | 417 #endif // CHROME_BROWSER_IO_THREAD_H_ |
| OLD | NEW |