Chromium Code Reviews| 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/metrics_service_accessor.h" | 5 #include "chrome/browser/metrics/metrics_service_accessor.h" |
| 6 | 6 |
| 7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 8 #include "components/metrics/metrics_service.h" | 8 #include "components/metrics/metrics_service.h" |
| 9 #include "components/metrics/metrics_service_observer.h" | 9 #include "components/metrics/metrics_service_observer.h" |
| 10 #include "components/variations/metrics_util.h" | |
| 10 | 11 |
| 11 // static | 12 // static |
| 12 void MetricsServiceAccessor::AddMetricsServiceObserver( | 13 void MetricsServiceAccessor::AddMetricsServiceObserver( |
| 13 MetricsServiceObserver* observer) { | 14 MetricsServiceObserver* observer) { |
| 14 MetricsService* metrics_service = g_browser_process->metrics_service(); | 15 MetricsService* metrics_service = g_browser_process->metrics_service(); |
| 15 if (metrics_service) | 16 if (metrics_service) |
| 16 metrics_service->AddObserver(observer); | 17 metrics_service->AddObserver(observer); |
| 17 } | 18 } |
| 18 | 19 |
| 19 void MetricsServiceAccessor::RemoveMetricsServiceObserver( | 20 void MetricsServiceAccessor::RemoveMetricsServiceObserver( |
| 20 MetricsServiceObserver* observer) { | 21 MetricsServiceObserver* observer) { |
| 21 MetricsService* metrics_service = g_browser_process->metrics_service(); | 22 MetricsService* metrics_service = g_browser_process->metrics_service(); |
| 22 if (metrics_service) | 23 if (metrics_service) |
| 23 metrics_service->RemoveObserver(observer); | 24 metrics_service->RemoveObserver(observer); |
| 24 } | 25 } |
| 26 | |
| 27 // static | |
| 28 bool MetricsServiceAccessor::RegisterSyntheticFieldTrial( | |
| 29 MetricsService* metrics_service, | |
| 30 const std::string& trial, | |
| 31 const std::string& group) { | |
| 32 if (metrics_service) { | |
|
Alexei Svitkine (slow)
2014/07/30 21:33:31
Nit: Instead do an early return if the service is
megjablon
2014/07/30 21:42:50
Done.
| |
| 33 SyntheticTrialGroup trial_group(metrics::HashName(trial), | |
| 34 metrics::HashName(group)); | |
| 35 metrics_service->RegisterSyntheticFieldTrial(trial_group); | |
| 36 return true; | |
| 37 } | |
| 38 return false; | |
| 39 } | |
| OLD | NEW |