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 typedef std::map<std::string, std::string> VariationParameters; | |
Lei Zhang
2014/06/23 21:28:14
Can you briefly document what the key/value are?
Ryan Hamilton
2014/06/23 22:38:52
Done.
| |
231 | |
226 // Provide SystemURLRequestContextGetter with access to | 232 // Provide SystemURLRequestContextGetter with access to |
227 // InitSystemRequestContext(). | 233 // InitSystemRequestContext(). |
228 friend class SystemURLRequestContextGetter; | 234 friend class SystemURLRequestContextGetter; |
229 | 235 |
236 friend class test::IOThreadPeer; | |
237 | |
230 // BrowserThreadDelegate implementation, runs on the IO thread. | 238 // BrowserThreadDelegate implementation, runs on the IO thread. |
231 // This handles initialization and destruction of state that must | 239 // This handles initialization and destruction of state that must |
232 // live on the IO thread. | 240 // live on the IO thread. |
233 virtual void Init() OVERRIDE; | 241 virtual void Init() OVERRIDE; |
234 virtual void InitAsync() OVERRIDE; | 242 virtual void InitAsync() OVERRIDE; |
235 virtual void CleanUp() OVERRIDE; | 243 virtual void CleanUp() OVERRIDE; |
236 | 244 |
245 // Initializes |params| based on the settings in |globals|. | |
246 static void InitializeNetworkSessionParamsFromGlobals( | |
247 const Globals& globals, | |
248 net::HttpNetworkSession::Params* params); | |
249 | |
237 void InitializeNetworkOptions(const base::CommandLine& parsed_command_line); | 250 void InitializeNetworkOptions(const base::CommandLine& parsed_command_line); |
238 | 251 |
239 // Enable SPDY with the given mode, which may contain the following: | 252 // Enable SPDY with the given mode, which may contain the following: |
240 // | 253 // |
241 // "off" : Disables SPDY support entirely. | 254 // "off" : Disables SPDY support entirely. |
242 // "ssl" : Forces SPDY for all HTTPS requests. | 255 // "ssl" : Forces SPDY for all HTTPS requests. |
243 // "no-ssl" : Forces SPDY for all HTTP requests. | 256 // "no-ssl" : Forces SPDY for all HTTP requests. |
244 // "no-ping" : Disables SPDY ping connection testing. | 257 // "no-ping" : Disables SPDY ping connection testing. |
245 // "exclude=<host>" : Disables SPDY support for the host <host>. | 258 // "exclude=<host>" : Disables SPDY support for the host <host>. |
246 // "no-compress" : Disables SPDY header compression. | 259 // "no-compress" : Disables SPDY header compression. |
(...skipping 23 matching lines...) Expand all Loading... | |
270 net::SSLConfigService* GetSSLConfigService(); | 283 net::SSLConfigService* GetSSLConfigService(); |
271 | 284 |
272 void ChangedToOnTheRecordOnIOThread(); | 285 void ChangedToOnTheRecordOnIOThread(); |
273 | 286 |
274 void UpdateDnsClientEnabled(); | 287 void UpdateDnsClientEnabled(); |
275 | 288 |
276 // Configures QUIC options based on the flags in |command_line| as | 289 // Configures QUIC options based on the flags in |command_line| as |
277 // well as the QUIC field trial group. | 290 // well as the QUIC field trial group. |
278 void ConfigureQuic(const base::CommandLine& command_line); | 291 void ConfigureQuic(const base::CommandLine& command_line); |
279 | 292 |
293 // Configures QUIC options in |globals| based on the flags in |command_line| | |
294 // as well as the QUIC field trial group and parameters. | |
295 static void ConfigureQuicGlobals( | |
296 const base::CommandLine& command_line, | |
297 base::StringPiece quic_trial_group, | |
298 const VariationParameters& quic_trial_params, | |
299 Globals* globals); | |
300 | |
280 // Returns true if QUIC should be enabled, either as a result | 301 // Returns true if QUIC should be enabled, either as a result |
281 // of a field trial or a command line flag. | 302 // of a field trial or a command line flag. |
282 bool ShouldEnableQuic(const base::CommandLine& command_line, | 303 static bool ShouldEnableQuic( |
283 base::StringPiece quic_trial_group); | 304 const base::CommandLine& command_line, |
305 base::StringPiece quic_trial_group); | |
284 | 306 |
285 // Returns true if the selection of the ephemeral port in bind() should be | 307 // 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 | 308 // 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 | 309 // option is used to prevent Windows from posting a security security warning |
288 // dialog. | 310 // dialog. |
289 bool ShouldEnableQuicPortSelection(const base::CommandLine& command_line); | 311 static bool ShouldEnableQuicPortSelection( |
312 const base::CommandLine& command_line); | |
290 | 313 |
291 // Returns true if QUIC packet pacing should be negotiated during the | 314 // Returns true if QUIC packet pacing should be negotiated during the |
292 // QUIC handshake. | 315 // QUIC handshake. |
293 bool ShouldEnableQuicPacing(const base::CommandLine& command_line, | 316 static bool ShouldEnableQuicPacing( |
294 base::StringPiece quic_trial_group); | 317 const base::CommandLine& command_line, |
318 base::StringPiece quic_trial_group, | |
Lei Zhang
2014/06/23 21:28:14
base::StringPiece should be const ref, ditto elsew
Ryan Hamilton
2014/06/23 22:38:52
Hm. The internal copy of string_piece.h says:
//
Lei Zhang
2014/06/23 22:42:06
Ok, I should have read string_piece.h, but instead
| |
319 const VariationParameters& quic_trial_params); | |
295 | 320 |
296 // Returns true if QUIC time-base loss detection should be negotiated during | 321 // Returns true if QUIC time-base loss detection should be negotiated during |
297 // the QUIC handshake. | 322 // the QUIC handshake. |
298 bool ShouldEnableQuicTimeBasedLossDetection( | 323 static bool ShouldEnableQuicTimeBasedLossDetection( |
299 const base::CommandLine& command_line, | 324 const base::CommandLine& command_line, |
300 base::StringPiece quic_trial_group); | 325 base::StringPiece quic_trial_group, |
301 | 326 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 | 327 |
306 // Returns the maximum length for QUIC packets, based on any flags in | 328 // 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 | 329 // |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. | 330 // parsing any of the options, or if the default value should be used. |
309 size_t GetQuicMaxPacketLength(const base::CommandLine& command_line, | 331 static size_t GetQuicMaxPacketLength( |
310 base::StringPiece quic_trial_group); | 332 const base::CommandLine& command_line, |
333 base::StringPiece quic_trial_group, | |
334 const VariationParameters& quic_trial_params); | |
311 | 335 |
312 // Returns the quic versions specified by any flags in |command_line|. | 336 // Returns the QUIC versions specified by any flags in |command_line| |
313 net::QuicVersion GetQuicVersion(const base::CommandLine& command_line); | 337 // or |quic_trial_params|. |
338 static net::QuicVersion GetQuicVersion( | |
339 const base::CommandLine& command_line, | |
340 const VariationParameters& quic_trial_params); | |
341 | |
342 // Returns the QUIC version specified by |quic_version| or | |
343 // QUIC_VERSION_UNSUPPORTED if |quic_version| is invalid. | |
344 static net::QuicVersion ParseQuicVersion(const std::string& quic_version); | |
345 | |
346 // Returns the QUIC connection options specified by any flags in | |
347 // |command_line| or |quic_trial_params|. | |
348 static net::QuicTagVector GetQuicConnectionOptions( | |
349 const base::CommandLine& command_line, | |
350 const VariationParameters& quic_trial_params); | |
351 | |
352 // Returns the list of QUIC tags represented by the comma separated | |
353 // string in |connection_options|. | |
354 static net::QuicTagVector ParseQuicConnectionOptions( | |
355 const std::string& connection_options); | |
314 | 356 |
315 // The NetLog is owned by the browser process, to allow logging from other | 357 // 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. | 358 // threads during shutdown, but is used most frequently on the IOThread. |
317 ChromeNetLog* net_log_; | 359 ChromeNetLog* net_log_; |
318 | 360 |
319 // The extensions::EventRouterForwarder allows for sending events to | 361 // The extensions::EventRouterForwarder allows for sending events to |
320 // extensions from the IOThread. | 362 // extensions from the IOThread. |
321 extensions::EventRouterForwarder* extension_event_router_forwarder_; | 363 extensions::EventRouterForwarder* extension_event_router_forwarder_; |
322 | 364 |
323 // These member variables are basically global, but their lifetimes are tied | 365 // 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_; | 407 bool is_spdy_disabled_by_policy_; |
366 | 408 |
367 base::WeakPtrFactory<IOThread> weak_factory_; | 409 base::WeakPtrFactory<IOThread> weak_factory_; |
368 | 410 |
369 const base::TimeTicks creation_time_; | 411 const base::TimeTicks creation_time_; |
370 | 412 |
371 DISALLOW_COPY_AND_ASSIGN(IOThread); | 413 DISALLOW_COPY_AND_ASSIGN(IOThread); |
372 }; | 414 }; |
373 | 415 |
374 #endif // CHROME_BROWSER_IO_THREAD_H_ | 416 #endif // CHROME_BROWSER_IO_THREAD_H_ |
OLD | NEW |