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