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

Side by Side Diff: chrome/browser/metrics/chrome_metrics_service_client.cc

Issue 2605553002: Add EffectiveConnectionType enum to the system profile proto (Closed)
Patch Set: Rebased, ryansturm comments, fix failing chromeos test Created 3 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/metrics/chrome_metrics_service_client.h" 5 #include "chrome/browser/metrics/chrome_metrics_service_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 10 matching lines...) Expand all
21 #include "base/metrics/persistent_histogram_allocator.h" 21 #include "base/metrics/persistent_histogram_allocator.h"
22 #include "base/path_service.h" 22 #include "base/path_service.h"
23 #include "base/rand_util.h" 23 #include "base/rand_util.h"
24 #include "base/strings/string16.h" 24 #include "base/strings/string16.h"
25 #include "base/threading/platform_thread.h" 25 #include "base/threading/platform_thread.h"
26 #include "base/threading/thread_task_runner_handle.h" 26 #include "base/threading/thread_task_runner_handle.h"
27 #include "build/build_config.h" 27 #include "build/build_config.h"
28 #include "chrome/browser/browser_process.h" 28 #include "chrome/browser/browser_process.h"
29 #include "chrome/browser/chrome_notification_types.h" 29 #include "chrome/browser/chrome_notification_types.h"
30 #include "chrome/browser/google/google_brand.h" 30 #include "chrome/browser/google/google_brand.h"
31 #include "chrome/browser/io_thread.h"
31 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" 32 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
32 #include "chrome/browser/metrics/chrome_stability_metrics_provider.h" 33 #include "chrome/browser/metrics/chrome_stability_metrics_provider.h"
33 #include "chrome/browser/metrics/https_engagement_metrics_provider.h" 34 #include "chrome/browser/metrics/https_engagement_metrics_provider.h"
34 #include "chrome/browser/metrics/metrics_reporting_state.h" 35 #include "chrome/browser/metrics/metrics_reporting_state.h"
35 #include "chrome/browser/metrics/sampling_metrics_provider.h" 36 #include "chrome/browser/metrics/sampling_metrics_provider.h"
36 #include "chrome/browser/metrics/subprocess_metrics_provider.h" 37 #include "chrome/browser/metrics/subprocess_metrics_provider.h"
37 #include "chrome/browser/metrics/time_ticks_experiment_win.h" 38 #include "chrome/browser/metrics/time_ticks_experiment_win.h"
38 #include "chrome/browser/safe_browsing/certificate_reporting_metrics_provider.h" 39 #include "chrome/browser/safe_browsing/certificate_reporting_metrics_provider.h"
39 #include "chrome/browser/sync/chrome_sync_client.h" 40 #include "chrome/browser/sync/chrome_sync_client.h"
40 #include "chrome/browser/ui/browser_otr_state.h" 41 #include "chrome/browser/ui/browser_otr_state.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 #include "third_party/crashpad/crashpad/client/crashpad_info.h" 116 #include "third_party/crashpad/crashpad/client/crashpad_info.h"
116 #endif 117 #endif
117 118
118 #if !defined(OS_CHROMEOS) 119 #if !defined(OS_CHROMEOS)
119 #include "chrome/browser/signin/chrome_signin_status_metrics_provider_delegate.h " 120 #include "chrome/browser/signin/chrome_signin_status_metrics_provider_delegate.h "
120 #include "components/signin/core/browser/signin_status_metrics_provider.h" 121 #include "components/signin/core/browser/signin_status_metrics_provider.h"
121 #endif // !defined(OS_CHROMEOS) 122 #endif // !defined(OS_CHROMEOS)
122 123
123 namespace { 124 namespace {
124 125
126 // Returns the network quality estimator. Runs on IO thread.
127 net::NetworkQualityEstimator* GetNetworkQualityEstimatorOnIOThread(
128 IOThread* io_thread) {
129 if (!io_thread)
Alexei Svitkine (slow) 2017/01/03 17:48:48 In what cases would this be hit? Add a comment or
tbansal1 2017/01/03 18:55:43 Done.
130 return nullptr;
131 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
132 return io_thread->globals()->network_quality_estimator.get();
133 }
134
125 // This specifies the amount of time to wait for all renderers to send their 135 // This specifies the amount of time to wait for all renderers to send their
126 // data. 136 // data.
127 const int kMaxHistogramGatheringWaitDuration = 60000; // 60 seconds. 137 const int kMaxHistogramGatheringWaitDuration = 60000; // 60 seconds.
128 138
129 // Needs to be kept in sync with the writer in 139 // Needs to be kept in sync with the writer in
130 // third_party/crashpad/crashpad/handler/handler_main.cc. 140 // third_party/crashpad/crashpad/handler/handler_main.cc.
131 const char kCrashpadHistogramAllocatorName[] = "CrashpadMetrics"; 141 const char kCrashpadHistogramAllocatorName[] = "CrashpadMetrics";
132 142
133 #if defined(OS_WIN) || defined(OS_MACOSX) 143 #if defined(OS_WIN) || defined(OS_MACOSX)
134 // The stream type assigned to the minidump stream that holds the serialized 144 // The stream type assigned to the minidump stream that holds the serialized
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 plugin_metrics_provider_(nullptr), 286 plugin_metrics_provider_(nullptr),
277 #endif 287 #endif
278 #if defined(OS_WIN) 288 #if defined(OS_WIN)
279 google_update_metrics_provider_(nullptr), 289 google_update_metrics_provider_(nullptr),
280 watcher_metrics_provider_(nullptr), 290 watcher_metrics_provider_(nullptr),
281 antivirus_metrics_provider_(nullptr), 291 antivirus_metrics_provider_(nullptr),
282 #endif 292 #endif
283 drive_metrics_provider_(nullptr), 293 drive_metrics_provider_(nullptr),
284 start_time_(base::TimeTicks::Now()), 294 start_time_(base::TimeTicks::Now()),
285 has_uploaded_profiler_data_(false), 295 has_uploaded_profiler_data_(false),
296 network_metrics_provider_(nullptr),
286 weak_ptr_factory_(this) { 297 weak_ptr_factory_(this) {
287 DCHECK(thread_checker_.CalledOnValidThread()); 298 DCHECK(thread_checker_.CalledOnValidThread());
288 RecordCommandLineMetrics(); 299 RecordCommandLineMetrics();
289 RegisterForNotifications(); 300 RegisterForNotifications();
290 } 301 }
291 302
292 ChromeMetricsServiceClient::~ChromeMetricsServiceClient() { 303 ChromeMetricsServiceClient::~ChromeMetricsServiceClient() {
293 DCHECK(thread_checker_.CalledOnValidThread()); 304 DCHECK(thread_checker_.CalledOnValidThread());
294 base::GlobalHistogramAllocator* allocator = 305 base::GlobalHistogramAllocator* allocator =
295 base::GlobalHistogramAllocator::Get(); 306 base::GlobalHistogramAllocator::Get();
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 metrics_service_->RegisterMetricsProvider( 574 metrics_service_->RegisterMetricsProvider(
564 std::unique_ptr<metrics::MetricsProvider>( 575 std::unique_ptr<metrics::MetricsProvider>(
565 new SubprocessMetricsProvider())); 576 new SubprocessMetricsProvider()));
566 577
567 // Register metrics providers. 578 // Register metrics providers.
568 #if BUILDFLAG(ENABLE_EXTENSIONS) 579 #if BUILDFLAG(ENABLE_EXTENSIONS)
569 metrics_service_->RegisterMetricsProvider( 580 metrics_service_->RegisterMetricsProvider(
570 std::unique_ptr<metrics::MetricsProvider>( 581 std::unique_ptr<metrics::MetricsProvider>(
571 new ExtensionsMetricsProvider(metrics_state_manager_))); 582 new ExtensionsMetricsProvider(metrics_state_manager_)));
572 #endif 583 #endif
584
585 std::unique_ptr<metrics::NetworkMetricsProvider> network_metrics_provider(
586 new metrics::NetworkMetricsProvider(
587 content::BrowserThread::GetBlockingPool()));
588
589 network_metrics_provider_ = network_metrics_provider.get();
590
591 // Get the network quality estimator on the IO thread, and provide it to the
592 // |network_metrics_provider|.
593 content::BrowserThread::PostTaskAndReplyWithResult(
594 content::BrowserThread::IO, FROM_HERE,
595 base::Bind(GetNetworkQualityEstimatorOnIOThread,
596 g_browser_process->io_thread()),
597 base::Bind(&ChromeMetricsServiceClient::ProvideNetworkQualityEstimator,
598 weak_ptr_factory_.GetWeakPtr()));
Alexei Svitkine (slow) 2017/01/03 17:48:48 Can all of this be internally in NetworksMetricsPr
tbansal1 2017/01/03 18:55:43 Yes, IO thread is in chrome/browser, so IOThread o
asvitkine_google 2017/01/03 19:09:50 Just to be clear, I would like there to be as litt
599
573 metrics_service_->RegisterMetricsProvider( 600 metrics_service_->RegisterMetricsProvider(
574 std::unique_ptr<metrics::MetricsProvider>( 601 std::move(network_metrics_provider));
575 new metrics::NetworkMetricsProvider(
576 content::BrowserThread::GetBlockingPool())));
577 602
578 // Currently, we configure OmniboxMetricsProvider to not log events to UMA 603 // Currently, we configure OmniboxMetricsProvider to not log events to UMA
579 // if there is a single incognito session visible. In the future, it may 604 // if there is a single incognito session visible. In the future, it may
580 // be worth revisiting this to still log events from non-incognito sessions. 605 // be worth revisiting this to still log events from non-incognito sessions.
581 metrics_service_->RegisterMetricsProvider( 606 metrics_service_->RegisterMetricsProvider(
582 std::unique_ptr<metrics::MetricsProvider>(new OmniboxMetricsProvider( 607 std::unique_ptr<metrics::MetricsProvider>(new OmniboxMetricsProvider(
583 base::Bind(&chrome::IsIncognitoSessionActive)))); 608 base::Bind(&chrome::IsIncognitoSessionActive))));
584 metrics_service_->RegisterMetricsProvider( 609 metrics_service_->RegisterMetricsProvider(
585 std::unique_ptr<metrics::MetricsProvider>( 610 std::unique_ptr<metrics::MetricsProvider>(
586 new ChromeStabilityMetricsProvider(local_state))); 611 new ChromeStabilityMetricsProvider(local_state)));
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 } 919 }
895 } 920 }
896 921
897 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { 922 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) {
898 metrics_service_->OnApplicationNotIdle(); 923 metrics_service_->OnApplicationNotIdle();
899 } 924 }
900 925
901 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() { 926 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() {
902 return metrics::IsCellularLogicEnabled(); 927 return metrics::IsCellularLogicEnabled();
903 } 928 }
929
930 void ChromeMetricsServiceClient::ProvideNetworkQualityEstimator(
931 net::NetworkQualityEstimator* network_quality_estimator) const {
932 DCHECK(thread_checker_.CalledOnValidThread());
933 // Provide the |network_quality_estimator| and the taskrunner for the thread
934 // on which |network_quality_estimator| runs to |network_metrics_provider_|.
935 network_metrics_provider_->ProvideNetworkQualityEstimator(
936 network_quality_estimator, content::BrowserThread::GetTaskRunnerForThread(
937 content::BrowserThread::IO));
938 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698