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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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: |
226 // Provide SystemURLRequestContextGetter with access to | 230 // Provide SystemURLRequestContextGetter with access to |
227 // InitSystemRequestContext(). | 231 // InitSystemRequestContext(). |
228 friend class SystemURLRequestContextGetter; | 232 friend class SystemURLRequestContextGetter; |
229 | 233 |
234 friend class test::IOThreadPeer; | |
235 | |
230 // BrowserThreadDelegate implementation, runs on the IO thread. | 236 // BrowserThreadDelegate implementation, runs on the IO thread. |
231 // This handles initialization and destruction of state that must | 237 // This handles initialization and destruction of state that must |
232 // live on the IO thread. | 238 // live on the IO thread. |
233 virtual void Init() OVERRIDE; | 239 virtual void Init() OVERRIDE; |
234 virtual void InitAsync() OVERRIDE; | 240 virtual void InitAsync() OVERRIDE; |
235 virtual void CleanUp() OVERRIDE; | 241 virtual void CleanUp() OVERRIDE; |
236 | 242 |
243 // Initializes |params| based on the settings in |globals|. | |
244 static void InitializeNetworkSessionParamsFromGlobals( | |
245 const Globals& globals, | |
246 net::HttpNetworkSession::Params* params); | |
247 | |
237 void InitializeNetworkOptions(const base::CommandLine& parsed_command_line); | 248 void InitializeNetworkOptions(const base::CommandLine& parsed_command_line); |
238 | 249 |
239 // Enable SPDY with the given mode, which may contain the following: | 250 // Enable SPDY with the given mode, which may contain the following: |
240 // | 251 // |
241 // "off" : Disables SPDY support entirely. | 252 // "off" : Disables SPDY support entirely. |
242 // "ssl" : Forces SPDY for all HTTPS requests. | 253 // "ssl" : Forces SPDY for all HTTPS requests. |
243 // "no-ssl" : Forces SPDY for all HTTP requests. | 254 // "no-ssl" : Forces SPDY for all HTTP requests. |
244 // "no-ping" : Disables SPDY ping connection testing. | 255 // "no-ping" : Disables SPDY ping connection testing. |
245 // "exclude=<host>" : Disables SPDY support for the host <host>. | 256 // "exclude=<host>" : Disables SPDY support for the host <host>. |
246 // "no-compress" : Disables SPDY header compression. | 257 // "no-compress" : Disables SPDY header compression. |
(...skipping 23 matching lines...) Expand all Loading... | |
270 net::SSLConfigService* GetSSLConfigService(); | 281 net::SSLConfigService* GetSSLConfigService(); |
271 | 282 |
272 void ChangedToOnTheRecordOnIOThread(); | 283 void ChangedToOnTheRecordOnIOThread(); |
273 | 284 |
274 void UpdateDnsClientEnabled(); | 285 void UpdateDnsClientEnabled(); |
275 | 286 |
276 // Configures QUIC options based on the flags in |command_line| as | 287 // Configures QUIC options based on the flags in |command_line| as |
277 // well as the QUIC field trial group. | 288 // well as the QUIC field trial group. |
278 void ConfigureQuic(const base::CommandLine& command_line); | 289 void ConfigureQuic(const base::CommandLine& command_line); |
279 | 290 |
291 // Configures QUIC options in |globals| based on the flags in |command_line| | |
292 // as well as the QUIC field trial group and parameters. | |
293 static void ConfigureQuicGlobals( | |
294 const base::CommandLine& command_line, | |
295 base::StringPiece quic_trial_group, | |
jar (doing other things)
2014/06/20 23:25:12
nit: should this be a const ref?
I think it is un
Ryan Hamilton
2014/06/21 02:45:23
As I understand it, it's actually faster to pass i
| |
296 const std::map<std::string, std::string>& quic_trial_params, | |
297 Globals* globals); | |
298 | |
280 // Returns true if QUIC should be enabled, either as a result | 299 // Returns true if QUIC should be enabled, either as a result |
281 // of a field trial or a command line flag. | 300 // of a field trial or a command line flag. |
282 bool ShouldEnableQuic(const base::CommandLine& command_line, | 301 static bool ShouldEnableQuic( |
283 base::StringPiece quic_trial_group); | 302 const base::CommandLine& command_line, |
303 base::StringPiece quic_trial_group); | |
284 | 304 |
285 // Returns true if the selection of the ephemeral port in bind() should be | 305 // 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 | 306 // 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 | 307 // option is used to prevent Windows from posting a security security warning |
288 // dialog. | 308 // dialog. |
289 bool ShouldEnableQuicPortSelection(const base::CommandLine& command_line); | 309 static bool ShouldEnableQuicPortSelection( |
310 const base::CommandLine& command_line); | |
290 | 311 |
291 // Returns true if QUIC packet pacing should be negotiated during the | 312 // Returns true if QUIC packet pacing should be negotiated during the |
292 // QUIC handshake. | 313 // QUIC handshake. |
293 bool ShouldEnableQuicPacing(const base::CommandLine& command_line, | 314 static bool ShouldEnableQuicPacing( |
294 base::StringPiece quic_trial_group); | 315 const base::CommandLine& command_line, |
316 base::StringPiece quic_trial_group, | |
317 const std::map<std::string, std::string>& quic_trial_params); | |
295 | 318 |
296 // Returns true if QUIC time-base loss detection should be negotiated during | 319 // Returns true if QUIC time-base loss detection should be negotiated during |
297 // the QUIC handshake. | 320 // the QUIC handshake. |
298 bool ShouldEnableQuicTimeBasedLossDetection( | 321 static bool ShouldEnableQuicTimeBasedLossDetection( |
299 const base::CommandLine& command_line, | 322 const base::CommandLine& command_line, |
300 base::StringPiece quic_trial_group); | 323 base::StringPiece quic_trial_group, |
301 | 324 const std::map<std::string, std::string>& 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 | 325 |
306 // Returns the maximum length for QUIC packets, based on any flags in | 326 // 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 | 327 // |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. | 328 // parsing any of the options, or if the default value should be used. |
309 size_t GetQuicMaxPacketLength(const base::CommandLine& command_line, | 329 static size_t GetQuicMaxPacketLength( |
310 base::StringPiece quic_trial_group); | 330 const base::CommandLine& command_line, |
331 base::StringPiece quic_trial_group, | |
332 const std::map<std::string, std::string>& quic_trial_params); | |
311 | 333 |
312 // Returns the quic versions specified by any flags in |command_line|. | 334 // Returns the QUIC versions specified by any flags in |command_line| |
313 net::QuicVersion GetQuicVersion(const base::CommandLine& command_line); | 335 // or |quic_trial_params|. |
336 static net::QuicVersion GetQuicVersion( | |
337 const base::CommandLine& command_line, | |
338 const std::map<std::string, std::string>& quic_trial_params); | |
jar (doing other things)
2014/06/20 23:25:12
nit: I think it would be helpful to decide a typed
Ryan Hamilton
2014/06/21 02:45:23
Done. (Yeah, I wish there were such a typedef in t
| |
339 | |
340 // Returns the QUIC connection options specified by any flags in | |
341 // |command_line| or |quic_trial_params|. | |
342 static net::QuicTagVector GetQuicConnectionOptions( | |
343 const base::CommandLine& command_line, | |
344 const std::map<std::string, std::string>& quic_trial_params); | |
314 | 345 |
315 // The NetLog is owned by the browser process, to allow logging from other | 346 // 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. | 347 // threads during shutdown, but is used most frequently on the IOThread. |
317 ChromeNetLog* net_log_; | 348 ChromeNetLog* net_log_; |
318 | 349 |
319 // The extensions::EventRouterForwarder allows for sending events to | 350 // The extensions::EventRouterForwarder allows for sending events to |
320 // extensions from the IOThread. | 351 // extensions from the IOThread. |
321 extensions::EventRouterForwarder* extension_event_router_forwarder_; | 352 extensions::EventRouterForwarder* extension_event_router_forwarder_; |
322 | 353 |
323 // These member variables are basically global, but their lifetimes are tied | 354 // 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_; | 396 bool is_spdy_disabled_by_policy_; |
366 | 397 |
367 base::WeakPtrFactory<IOThread> weak_factory_; | 398 base::WeakPtrFactory<IOThread> weak_factory_; |
368 | 399 |
369 const base::TimeTicks creation_time_; | 400 const base::TimeTicks creation_time_; |
370 | 401 |
371 DISALLOW_COPY_AND_ASSIGN(IOThread); | 402 DISALLOW_COPY_AND_ASSIGN(IOThread); |
372 }; | 403 }; |
373 | 404 |
374 #endif // CHROME_BROWSER_IO_THREAD_H_ | 405 #endif // CHROME_BROWSER_IO_THREAD_H_ |
OLD | NEW |