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 #include "chrome/browser/io_thread.h" | 5 #include "chrome/browser/io_thread.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/debug/leak_tracker.h" | 14 #include "base/debug/leak_tracker.h" |
15 #include "base/debug/trace_event.h" | 15 #include "base/debug/trace_event.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/metrics/field_trial.h" | 17 #include "base/metrics/field_trial.h" |
18 #include "base/prefs/pref_registry_simple.h" | 18 #include "base/prefs/pref_registry_simple.h" |
19 #include "base/prefs/pref_service.h" | 19 #include "base/prefs/pref_service.h" |
20 #include "base/stl_util.h" | 20 #include "base/stl_util.h" |
21 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
22 #include "base/strings/string_split.h" | 22 #include "base/strings/string_split.h" |
23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
24 #include "base/threading/sequenced_worker_pool.h" | 24 #include "base/threading/sequenced_worker_pool.h" |
25 #include "base/threading/thread.h" | 25 #include "base/threading/thread.h" |
26 #include "base/threading/worker_pool.h" | 26 #include "base/threading/worker_pool.h" |
27 #include "base/time/time.h" | 27 #include "base/time/time.h" |
28 #include "build/build_config.h" | 28 #include "build/build_config.h" |
29 #include "chrome/browser/browser_process.h" | 29 #include "chrome/browser/browser_process.h" |
30 #include "chrome/browser/extensions/event_router_forwarder.h" | |
31 #include "chrome/browser/net/async_dns_field_trial.h" | 30 #include "chrome/browser/net/async_dns_field_trial.h" |
32 #include "chrome/browser/net/chrome_net_log.h" | 31 #include "chrome/browser/net/chrome_net_log.h" |
33 #include "chrome/browser/net/chrome_network_delegate.h" | 32 #include "chrome/browser/net/chrome_network_delegate.h" |
34 #include "chrome/browser/net/chrome_url_request_context.h" | 33 #include "chrome/browser/net/chrome_url_request_context.h" |
35 #include "chrome/browser/net/connect_interceptor.h" | 34 #include "chrome/browser/net/connect_interceptor.h" |
36 #include "chrome/browser/net/dns_probe_service.h" | 35 #include "chrome/browser/net/dns_probe_service.h" |
37 #include "chrome/browser/net/pref_proxy_config_tracker.h" | 36 #include "chrome/browser/net/pref_proxy_config_tracker.h" |
38 #include "chrome/browser/net/proxy_service_factory.h" | 37 #include "chrome/browser/net/proxy_service_factory.h" |
39 #include "chrome/common/chrome_content_client.h" | 38 #include "chrome/common/chrome_content_client.h" |
40 #include "chrome/common/chrome_switches.h" | 39 #include "chrome/common/chrome_switches.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 #include "net/url_request/static_http_user_agent_settings.h" | 74 #include "net/url_request/static_http_user_agent_settings.h" |
76 #include "net/url_request/url_fetcher.h" | 75 #include "net/url_request/url_fetcher.h" |
77 #include "net/url_request/url_request_job_factory_impl.h" | 76 #include "net/url_request/url_request_job_factory_impl.h" |
78 #include "net/url_request/url_request_throttler_manager.h" | 77 #include "net/url_request/url_request_throttler_manager.h" |
79 #include "url/url_constants.h" | 78 #include "url/url_constants.h" |
80 | 79 |
81 #if defined(ENABLE_CONFIGURATION_POLICY) | 80 #if defined(ENABLE_CONFIGURATION_POLICY) |
82 #include "policy/policy_constants.h" | 81 #include "policy/policy_constants.h" |
83 #endif | 82 #endif |
84 | 83 |
84 #if defined(ENABLE_EXTENSIONS) | |
85 #include "chrome/browser/extensions/event_router_forwarder.h" | |
86 #endif | |
87 | |
85 #if !defined(USE_OPENSSL) | 88 #if !defined(USE_OPENSSL) |
86 #include "net/cert/ct_log_verifier.h" | 89 #include "net/cert/ct_log_verifier.h" |
87 #include "net/cert/multi_log_ct_verifier.h" | 90 #include "net/cert/multi_log_ct_verifier.h" |
88 #endif | 91 #endif |
89 | 92 |
90 #if defined(USE_NSS) || defined(OS_IOS) | 93 #if defined(USE_NSS) || defined(OS_IOS) |
91 #include "net/ocsp/nss_ocsp.h" | 94 #include "net/ocsp/nss_ocsp.h" |
92 #endif | 95 #endif |
93 | 96 |
94 #if defined(OS_ANDROID) || defined(OS_IOS) | 97 #if defined(OS_ANDROID) || defined(OS_IOS) |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 IOThread::Globals::~Globals() {} | 439 IOThread::Globals::~Globals() {} |
437 | 440 |
438 // |local_state| is passed in explicitly in order to (1) reduce implicit | 441 // |local_state| is passed in explicitly in order to (1) reduce implicit |
439 // dependencies and (2) make IOThread more flexible for testing. | 442 // dependencies and (2) make IOThread more flexible for testing. |
440 IOThread::IOThread( | 443 IOThread::IOThread( |
441 PrefService* local_state, | 444 PrefService* local_state, |
442 policy::PolicyService* policy_service, | 445 policy::PolicyService* policy_service, |
443 ChromeNetLog* net_log, | 446 ChromeNetLog* net_log, |
444 extensions::EventRouterForwarder* extension_event_router_forwarder) | 447 extensions::EventRouterForwarder* extension_event_router_forwarder) |
445 : net_log_(net_log), | 448 : net_log_(net_log), |
449 #if defined(ENABLE_EXTENSIONS) | |
Ryan Sleevi
2014/07/16 20:23:44
Why do you #ifdef the member, but not the ctor par
Lei Zhang
2014/07/18 01:34:24
I considered #ifdefing the ctor, or adding a separ
| |
446 extension_event_router_forwarder_(extension_event_router_forwarder), | 450 extension_event_router_forwarder_(extension_event_router_forwarder), |
451 #endif | |
447 globals_(NULL), | 452 globals_(NULL), |
448 is_spdy_disabled_by_policy_(false), | 453 is_spdy_disabled_by_policy_(false), |
449 weak_factory_(this), | 454 weak_factory_(this), |
450 creation_time_(base::TimeTicks::Now()) { | 455 creation_time_(base::TimeTicks::Now()) { |
451 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); | 456 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); |
452 negotiate_disable_cname_lookup_ = local_state->GetBoolean( | 457 negotiate_disable_cname_lookup_ = local_state->GetBoolean( |
453 prefs::kDisableAuthNegotiateCnameLookup); | 458 prefs::kDisableAuthNegotiateCnameLookup); |
454 negotiate_enable_port_ = local_state->GetBoolean( | 459 negotiate_enable_port_ = local_state->GetBoolean( |
455 prefs::kEnableAuthNegotiatePort); | 460 prefs::kEnableAuthNegotiatePort); |
456 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist); | 461 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
555 | 560 |
556 // Add an observer that will emit network change events to the ChromeNetLog. | 561 // Add an observer that will emit network change events to the ChromeNetLog. |
557 // Assuming NetworkChangeNotifier dispatches in FIFO order, we should be | 562 // Assuming NetworkChangeNotifier dispatches in FIFO order, we should be |
558 // logging the network change before other IO thread consumers respond to it. | 563 // logging the network change before other IO thread consumers respond to it. |
559 network_change_observer_.reset( | 564 network_change_observer_.reset( |
560 new LoggingNetworkChangeObserver(net_log_)); | 565 new LoggingNetworkChangeObserver(net_log_)); |
561 | 566 |
562 // Setup the HistogramWatcher to run on the IO thread. | 567 // Setup the HistogramWatcher to run on the IO thread. |
563 net::NetworkChangeNotifier::InitHistogramWatcher(); | 568 net::NetworkChangeNotifier::InitHistogramWatcher(); |
564 | 569 |
570 #if defined(ENABLE_EXTENSIONS) | |
565 globals_->extension_event_router_forwarder = | 571 globals_->extension_event_router_forwarder = |
566 extension_event_router_forwarder_; | 572 extension_event_router_forwarder_; |
573 #endif | |
574 | |
567 ChromeNetworkDelegate* network_delegate = | 575 ChromeNetworkDelegate* network_delegate = |
568 new ChromeNetworkDelegate(extension_event_router_forwarder_, | 576 new ChromeNetworkDelegate( |
569 &system_enable_referrers_); | 577 #if defined(ENABLE_EXTENSIONS) |
578 extension_event_router_forwarder_, | |
Ryan Sleevi
2014/07/16 20:23:44
wrap this ala BrowserProcessImpl in a member acces
Lei Zhang
2014/07/18 01:34:24
Done.
| |
579 #else | |
580 NULL, | |
581 #endif | |
582 &system_enable_referrers_); | |
583 | |
570 if (command_line.HasSwitch(switches::kEnableClientHints)) | 584 if (command_line.HasSwitch(switches::kEnableClientHints)) |
571 network_delegate->SetEnableClientHints(); | 585 network_delegate->SetEnableClientHints(); |
586 | |
587 #if defined(ENABLE_EXTENSIONS) | |
572 if (command_line.HasSwitch(switches::kDisableExtensionsHttpThrottling)) | 588 if (command_line.HasSwitch(switches::kDisableExtensionsHttpThrottling)) |
573 network_delegate->NeverThrottleRequests(); | 589 network_delegate->NeverThrottleRequests(); |
590 #endif | |
591 | |
574 globals_->system_network_delegate.reset(network_delegate); | 592 globals_->system_network_delegate.reset(network_delegate); |
575 globals_->host_resolver = CreateGlobalHostResolver(net_log_); | 593 globals_->host_resolver = CreateGlobalHostResolver(net_log_); |
576 UpdateDnsClientEnabled(); | 594 UpdateDnsClientEnabled(); |
577 #if defined(OS_CHROMEOS) | 595 #if defined(OS_CHROMEOS) |
578 // Creates a CertVerifyProc that doesn't allow any profile-provided certs. | 596 // Creates a CertVerifyProc that doesn't allow any profile-provided certs. |
579 globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier( | 597 globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier( |
580 new chromeos::CertVerifyProcChromeOS())); | 598 new chromeos::CertVerifyProcChromeOS())); |
581 #else | 599 #else |
582 globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier( | 600 globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier( |
583 net::CertVerifyProc::CreateDefault())); | 601 net::CertVerifyProc::CreateDefault())); |
584 #endif | 602 #endif |
585 | 603 |
586 globals_->transport_security_state.reset(new net::TransportSecurityState()); | 604 globals_->transport_security_state.reset(new net::TransportSecurityState()); |
587 #if !defined(USE_OPENSSL) | 605 #if !defined(USE_OPENSSL) |
588 // For now, Certificate Transparency is only implemented for platforms | 606 // For now, Certificate Transparency is only implemented for platforms |
589 // that use NSS. | 607 // that use NSS. |
590 net::MultiLogCTVerifier* ct_verifier = new net::MultiLogCTVerifier(); | 608 net::MultiLogCTVerifier* ct_verifier = new net::MultiLogCTVerifier(); |
591 globals_->cert_transparency_verifier.reset(ct_verifier); | 609 globals_->cert_transparency_verifier.reset(ct_verifier); |
592 | 610 |
593 // Add built-in logs | 611 // Add built-in logs |
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1367 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); | 1385 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); |
1368 for (size_t i = 0; i < supported_versions.size(); ++i) { | 1386 for (size_t i = 0; i < supported_versions.size(); ++i) { |
1369 net::QuicVersion version = supported_versions[i]; | 1387 net::QuicVersion version = supported_versions[i]; |
1370 if (net::QuicVersionToString(version) == quic_version) { | 1388 if (net::QuicVersionToString(version) == quic_version) { |
1371 return version; | 1389 return version; |
1372 } | 1390 } |
1373 } | 1391 } |
1374 | 1392 |
1375 return net::QUIC_VERSION_UNSUPPORTED; | 1393 return net::QUIC_VERSION_UNSUPPORTED; |
1376 } | 1394 } |
OLD | NEW |