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

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

Issue 1818613002: Implement UMA log throttling for cellular connections (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix build for gn, fix unittests, add comments Created 4 years, 8 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
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 #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
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
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 metrics::DataUseTracker::GetForwardingCallback(
518 g_browser_process->metrics_service()->GetDataUseTracker(),
Alexei Svitkine (slow) 2016/03/31 04:32:25 Instead of having a static GetForwardingCallback()
gayane -on leave until 09-2017 2016/03/31 17:54:57 Done.
519 base::ThreadTaskRunnerHandle::Get());
520 }
521
511 BrowserThread::SetDelegate(BrowserThread::IO, this); 522 BrowserThread::SetDelegate(BrowserThread::IO, this);
512 } 523 }
513 524
514 IOThread::~IOThread() { 525 IOThread::~IOThread() {
515 // This isn't needed for production code, but in tests, IOThread may 526 // This isn't needed for production code, but in tests, IOThread may
516 // be multiply constructed. 527 // be multiply constructed.
517 BrowserThread::SetDelegate(BrowserThread::IO, NULL); 528 BrowserThread::SetDelegate(BrowserThread::IO, NULL);
518 529
519 pref_proxy_config_tracker_->DetachFromPrefService(); 530 pref_proxy_config_tracker_->DetachFromPrefService();
520 DCHECK(!globals_); 531 DCHECK(!globals_);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 new chrome_browser_data_usage::TabIdAnnotator()), 618 new chrome_browser_data_usage::TabIdAnnotator()),
608 std::move(data_use_amortizer))); 619 std::move(data_use_amortizer)));
609 620
610 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 621 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432
611 // is fixed. 622 // is fixed.
612 tracked_objects::ScopedTracker tracking_profile3( 623 tracked_objects::ScopedTracker tracking_profile3(
613 FROM_HERE_WITH_EXPLICIT_FUNCTION( 624 FROM_HERE_WITH_EXPLICIT_FUNCTION(
614 "466432 IOThread::InitAsync::ChromeNetworkDelegate")); 625 "466432 IOThread::InitAsync::ChromeNetworkDelegate"));
615 scoped_ptr<ChromeNetworkDelegate> chrome_network_delegate( 626 scoped_ptr<ChromeNetworkDelegate> chrome_network_delegate(
616 new ChromeNetworkDelegate(extension_event_router_forwarder(), 627 new ChromeNetworkDelegate(extension_event_router_forwarder(),
617 &system_enable_referrers_)); 628 &system_enable_referrers_,
629 metrics_data_use_forwarder_));
618 // By default, data usage is considered off the record. 630 // By default, data usage is considered off the record.
619 chrome_network_delegate->set_data_use_aggregator( 631 chrome_network_delegate->set_data_use_aggregator(
620 globals_->data_use_aggregator.get(), 632 globals_->data_use_aggregator.get(),
621 true /* is_data_usage_off_the_record */); 633 true /* is_data_usage_off_the_record */);
622 634
623 #if BUILDFLAG(ANDROID_JAVA_UI) 635 #if BUILDFLAG(ANDROID_JAVA_UI)
624 globals_->external_data_use_observer.reset( 636 globals_->external_data_use_observer.reset(
625 new chrome::android::ExternalDataUseObserver( 637 new chrome::android::ExternalDataUseObserver(
626 globals_->data_use_aggregator.get(), 638 globals_->data_use_aggregator.get(),
627 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), 639 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
(...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1756 std::move(job_factory); 1768 std::move(job_factory);
1757 1769
1758 context->set_job_factory( 1770 context->set_job_factory(
1759 globals->proxy_script_fetcher_url_request_job_factory.get()); 1771 globals->proxy_script_fetcher_url_request_job_factory.get());
1760 1772
1761 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the 1773 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the
1762 // system URLRequestContext too. There's no reason this should be tied to a 1774 // system URLRequestContext too. There's no reason this should be tied to a
1763 // profile. 1775 // profile.
1764 return context; 1776 return context;
1765 } 1777 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698