| 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 29 matching lines...) Expand all Loading... |
| 40 #include "chrome/browser/net/proxy_service_factory.h" | 40 #include "chrome/browser/net/proxy_service_factory.h" |
| 41 #include "chrome/common/channel_info.h" | 41 #include "chrome/common/channel_info.h" |
| 42 #include "chrome/common/chrome_content_client.h" | 42 #include "chrome/common/chrome_content_client.h" |
| 43 #include "chrome/common/chrome_switches.h" | 43 #include "chrome/common/chrome_switches.h" |
| 44 #include "chrome/common/pref_names.h" | 44 #include "chrome/common/pref_names.h" |
| 45 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref
s.h" | 45 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref
s.h" |
| 46 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" | 46 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" |
| 47 #include "components/data_usage/core/data_use_aggregator.h" | 47 #include "components/data_usage/core/data_use_aggregator.h" |
| 48 #include "components/data_usage/core/data_use_amortizer.h" | 48 #include "components/data_usage/core/data_use_amortizer.h" |
| 49 #include "components/data_usage/core/data_use_annotator.h" | 49 #include "components/data_usage/core/data_use_annotator.h" |
| 50 #include "components/metrics/metrics_service.h" |
| 50 #include "components/net_log/chrome_net_log.h" | 51 #include "components/net_log/chrome_net_log.h" |
| 51 #include "components/policy/core/common/policy_service.h" | 52 #include "components/policy/core/common/policy_service.h" |
| 52 #include "components/prefs/pref_registry_simple.h" | 53 #include "components/prefs/pref_registry_simple.h" |
| 53 #include "components/prefs/pref_service.h" | 54 #include "components/prefs/pref_service.h" |
| 54 #include "components/proxy_config/pref_proxy_config_tracker.h" | 55 #include "components/proxy_config/pref_proxy_config_tracker.h" |
| 55 #include "components/variations/variations_associated_data.h" | 56 #include "components/variations/variations_associated_data.h" |
| 56 #include "components/version_info/version_info.h" | 57 #include "components/version_info/version_info.h" |
| 57 #include "content/public/browser/browser_thread.h" | 58 #include "content/public/browser/browser_thread.h" |
| 58 #include "content/public/browser/cookie_store_factory.h" | 59 #include "content/public/browser/cookie_store_factory.h" |
| 59 #include "content/public/common/content_features.h" | 60 #include "content/public/common/content_features.h" |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 is_spdy_disabled_by_policy_ = policy_service->GetPolicies( | 502 is_spdy_disabled_by_policy_ = policy_service->GetPolicies( |
| 502 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())).Get( | 503 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())).Get( |
| 503 policy::key::kDisableSpdy) != NULL; | 504 policy::key::kDisableSpdy) != NULL; |
| 504 | 505 |
| 505 const base::Value* value = policy_service->GetPolicies( | 506 const base::Value* value = policy_service->GetPolicies( |
| 506 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, | 507 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, |
| 507 std::string())).GetValue(policy::key::kQuicAllowed); | 508 std::string())).GetValue(policy::key::kQuicAllowed); |
| 508 if (value) | 509 if (value) |
| 509 value->GetAsBoolean(&is_quic_allowed_by_policy_); | 510 value->GetAsBoolean(&is_quic_allowed_by_policy_); |
| 510 | 511 |
| 512 // Some unit tests use IOThread but do not initialize MetricsService. In that |
| 513 // case it is fine not to have |metrics_data_use_forwarder_|. |
| 514 if (g_browser_process->metrics_service()) { |
| 515 // Callback for updating data use prefs should be obtained on UI thread. |
| 516 metrics_data_use_forwarder_ = |
| 517 g_browser_process->metrics_service()->GetDataUseForwardingCallback(); |
| 518 } |
| 519 |
| 511 BrowserThread::SetDelegate(BrowserThread::IO, this); | 520 BrowserThread::SetDelegate(BrowserThread::IO, this); |
| 512 } | 521 } |
| 513 | 522 |
| 514 IOThread::~IOThread() { | 523 IOThread::~IOThread() { |
| 515 // This isn't needed for production code, but in tests, IOThread may | 524 // This isn't needed for production code, but in tests, IOThread may |
| 516 // be multiply constructed. | 525 // be multiply constructed. |
| 517 BrowserThread::SetDelegate(BrowserThread::IO, NULL); | 526 BrowserThread::SetDelegate(BrowserThread::IO, NULL); |
| 518 | 527 |
| 519 pref_proxy_config_tracker_->DetachFromPrefService(); | 528 pref_proxy_config_tracker_->DetachFromPrefService(); |
| 520 DCHECK(!globals_); | 529 DCHECK(!globals_); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 new chrome_browser_data_usage::TabIdAnnotator()), | 616 new chrome_browser_data_usage::TabIdAnnotator()), |
| 608 std::move(data_use_amortizer))); | 617 std::move(data_use_amortizer))); |
| 609 | 618 |
| 610 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 | 619 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 |
| 611 // is fixed. | 620 // is fixed. |
| 612 tracked_objects::ScopedTracker tracking_profile3( | 621 tracked_objects::ScopedTracker tracking_profile3( |
| 613 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 622 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 614 "466432 IOThread::InitAsync::ChromeNetworkDelegate")); | 623 "466432 IOThread::InitAsync::ChromeNetworkDelegate")); |
| 615 scoped_ptr<ChromeNetworkDelegate> chrome_network_delegate( | 624 scoped_ptr<ChromeNetworkDelegate> chrome_network_delegate( |
| 616 new ChromeNetworkDelegate(extension_event_router_forwarder(), | 625 new ChromeNetworkDelegate(extension_event_router_forwarder(), |
| 617 &system_enable_referrers_)); | 626 &system_enable_referrers_, |
| 627 metrics_data_use_forwarder_)); |
| 618 // By default, data usage is considered off the record. | 628 // By default, data usage is considered off the record. |
| 619 chrome_network_delegate->set_data_use_aggregator( | 629 chrome_network_delegate->set_data_use_aggregator( |
| 620 globals_->data_use_aggregator.get(), | 630 globals_->data_use_aggregator.get(), |
| 621 true /* is_data_usage_off_the_record */); | 631 true /* is_data_usage_off_the_record */); |
| 622 | 632 |
| 623 #if BUILDFLAG(ANDROID_JAVA_UI) | 633 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 624 globals_->external_data_use_observer.reset( | 634 globals_->external_data_use_observer.reset( |
| 625 new chrome::android::ExternalDataUseObserver( | 635 new chrome::android::ExternalDataUseObserver( |
| 626 globals_->data_use_aggregator.get(), | 636 globals_->data_use_aggregator.get(), |
| 627 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | 637 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |
| (...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1756 std::move(job_factory); | 1766 std::move(job_factory); |
| 1757 | 1767 |
| 1758 context->set_job_factory( | 1768 context->set_job_factory( |
| 1759 globals->proxy_script_fetcher_url_request_job_factory.get()); | 1769 globals->proxy_script_fetcher_url_request_job_factory.get()); |
| 1760 | 1770 |
| 1761 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the | 1771 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the |
| 1762 // system URLRequestContext too. There's no reason this should be tied to a | 1772 // system URLRequestContext too. There's no reason this should be tied to a |
| 1763 // profile. | 1773 // profile. |
| 1764 return context; | 1774 return context; |
| 1765 } | 1775 } |
| OLD | NEW |