blob: 7e1a107778bf511581464d4f076e3cfcd2a77d15 [file] [log] [blame]
[email protected]7edd78cd2014-05-23 22:31:451// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
asvitkinec8fa43e92014-11-14 22:39:565#ifndef COMPONENTS_METRICS_METRICS_SERVICE_ACCESSOR_H_
6#define COMPONENTS_METRICS_METRICS_SERVICE_ACCESSOR_H_
[email protected]7edd78cd2014-05-23 22:31:457
[email protected]bb5d1892014-08-06 06:03:228#include <stdint.h>
asvitkine6a1c8812016-08-01 22:37:019#include <vector>
[email protected]0129c272014-08-02 00:35:1710
[email protected]7edd78cd2014-05-23 22:31:4511#include "base/macros.h"
thestig345fc9c52017-03-23 22:35:2412#include "base/strings/string_piece.h"
[email protected]7edd78cd2014-05-23 22:31:4513
blundell0176f9a2015-10-01 09:09:3514class PrefService;
15
asvitkinecbd420732014-08-26 22:15:4016namespace metrics {
asvitkinec8fa43e92014-11-14 22:39:5617
[email protected]0129c272014-08-02 00:35:1718class MetricsService;
[email protected]7edd78cd2014-05-23 22:31:4519
20// This class limits and documents access to metrics service helper methods.
21// These methods are protected so each user has to inherit own program-specific
22// specialization and enable access there by declaring friends.
23class MetricsServiceAccessor {
24 protected:
asvitkinecbd420732014-08-26 22:15:4025 // Constructor declared as protected to enable inheritance. Descendants should
[email protected]7edd78cd2014-05-23 22:31:4526 // disallow instantiation.
27 MetricsServiceAccessor() {}
28
blundell0176f9a2015-10-01 09:09:3529 // Returns whether metrics reporting is enabled, using the value of the
30 // kMetricsReportingEnabled pref in |pref_service| to determine whether user
31 // has enabled reporting.
blundell0176f9a2015-10-01 09:09:3532 static bool IsMetricsReportingEnabled(PrefService* pref_service);
33
blundell0176f9a2015-10-01 09:09:3534
blundelldcd73e52015-09-29 14:09:5035 // Registers a field trial name and group with |metrics_service| (if not
36 // null), to be used to annotate a UMA report with a particular configuration
asvitkine6a1c8812016-08-01 22:37:0137 // state. Returns true on success.
38 // See the comment on MetricsService::RegisterSyntheticFieldTrial() for
39 // details.
blundelldcd73e52015-09-29 14:09:5040 static bool RegisterSyntheticFieldTrial(MetricsService* metrics_service,
thestig345fc9c52017-03-23 22:35:2441 base::StringPiece trial_name,
42 base::StringPiece group_name);
blundelldcd73e52015-09-29 14:09:5043
asvitkine6a1c8812016-08-01 22:37:0144 // Registers a field trial name and set of groups with |metrics_service| (if
45 // not null), to be used to annotate a UMA report with a particular
46 // configuration state. Returns true on success.
47 // See the comment on MetricsService::RegisterSyntheticMultiGroupFieldTrial()
48 // for details.
49 static bool RegisterSyntheticMultiGroupFieldTrial(
50 MetricsService* metrics_service,
thestig345fc9c52017-03-23 22:35:2451 base::StringPiece trial_name,
asvitkine6a1c8812016-08-01 22:37:0152 const std::vector<uint32_t>& group_name_hashes);
53
blundelldcd73e52015-09-29 14:09:5054 // Same as RegisterSyntheticFieldTrial above, but takes in the trial name as a
55 // hash rather than computing the hash from the string.
56 static bool RegisterSyntheticFieldTrialWithNameHash(
57 MetricsService* metrics_service,
58 uint32_t trial_name_hash,
thestig345fc9c52017-03-23 22:35:2459 base::StringPiece group_name);
blundelldcd73e52015-09-29 14:09:5060
61 // Same as RegisterSyntheticFieldTrial above, but takes in the trial and group
62 // names as hashes rather than computing those hashes from the strings.
63 static bool RegisterSyntheticFieldTrialWithNameAndGroupHash(
asvitkinec8fa43e92014-11-14 22:39:5664 MetricsService* metrics_service,
asvitkinecbd420732014-08-26 22:15:4065 uint32_t trial_name_hash,
66 uint32_t group_name_hash);
[email protected]0129c272014-08-02 00:35:1767
[email protected]7edd78cd2014-05-23 22:31:4568 private:
69 DISALLOW_COPY_AND_ASSIGN(MetricsServiceAccessor);
70};
71
asvitkinec8fa43e92014-11-14 22:39:5672} // namespace metrics
73
74#endif // COMPONENTS_METRICS_METRICS_SERVICE_ACCESSOR_H_