Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Side by Side Diff: chrome/browser/io_thread.h

Issue 1892123003: Add components/network_session_configurator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase on https://crrev.com/1945513002. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/io_thread.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 18 matching lines...) Expand all
29 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
30 #include "content/public/browser/browser_thread_delegate.h" 30 #include "content/public/browser/browser_thread_delegate.h"
31 #include "net/base/network_change_notifier.h" 31 #include "net/base/network_change_notifier.h"
32 #include "net/http/http_network_session.h" 32 #include "net/http/http_network_session.h"
33 33
34 class PrefProxyConfigTracker; 34 class PrefProxyConfigTracker;
35 class PrefService; 35 class PrefService;
36 class PrefRegistrySimple; 36 class PrefRegistrySimple;
37 class SystemURLRequestContextGetter; 37 class SystemURLRequestContextGetter;
38 38
39 namespace base {
40 class CommandLine;
41 }
42
43 #if BUILDFLAG(ANDROID_JAVA_UI) 39 #if BUILDFLAG(ANDROID_JAVA_UI)
44 namespace chrome { 40 namespace chrome {
45 namespace android { 41 namespace android {
46 class ExternalDataUseObserver; 42 class ExternalDataUseObserver;
47 } 43 }
48 } 44 }
49 #endif // BUILDFLAG(ANDROID_JAVA_UI) 45 #endif // BUILDFLAG(ANDROID_JAVA_UI)
50 46
51 namespace chrome_browser_net { 47 namespace chrome_browser_net {
52 class DnsProbeService; 48 class DnsProbeService;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 178
183 // NetErrorTabHelper uses |dns_probe_service| to send DNS probes when a 179 // NetErrorTabHelper uses |dns_probe_service| to send DNS probes when a
184 // main frame load fails with a DNS error in order to provide more useful 180 // main frame load fails with a DNS error in order to provide more useful
185 // information to the renderer so it can show a more specific error page. 181 // information to the renderer so it can show a more specific error page.
186 std::unique_ptr<chrome_browser_net::DnsProbeService> dns_probe_service; 182 std::unique_ptr<chrome_browser_net::DnsProbeService> dns_probe_service;
187 183
188 // Enables Brotli Content-Encoding support 184 // Enables Brotli Content-Encoding support
189 bool enable_brotli; 185 bool enable_brotli;
190 }; 186 };
191 187
192 // Helper class to configure HttpNetworkSession::Params and
193 // HttpServerProperties based on field trials, policy, and command line.
194 class NetworkSessionConfigurator {
195 public:
196 // Configure |params| based on field trials and policy arguments.
197 static void ParseFieldTrials(bool is_spdy_allowed_by_policy,
198 bool is_quic_allowed_by_policy,
199 net::HttpNetworkSession::Params* params);
200
201 // Configure |params| based on field trials, policy arguments,
202 // and command line.
203 static void ParseFieldTrialsAndCommandLine(
204 bool is_spdy_allowed_by_policy,
205 bool is_quic_allowed_by_policy,
206 net::HttpNetworkSession::Params* params);
207
208 private:
209 // Map from name to value for all parameters associate with a field trial.
210 using VariationParameters = std::map<std::string, std::string>;
211
212 static void ParseFieldTrialsAndCommandLineInternal(
213 const base::CommandLine& command_line,
214 bool is_spdy_allowed_by_policy,
215 bool is_quic_allowed_by_policy,
216 net::HttpNetworkSession::Params* params);
217
218 // Configures Alternative Services based on command line options and the
219 // field trial group.
220 static void ConfigureAltSvcParams(const base::CommandLine& command_line,
221 base::StringPiece altsvc_trial_group,
222 net::HttpNetworkSession::Params* params);
223
224 // Configures QUIC options based on the flags in |command_line| as well as
225 // the QUIC field trial group and parameters. Must be called before
226 // ConfigureSpdyParams.
227 static void ConfigureQuicParams(
228 const base::CommandLine& command_line,
229 base::StringPiece quic_trial_group,
230 const VariationParameters& quic_trial_params,
231 bool is_quic_allowed_by_policy,
232 net::HttpNetworkSession::Params* params);
233
234 // Configures available SPDY protocol versions and parameters based on
235 // command line flags as well as SPDY field trial group and parameters.
236 // Must be called after ConfigureQuicParams.
237 static void ConfigureSpdyParams(
238 const base::CommandLine& command_line,
239 base::StringPiece spdy_trial_group,
240 const VariationParameters& spdy_trial_params,
241 bool is_spdy_allowed_by_policy,
242 net::HttpNetworkSession::Params* params);
243
244 // Configure TCP FastOpen based on the field trial group.
245 static void ConfigureTCPFastOpenParams(
246 base::StringPiece tfo_trial_group,
247 net::HttpNetworkSession::Params* params);
248
249 // Configures NPN based on command line and the field trial group.
250 static void ConfigureNPNParams(const base::CommandLine& command_line,
251 base::StringPiece npn_trial_group,
252 net::HttpNetworkSession::Params* params);
253
254 // Configures the use of priority dependencies based on the field trial
255 // group.
256 static void ConfigurePriorityDependencies(
257 base::StringPiece priority_dependencies_trial_group,
258 net::HttpNetworkSession::Params* params);
259
260 // Returns true if QUIC should be disabled when a connection times out with
261 // open streams.
262 static bool ShouldDisableQuicWhenConnectionTimesOutWithOpenStreams(
263 const VariationParameters& quic_trial_params);
264
265 // Returns true if QUIC should be enabled, either as a result of a field
266 // trial or a command line flag.
267 static bool ShouldEnableQuic(const base::CommandLine& command_line,
268 base::StringPiece quic_trial_group,
269 bool quic_allowed_by_policy);
270
271 // Returns true if the selection of the ephemeral port in bind() should be
272 // performed by Chromium, and false if the OS should select the port. The
273 // OS option is used to prevent Windows from posting a security warning
274 // dialog.
275 static bool ShouldEnableQuicPortSelection(
276 const base::CommandLine& command_line);
277
278 // Returns true if QUIC should always require handshake confirmation during
279 // the QUIC handshake.
280 static bool ShouldQuicAlwaysRequireHandshakeConfirmation(
281 const VariationParameters& quic_trial_params);
282
283 // Returns true if QUIC should disable connection pooling.
284 static bool ShouldQuicDisableConnectionPooling(
285 const VariationParameters& quic_trial_params);
286
287 // Returns the ratio of time to load QUIC sever information from disk cache
288 // to 'smoothed RTT' based on field trial. Returns 0 if there is an error
289 // parsing the field trial params, or if the default value should be used.
290 static float GetQuicLoadServerInfoTimeoutSrttMultiplier(
291 const VariationParameters& quic_trial_params);
292
293 // Returns true if QUIC's connection racing should be enabled.
294 static bool ShouldQuicEnableConnectionRacing(
295 const VariationParameters& quic_trial_params);
296
297 // Returns true if QUIC's should use non-blocking IO.
298 static bool ShouldQuicEnableNonBlockingIO(
299 const VariationParameters& quic_trial_params);
300
301 // Returns true if QUIC shouldn't load QUIC server information from the disk
302 // cache.
303 static bool ShouldQuicDisableDiskCache(
304 const VariationParameters& quic_trial_params);
305
306 // Returns true if QUIC should prefer AES-GCN even without hardware support.
307 static bool ShouldQuicPreferAes(
308 const VariationParameters& quic_trial_params);
309
310 // Returns true if QUIC should enable alternative services for different
311 // host.
312 static bool ShouldQuicEnableAlternativeServicesForDifferentHost(
313 const base::CommandLine& command_line,
314 const VariationParameters& quic_trial_params);
315
316 // Returns the maximum number of QUIC connections with high packet loss in a
317 // row after which QUIC should be disabled. Returns 0 if the default value
318 // should be used.
319 static int GetQuicMaxNumberOfLossyConnections(
320 const VariationParameters& quic_trial_params);
321
322 // Returns the packet loss rate in fraction after which a QUIC connection is
323 // closed and is considered as a lossy connection. Returns 0 if the default
324 // value should be used.
325 static float GetQuicPacketLossThreshold(
326 const VariationParameters& quic_trial_params);
327
328 // Returns the size of the QUIC receive buffer to use, or 0 if the default
329 // should be used.
330 static int GetQuicSocketReceiveBufferSize(
331 const VariationParameters& quic_trial_params);
332
333 // Returns true if QUIC should delay TCP connection when QUIC works.
334 static bool ShouldQuicDelayTcpRace(
335 const VariationParameters& quic_trial_params);
336
337 // Returns true if QUIC should close sessions when any of the client's IP
338 // addresses change.
339 static bool ShouldQuicCloseSessionsOnIpChange(
340 const VariationParameters& quic_trial_params);
341
342 // Returns the idle connection timeout for QUIC connections. Returns 0 if
343 // there is an error parsing any of the options, or if the default value
344 // should be used.
345 static int GetQuicIdleConnectionTimeoutSeconds(
346 const VariationParameters& quic_trial_params);
347
348 // Returns true if PreConnect should be disabled if QUIC can do 0RTT.
349 static bool ShouldQuicDisablePreConnectIfZeroRtt(
350 const VariationParameters& quic_trial_params);
351
352 // Returns the set of hosts to whitelist for QUIC.
353 static std::unordered_set<std::string> GetQuicHostWhitelist(
354 const base::CommandLine& command_line,
355 const VariationParameters& quic_trial_params);
356
357 // Returns true if QUIC should migrate sessions when primary network
358 // changes.
359 static bool ShouldQuicMigrateSessionsOnNetworkChange(
360 const VariationParameters& quic_trial_params);
361
362 // Returns true if QUIC should migrate sessions early.
363 static bool ShouldQuicMigrateSessionsEarly(
364 const VariationParameters& quic_trial_params);
365
366 // Returns the maximum length for QUIC packets, based on any flags in
367 // |command_line| or the field trial. Returns 0 if there is an error
368 // parsing any of the options, or if the default value should be used.
369 static size_t GetQuicMaxPacketLength(
370 const base::CommandLine& command_line,
371 const VariationParameters& quic_trial_params);
372
373 // Returns the QUIC versions specified by any flags in |command_line| or
374 // |quic_trial_params|.
375 static net::QuicVersion GetQuicVersion(
376 const base::CommandLine& command_line,
377 const VariationParameters& quic_trial_params);
378
379 // Returns the QUIC version specified by |quic_version| or
380 // QUIC_VERSION_UNSUPPORTED if |quic_version| is invalid.
381 static net::QuicVersion ParseQuicVersion(const std::string& quic_version);
382
383 // Returns the QUIC connection options specified by any flags in
384 // |command_line| or |quic_trial_params|.
385 static net::QuicTagVector GetQuicConnectionOptions(
386 const base::CommandLine& command_line,
387 const VariationParameters& quic_trial_params);
388 };
389
390 // |net_log| must either outlive the IOThread or be NULL. 188 // |net_log| must either outlive the IOThread or be NULL.
391 IOThread(PrefService* local_state, 189 IOThread(PrefService* local_state,
392 policy::PolicyService* policy_service, 190 policy::PolicyService* policy_service,
393 net_log::ChromeNetLog* net_log, 191 net_log::ChromeNetLog* net_log,
394 extensions::EventRouterForwarder* extension_event_router_forwarder); 192 extensions::EventRouterForwarder* extension_event_router_forwarder);
395 193
396 ~IOThread() override; 194 ~IOThread() override;
397 195
398 static void RegisterPrefs(PrefRegistrySimple* registry); 196 static void RegisterPrefs(PrefRegistrySimple* registry);
399 197
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 friend class SystemURLRequestContextGetter; 229 friend class SystemURLRequestContextGetter;
432 230
433 friend class test::IOThreadPeer; 231 friend class test::IOThreadPeer;
434 232
435 // BrowserThreadDelegate implementation, runs on the IO thread. 233 // BrowserThreadDelegate implementation, runs on the IO thread.
436 // This handles initialization and destruction of state that must 234 // This handles initialization and destruction of state that must
437 // live on the IO thread. 235 // live on the IO thread.
438 void Init() override; 236 void Init() override;
439 void CleanUp() override; 237 void CleanUp() override;
440 238
441 void InitializeNetworkOptions(const base::CommandLine& parsed_command_line);
442
443 // Global state must be initialized on the IO thread, then this 239 // Global state must be initialized on the IO thread, then this
444 // method must be invoked on the UI thread. 240 // method must be invoked on the UI thread.
445 void InitSystemRequestContext(); 241 void InitSystemRequestContext();
446 242
447 // Lazy initialization of system request context for 243 // Lazy initialization of system request context for
448 // SystemURLRequestContextGetter. To be called on IO thread only 244 // SystemURLRequestContextGetter. To be called on IO thread only
449 // after global state has been initialized on the IO thread, and 245 // after global state has been initialized on the IO thread, and
450 // SystemRequestContext state has been initialized on the UI thread. 246 // SystemRequestContext state has been initialized on the UI thread.
451 void InitSystemRequestContextOnIOThread(); 247 void InitSystemRequestContextOnIOThread();
452 248
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 // to the IOThread. IOThread owns them all, despite not using scoped_ptr. 294 // to the IOThread. IOThread owns them all, despite not using scoped_ptr.
499 // This is because the destructor of IOThread runs on the wrong thread. All 295 // This is because the destructor of IOThread runs on the wrong thread. All
500 // member variables should be deleted in CleanUp(). 296 // member variables should be deleted in CleanUp().
501 297
502 // These member variables are initialized in Init() and do not change for the 298 // These member variables are initialized in Init() and do not change for the
503 // lifetime of the IO thread. 299 // lifetime of the IO thread.
504 300
505 Globals* globals_; 301 Globals* globals_;
506 302
507 net::HttpNetworkSession::Params params_; 303 net::HttpNetworkSession::Params params_;
508 NetworkSessionConfigurator network_session_configurator_;
509 304
510 // Observer that logs network changes to the ChromeNetLog. 305 // Observer that logs network changes to the ChromeNetLog.
511 std::unique_ptr<net::LoggingNetworkChangeObserver> network_change_observer_; 306 std::unique_ptr<net::LoggingNetworkChangeObserver> network_change_observer_;
512 307
513 BooleanPrefMember system_enable_referrers_; 308 BooleanPrefMember system_enable_referrers_;
514 309
515 BooleanPrefMember dns_client_enabled_; 310 BooleanPrefMember dns_client_enabled_;
516 311
517 BooleanPrefMember quick_check_enabled_; 312 BooleanPrefMember quick_check_enabled_;
518 313
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 // Callback for updating data use prefs which needs to be initialized on UI 355 // Callback for updating data use prefs which needs to be initialized on UI
561 // thread and passed to |ChromeNetworkDelegate|. 356 // thread and passed to |ChromeNetworkDelegate|.
562 metrics::UpdateUsagePrefCallbackType metrics_data_use_forwarder_; 357 metrics::UpdateUsagePrefCallbackType metrics_data_use_forwarder_;
563 358
564 base::WeakPtrFactory<IOThread> weak_factory_; 359 base::WeakPtrFactory<IOThread> weak_factory_;
565 360
566 DISALLOW_COPY_AND_ASSIGN(IOThread); 361 DISALLOW_COPY_AND_ASSIGN(IOThread);
567 }; 362 };
568 363
569 #endif // CHROME_BROWSER_IO_THREAD_H_ 364 #endif // CHROME_BROWSER_IO_THREAD_H_
OLDNEW
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/io_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698