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 | 10 |
| 11 // TODO(asvitkine): Remove when this class is moved to metrics namespace. |
| 12 using metrics::MetricsService; |
| 13 using metrics::MetricsServiceObserver; |
| 14 using metrics::SyntheticTrialGroup; |
| 15 |
11 // static | 16 // static |
12 void MetricsServiceAccessor::AddMetricsServiceObserver( | 17 void MetricsServiceAccessor::AddMetricsServiceObserver( |
13 MetricsServiceObserver* observer) { | 18 MetricsServiceObserver* observer) { |
14 MetricsService* metrics_service = g_browser_process->metrics_service(); | 19 MetricsService* metrics_service = g_browser_process->metrics_service(); |
15 if (metrics_service) | 20 if (metrics_service) |
16 metrics_service->AddObserver(observer); | 21 metrics_service->AddObserver(observer); |
17 } | 22 } |
18 | 23 |
19 void MetricsServiceAccessor::RemoveMetricsServiceObserver( | 24 void MetricsServiceAccessor::RemoveMetricsServiceObserver( |
20 MetricsServiceObserver* observer) { | 25 MetricsServiceObserver* observer) { |
21 MetricsService* metrics_service = g_browser_process->metrics_service(); | 26 MetricsService* metrics_service = g_browser_process->metrics_service(); |
22 if (metrics_service) | 27 if (metrics_service) |
23 metrics_service->RemoveObserver(observer); | 28 metrics_service->RemoveObserver(observer); |
24 } | 29 } |
25 | 30 |
26 // static | 31 // static |
27 bool MetricsServiceAccessor::RegisterSyntheticFieldTrial( | 32 bool MetricsServiceAccessor::RegisterSyntheticFieldTrial( |
28 MetricsService* metrics_service, | 33 MetricsService* metrics_service, |
29 uint32_t trial_name_hash, | 34 uint32_t trial_name_hash, |
30 uint32_t group_name_hash) { | 35 uint32_t group_name_hash) { |
31 if (!metrics_service) | 36 if (!metrics_service) |
32 return false; | 37 return false; |
33 | 38 |
34 SyntheticTrialGroup trial_group(trial_name_hash, group_name_hash); | 39 SyntheticTrialGroup trial_group(trial_name_hash, group_name_hash); |
35 metrics_service->RegisterSyntheticFieldTrial(trial_group); | 40 metrics_service->RegisterSyntheticFieldTrial(trial_group); |
36 return true; | 41 return true; |
37 } | 42 } |
OLD | NEW |