| 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 <stdint.h> |
| 9 #include <string> | |
| 10 | 9 |
| 11 #include "base/macros.h" | 10 #include "base/macros.h" |
| 12 | 11 |
| 13 namespace metrics { | 12 namespace metrics { |
| 14 class MetricsService; | 13 class MetricsService; |
| 15 class MetricsServiceObserver; | |
| 16 } | 14 } |
| 17 | 15 |
| 18 // This class limits and documents access to metrics service helper methods. | 16 // This class limits and documents access to metrics service helper methods. |
| 19 // 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 |
| 20 // specialization and enable access there by declaring friends. | 18 // specialization and enable access there by declaring friends. |
| 21 class MetricsServiceAccessor { | 19 class MetricsServiceAccessor { |
| 22 protected: | 20 protected: |
| 23 // Constructor declared as protected to enable inheritance. Descendants should | 21 // Constructor declared as protected to enable inheritance. Descendants should |
| 24 // disallow instantiation. | 22 // disallow instantiation. |
| 25 MetricsServiceAccessor() {} | 23 MetricsServiceAccessor() {} |
| 26 | 24 |
| 27 // Registers/unregisters |observer| to receive MetricsLog notifications | |
| 28 // from metrics service. | |
| 29 static void AddMetricsServiceObserver( | |
| 30 metrics::MetricsServiceObserver* observer); | |
| 31 static void RemoveMetricsServiceObserver( | |
| 32 metrics::MetricsServiceObserver* observer); | |
| 33 | |
| 34 // Registers the specified synthetic field trial (identified by a hash of the | 25 // Registers the specified synthetic field trial (identified by a hash of the |
| 35 // trial name and group name) with |metrics_service|, if the service is not | 26 // trial name and group name) with |metrics_service|, if the service is not |
| 36 // NULL, returning true on success. | 27 // NULL, returning true on success. |
| 37 // See the comment on MetricsService::RegisterSyntheticFieldTrial for details. | 28 // See the comment on MetricsService::RegisterSyntheticFieldTrial for details. |
| 38 static bool RegisterSyntheticFieldTrial( | 29 static bool RegisterSyntheticFieldTrial( |
| 39 metrics::MetricsService* metrics_service, | 30 metrics::MetricsService* metrics_service, |
| 40 uint32_t trial_name_hash, | 31 uint32_t trial_name_hash, |
| 41 uint32_t group_name_hash); | 32 uint32_t group_name_hash); |
| 42 | 33 |
| 43 private: | 34 private: |
| 44 DISALLOW_COPY_AND_ASSIGN(MetricsServiceAccessor); | 35 DISALLOW_COPY_AND_ASSIGN(MetricsServiceAccessor); |
| 45 }; | 36 }; |
| 46 | 37 |
| 47 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_ACCESSOR_H_ | 38 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_ACCESSOR_H_ |
| OLD | NEW |