| 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 <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 #include "components/prefs/pref_service.h" | 56 #include "components/prefs/pref_service.h" |
| 57 #include "components/proxy_config/pref_proxy_config_tracker.h" | 57 #include "components/proxy_config/pref_proxy_config_tracker.h" |
| 58 #include "components/variations/variations_associated_data.h" | 58 #include "components/variations/variations_associated_data.h" |
| 59 #include "components/version_info/version_info.h" | 59 #include "components/version_info/version_info.h" |
| 60 #include "content/public/browser/browser_thread.h" | 60 #include "content/public/browser/browser_thread.h" |
| 61 #include "content/public/browser/cookie_store_factory.h" | 61 #include "content/public/browser/cookie_store_factory.h" |
| 62 #include "content/public/common/content_features.h" | 62 #include "content/public/common/content_features.h" |
| 63 #include "content/public/common/content_switches.h" | 63 #include "content/public/common/content_switches.h" |
| 64 #include "content/public/common/user_agent.h" | 64 #include "content/public/common/user_agent.h" |
| 65 #include "net/base/host_mapping_rules.h" | 65 #include "net/base/host_mapping_rules.h" |
| 66 #include "net/base/logging_network_change_observer.h" |
| 66 #include "net/base/sdch_manager.h" | 67 #include "net/base/sdch_manager.h" |
| 67 #include "net/cert/cert_verifier.h" | 68 #include "net/cert/cert_verifier.h" |
| 68 #include "net/cert/cert_verify_proc.h" | 69 #include "net/cert/cert_verify_proc.h" |
| 69 #include "net/cert/ct_known_logs.h" | 70 #include "net/cert/ct_known_logs.h" |
| 70 #include "net/cert/ct_log_verifier.h" | 71 #include "net/cert/ct_log_verifier.h" |
| 71 #include "net/cert/ct_policy_enforcer.h" | 72 #include "net/cert/ct_policy_enforcer.h" |
| 72 #include "net/cert/ct_verifier.h" | 73 #include "net/cert/ct_verifier.h" |
| 73 #include "net/cert/multi_log_ct_verifier.h" | 74 #include "net/cert/multi_log_ct_verifier.h" |
| 74 #include "net/cert/multi_threaded_cert_verifier.h" | 75 #include "net/cert/multi_threaded_cert_verifier.h" |
| 75 #include "net/cookies/cookie_store.h" | 76 #include "net/cookies/cookie_store.h" |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 const std::string& key) { | 301 const std::string& key) { |
| 301 std::map<std::string, std::string>::const_iterator it = params.find(key); | 302 std::map<std::string, std::string>::const_iterator it = params.find(key); |
| 302 if (it == params.end()) | 303 if (it == params.end()) |
| 303 return base::EmptyString(); | 304 return base::EmptyString(); |
| 304 | 305 |
| 305 return it->second; | 306 return it->second; |
| 306 } | 307 } |
| 307 | 308 |
| 308 } // namespace | 309 } // namespace |
| 309 | 310 |
| 310 class IOThread::LoggingNetworkChangeObserver | |
| 311 : public net::NetworkChangeNotifier::IPAddressObserver, | |
| 312 public net::NetworkChangeNotifier::ConnectionTypeObserver, | |
| 313 public net::NetworkChangeNotifier::NetworkChangeObserver { | |
| 314 public: | |
| 315 // |net_log| must remain valid throughout our lifetime. | |
| 316 explicit LoggingNetworkChangeObserver(net::NetLog* net_log) | |
| 317 : net_log_(net_log) { | |
| 318 net::NetworkChangeNotifier::AddIPAddressObserver(this); | |
| 319 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); | |
| 320 net::NetworkChangeNotifier::AddNetworkChangeObserver(this); | |
| 321 } | |
| 322 | |
| 323 ~LoggingNetworkChangeObserver() override { | |
| 324 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); | |
| 325 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); | |
| 326 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); | |
| 327 } | |
| 328 | |
| 329 // NetworkChangeNotifier::IPAddressObserver implementation. | |
| 330 void OnIPAddressChanged() override { | |
| 331 VLOG(1) << "Observed a change to the network IP addresses"; | |
| 332 | |
| 333 net_log_->AddGlobalEntry(net::NetLog::TYPE_NETWORK_IP_ADDRESSES_CHANGED); | |
| 334 } | |
| 335 | |
| 336 // NetworkChangeNotifier::ConnectionTypeObserver implementation. | |
| 337 void OnConnectionTypeChanged( | |
| 338 net::NetworkChangeNotifier::ConnectionType type) override { | |
| 339 std::string type_as_string = | |
| 340 net::NetworkChangeNotifier::ConnectionTypeToString(type); | |
| 341 | |
| 342 VLOG(1) << "Observed a change to network connectivity state " | |
| 343 << type_as_string; | |
| 344 | |
| 345 net_log_->AddGlobalEntry( | |
| 346 net::NetLog::TYPE_NETWORK_CONNECTIVITY_CHANGED, | |
| 347 net::NetLog::StringCallback("new_connection_type", &type_as_string)); | |
| 348 } | |
| 349 | |
| 350 // NetworkChangeNotifier::NetworkChangeObserver implementation. | |
| 351 void OnNetworkChanged( | |
| 352 net::NetworkChangeNotifier::ConnectionType type) override { | |
| 353 std::string type_as_string = | |
| 354 net::NetworkChangeNotifier::ConnectionTypeToString(type); | |
| 355 | |
| 356 VLOG(1) << "Observed a network change to state " << type_as_string; | |
| 357 | |
| 358 net_log_->AddGlobalEntry( | |
| 359 net::NetLog::TYPE_NETWORK_CHANGED, | |
| 360 net::NetLog::StringCallback("new_connection_type", &type_as_string)); | |
| 361 } | |
| 362 | |
| 363 private: | |
| 364 net::NetLog* net_log_; | |
| 365 DISALLOW_COPY_AND_ASSIGN(LoggingNetworkChangeObserver); | |
| 366 }; | |
| 367 | |
| 368 class SystemURLRequestContextGetter : public net::URLRequestContextGetter { | 311 class SystemURLRequestContextGetter : public net::URLRequestContextGetter { |
| 369 public: | 312 public: |
| 370 explicit SystemURLRequestContextGetter(IOThread* io_thread); | 313 explicit SystemURLRequestContextGetter(IOThread* io_thread); |
| 371 | 314 |
| 372 // Implementation for net::UrlRequestContextGetter. | 315 // Implementation for net::UrlRequestContextGetter. |
| 373 net::URLRequestContext* GetURLRequestContext() override; | 316 net::URLRequestContext* GetURLRequestContext() override; |
| 374 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() | 317 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() |
| 375 const override; | 318 const override; |
| 376 | 319 |
| 377 protected: | 320 protected: |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); | 535 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); |
| 593 } | 536 } |
| 594 | 537 |
| 595 DCHECK(!globals_); | 538 DCHECK(!globals_); |
| 596 globals_ = new Globals; | 539 globals_ = new Globals; |
| 597 | 540 |
| 598 // Add an observer that will emit network change events to the ChromeNetLog. | 541 // Add an observer that will emit network change events to the ChromeNetLog. |
| 599 // Assuming NetworkChangeNotifier dispatches in FIFO order, we should be | 542 // Assuming NetworkChangeNotifier dispatches in FIFO order, we should be |
| 600 // logging the network change before other IO thread consumers respond to it. | 543 // logging the network change before other IO thread consumers respond to it. |
| 601 network_change_observer_.reset( | 544 network_change_observer_.reset( |
| 602 new LoggingNetworkChangeObserver(net_log_)); | 545 new net::LoggingNetworkChangeObserver(net_log_)); |
| 603 | 546 |
| 604 // Setup the HistogramWatcher to run on the IO thread. | 547 // Setup the HistogramWatcher to run on the IO thread. |
| 605 net::NetworkChangeNotifier::InitHistogramWatcher(); | 548 net::NetworkChangeNotifier::InitHistogramWatcher(); |
| 606 | 549 |
| 607 #if defined(ENABLE_EXTENSIONS) | 550 #if defined(ENABLE_EXTENSIONS) |
| 608 globals_->extension_event_router_forwarder = | 551 globals_->extension_event_router_forwarder = |
| 609 extension_event_router_forwarder_; | 552 extension_event_router_forwarder_; |
| 610 #endif | 553 #endif |
| 611 | 554 |
| 612 std::unique_ptr<data_usage::DataUseAmortizer> data_use_amortizer; | 555 std::unique_ptr<data_usage::DataUseAmortizer> data_use_amortizer; |
| (...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1786 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the | 1729 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the |
| 1787 // system URLRequestContext too. There's no reason this should be tied to a | 1730 // system URLRequestContext too. There's no reason this should be tied to a |
| 1788 // profile. | 1731 // profile. |
| 1789 return context; | 1732 return context; |
| 1790 } | 1733 } |
| 1791 | 1734 |
| 1792 const metrics::UpdateUsagePrefCallbackType& | 1735 const metrics::UpdateUsagePrefCallbackType& |
| 1793 IOThread::GetMetricsDataUseForwarder() { | 1736 IOThread::GetMetricsDataUseForwarder() { |
| 1794 return metrics_data_use_forwarder_; | 1737 return metrics_data_use_forwarder_; |
| 1795 } | 1738 } |
| OLD | NEW |