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 COMPONENTS_METRICS_METRICS_STATE_MANAGER_H_ | 5 #ifndef COMPONENTS_METRICS_METRICS_STATE_MANAGER_H_ |
6 #define COMPONENTS_METRICS_METRICS_STATE_MANAGER_H_ | 6 #define COMPONENTS_METRICS_METRICS_STATE_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 PermutedEntropyCacheClearedWhenLowEntropyReset); | 83 PermutedEntropyCacheClearedWhenLowEntropyReset); |
84 FRIEND_TEST_ALL_PREFIXES(MetricsStateManagerTest, ResetMetricsIDs); | 84 FRIEND_TEST_ALL_PREFIXES(MetricsStateManagerTest, ResetMetricsIDs); |
85 | 85 |
86 // Designates which entropy source was returned from this class. | 86 // Designates which entropy source was returned from this class. |
87 // This is used for testing to validate that we return the correct source | 87 // This is used for testing to validate that we return the correct source |
88 // depending on the state of the service. | 88 // depending on the state of the service. |
89 enum EntropySourceType { | 89 enum EntropySourceType { |
90 ENTROPY_SOURCE_NONE, | 90 ENTROPY_SOURCE_NONE, |
91 ENTROPY_SOURCE_LOW, | 91 ENTROPY_SOURCE_LOW, |
92 ENTROPY_SOURCE_HIGH, | 92 ENTROPY_SOURCE_HIGH, |
| 93 ENTROPY_SOURCE_ENUM_SIZE, |
93 }; | 94 }; |
94 | 95 |
95 // Creates the MetricsStateManager with the given |local_state|. Calls | 96 // Creates the MetricsStateManager with the given |local_state|. Calls |
96 // |is_reporting_enabled_callback| to query whether metrics reporting is | 97 // |is_reporting_enabled_callback| to query whether metrics reporting is |
97 // enabled. Clients should instead use Create(), which enforces that a single | 98 // enabled. Clients should instead use Create(), which enforces that a single |
98 // instance of this class be alive at any given time. | 99 // instance of this class be alive at any given time. |
99 // |store_client_info| should back up client info to persistent storage such | 100 // |store_client_info| should back up client info to persistent storage such |
100 // that it is later retrievable by |load_client_info|. | 101 // that it is later retrievable by |load_client_info|. |
101 MetricsStateManager( | 102 MetricsStateManager( |
102 PrefService* local_state, | 103 PrefService* local_state, |
103 const base::Callback<bool(void)>& is_reporting_enabled_callback, | 104 const base::Callback<bool(void)>& is_reporting_enabled_callback, |
104 const StoreClientInfoCallback& store_client_info, | 105 const StoreClientInfoCallback& store_client_info, |
105 const LoadClientInfoCallback& load_client_info); | 106 const LoadClientInfoCallback& load_client_info); |
106 | 107 |
107 // Backs up the current client info via |store_client_info_|. | 108 // Backs up the current client info via |store_client_info_|. |
108 void BackUpCurrentClientInfo(); | 109 void BackUpCurrentClientInfo(); |
109 | 110 |
110 // Loads the client info via |load_client_info_| and potentially migrates it | 111 // Loads the client info via |load_client_info_| and potentially migrates it |
111 // before returning it if it comes back in its old form. | 112 // before returning it if it comes back in its old form. |
112 scoped_ptr<ClientInfo> LoadClientInfoAndMaybeMigrate(); | 113 scoped_ptr<ClientInfo> LoadClientInfoAndMaybeMigrate(); |
113 | 114 |
114 // Returns the low entropy source for this client. This is a random value | 115 // Returns the low entropy source for this client. This is a random value |
115 // that is non-identifying amongst browser clients. This method will | 116 // that is non-identifying amongst browser clients. This method will |
116 // generate the entropy source value if it has not been called before. | 117 // generate the entropy source value if it has not been called before. |
117 int GetLowEntropySource(); | 118 int GetLowEntropySource(); |
118 | 119 |
| 120 // Updates |entropy_source_returned_| with |type| iff the current value is |
| 121 // ENTROPY_SOURCE_NONE and logs the new value in a histogram. |
| 122 void UpdateEntropySourceReturnedValue(EntropySourceType type); |
| 123 |
119 // Returns the first entropy source that was returned by this service since | 124 // Returns the first entropy source that was returned by this service since |
120 // start up, or NONE if neither was returned yet. This is exposed for testing | 125 // start up, or NONE if neither was returned yet. This is exposed for testing |
121 // only. | 126 // only. |
122 EntropySourceType entropy_source_returned() const { | 127 EntropySourceType entropy_source_returned() const { |
123 return entropy_source_returned_; | 128 return entropy_source_returned_; |
124 } | 129 } |
125 | 130 |
126 // Reset the client id and low entropy source if the kMetricsResetMetricIDs | 131 // Reset the client id and low entropy source if the kMetricsResetMetricIDs |
127 // pref is true. | 132 // pref is true. |
128 void ResetMetricsIDsIfNecessary(); | 133 void ResetMetricsIDsIfNecessary(); |
(...skipping 27 matching lines...) Expand all Loading... |
156 EntropySourceType entropy_source_returned_; | 161 EntropySourceType entropy_source_returned_; |
157 | 162 |
158 scoped_ptr<ClonedInstallDetector> cloned_install_detector_; | 163 scoped_ptr<ClonedInstallDetector> cloned_install_detector_; |
159 | 164 |
160 DISALLOW_COPY_AND_ASSIGN(MetricsStateManager); | 165 DISALLOW_COPY_AND_ASSIGN(MetricsStateManager); |
161 }; | 166 }; |
162 | 167 |
163 } // namespace metrics | 168 } // namespace metrics |
164 | 169 |
165 #endif // COMPONENTS_METRICS_METRICS_STATE_MANAGER_H_ | 170 #endif // COMPONENTS_METRICS_METRICS_STATE_MANAGER_H_ |
OLD | NEW |