| OLD | NEW |
| 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 <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 bool ChromeMetricsServiceClient::IsReportingPolicyManaged() { | 563 bool ChromeMetricsServiceClient::IsReportingPolicyManaged() { |
| 564 return IsMetricsReportingPolicyManaged(); | 564 return IsMetricsReportingPolicyManaged(); |
| 565 } | 565 } |
| 566 | 566 |
| 567 metrics::EnableMetricsDefault | 567 metrics::EnableMetricsDefault |
| 568 ChromeMetricsServiceClient::GetMetricsReportingDefaultState() { | 568 ChromeMetricsServiceClient::GetMetricsReportingDefaultState() { |
| 569 return metrics::GetMetricsReportingDefaultState( | 569 return metrics::GetMetricsReportingDefaultState( |
| 570 g_browser_process->local_state()); | 570 g_browser_process->local_state()); |
| 571 } | 571 } |
| 572 | 572 |
| 573 // static |
| 574 bool ChromeMetricsServiceClient::IsMetricsReportingEnabledForTesting() { |
| 575 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 576 switches::kEnableMetricsReportingForTesting); |
| 577 } |
| 578 |
| 573 void ChromeMetricsServiceClient::Initialize() { | 579 void ChromeMetricsServiceClient::Initialize() { |
| 574 PrefService* local_state = g_browser_process->local_state(); | 580 PrefService* local_state = g_browser_process->local_state(); |
| 575 | 581 |
| 576 // Clear deprecated metrics preference for Android. | 582 // Clear deprecated metrics preference for Android. |
| 577 // TODO(gayane): Cleanup this code after M60 when the pref would be cleared | 583 // TODO(gayane): Cleanup this code after M60 when the pref would be cleared |
| 578 // from clients. | 584 // from clients. |
| 579 #if defined(OS_ANDROID) | 585 #if defined(OS_ANDROID) |
| 580 local_state->ClearPref(prefs::kCrashReportingEnabled); | 586 local_state->ClearPref(prefs::kCrashReportingEnabled); |
| 581 #endif | 587 #endif |
| 582 | 588 |
| 583 metrics_service_.reset( | 589 metrics_service_.reset( |
| 584 new metrics::MetricsService(metrics_state_manager_, this, local_state)); | 590 new metrics::MetricsService(metrics_state_manager_, this, local_state)); |
| 585 | 591 |
| 586 RegisterMetricsServiceProviders(); | 592 RegisterMetricsServiceProviders(); |
| 587 | 593 |
| 588 if (base::FeatureList::IsEnabled(ukm::kUkmFeature)) { | 594 if (IsMetricsReportingEnabledForTesting() || |
| 595 base::FeatureList::IsEnabled(ukm::kUkmFeature)) { |
| 589 ukm_service_.reset(new ukm::UkmService(local_state, this)); | 596 ukm_service_.reset(new ukm::UkmService(local_state, this)); |
| 590 RegisterUKMProviders(); | 597 RegisterUKMProviders(); |
| 591 } | 598 } |
| 592 } | 599 } |
| 593 | 600 |
| 594 void ChromeMetricsServiceClient::RegisterMetricsServiceProviders() { | 601 void ChromeMetricsServiceClient::RegisterMetricsServiceProviders() { |
| 595 PrefService* local_state = g_browser_process->local_state(); | 602 PrefService* local_state = g_browser_process->local_state(); |
| 596 | 603 |
| 597 // Gets access to persistent metrics shared by sub-processes. | 604 // Gets access to persistent metrics shared by sub-processes. |
| 598 metrics_service_->RegisterMetricsProvider( | 605 metrics_service_->RegisterMetricsProvider( |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 ukm_service_->Purge(); | 988 ukm_service_->Purge(); |
| 982 ukm_service_->ResetClientId(); | 989 ukm_service_->ResetClientId(); |
| 983 } | 990 } |
| 984 // Signal service manager to enable/disable UKM based on new state. | 991 // Signal service manager to enable/disable UKM based on new state. |
| 985 UpdateRunningServices(); | 992 UpdateRunningServices(); |
| 986 } | 993 } |
| 987 | 994 |
| 988 bool ChromeMetricsServiceClient::IsHistorySyncEnabledOnAllProfiles() { | 995 bool ChromeMetricsServiceClient::IsHistorySyncEnabledOnAllProfiles() { |
| 989 return SyncDisableObserver::IsHistorySyncEnabledOnAllProfiles(); | 996 return SyncDisableObserver::IsHistorySyncEnabledOnAllProfiles(); |
| 990 } | 997 } |
| OLD | NEW |