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 #ifndef CHROME_BROWSER_METRICS_METRICS_SERVICE_ACCESSOR_H_ | 5 #ifndef CHROME_BROWSER_METRICS_METRICS_SERVICE_ACCESSOR_H_ |
6 #define CHROME_BROWSER_METRICS_METRICS_SERVICE_ACCESSOR_H_ | 6 #define CHROME_BROWSER_METRICS_METRICS_SERVICE_ACCESSOR_H_ |
7 | 7 |
| 8 #include <stdint.h> |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 | 12 |
12 class MetricsService; | 13 class MetricsService; |
13 class MetricsServiceObserver; | 14 class MetricsServiceObserver; |
14 | 15 |
15 // This class limits and documents access to metrics service helper methods. | 16 // This class limits and documents access to metrics service helper methods. |
16 // These methods are protected so each user has to inherit own program-specific | 17 // These methods are protected so each user has to inherit own program-specific |
17 // specialization and enable access there by declaring friends. | 18 // specialization and enable access there by declaring friends. |
18 class MetricsServiceAccessor { | 19 class MetricsServiceAccessor { |
19 protected: | 20 protected: |
20 // Constructor declared as protected to enable inheritance. Decendants should | 21 // Constructor declared as protected to enable inheritance. Decendants should |
21 // disallow instantiation. | 22 // disallow instantiation. |
22 MetricsServiceAccessor() {} | 23 MetricsServiceAccessor() {} |
23 | 24 |
24 // Registers/unregisters |observer| to receive MetricsLog notifications | 25 // Registers/unregisters |observer| to receive MetricsLog notifications |
25 // from metrics service. | 26 // from metrics service. |
26 static void AddMetricsServiceObserver(MetricsServiceObserver* observer); | 27 static void AddMetricsServiceObserver(MetricsServiceObserver* observer); |
27 static void RemoveMetricsServiceObserver(MetricsServiceObserver* observer); | 28 static void RemoveMetricsServiceObserver(MetricsServiceObserver* observer); |
28 | 29 |
29 // Registers a field trial name and group to be used to annotate a UMA report | 30 // Registers the specified synthetic field trial (identified by a hash of the |
30 // with a particular Chrome configuration state. A UMA report will be | 31 // trial name and group name) with |metrics_service|, if the service is not |
31 // annotated with this trial group if and only if all events in the report | 32 // NULL, returning true on success. |
32 // were created after the trial is registered. Only one group name may be | 33 // See the comment on MetricsService::RegisterSyntheticFieldTrial for details. |
33 // registered at a time for a given trial name. Only the last group name that | |
34 // is registered for a given trial name will be recorded. The values passed | |
35 // in must not correspond to any real field trial in the code. | |
36 static bool RegisterSyntheticFieldTrial(MetricsService* metrics_service, | 34 static bool RegisterSyntheticFieldTrial(MetricsService* metrics_service, |
37 const std::string& trial, | 35 uint32_t trial_name_hash, |
38 const std::string& group); | 36 uint32_t group_name_hash); |
39 | 37 |
40 private: | 38 private: |
41 DISALLOW_COPY_AND_ASSIGN(MetricsServiceAccessor); | 39 DISALLOW_COPY_AND_ASSIGN(MetricsServiceAccessor); |
42 }; | 40 }; |
43 | 41 |
44 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_ACCESSOR_H_ | 42 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_ACCESSOR_H_ |
OLD | NEW |