Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_VARIATIONS_VARIATIONS_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_ |
| 6 #define CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_ | 6 #define CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 // Creates field trials based on Variations Seed loaded from local prefs. If | 40 // Creates field trials based on Variations Seed loaded from local prefs. If |
| 41 // there is a problem loading the seed data, all trials specified by the seed | 41 // there is a problem loading the seed data, all trials specified by the seed |
| 42 // may not be created. | 42 // may not be created. |
| 43 bool CreateTrialsFromSeed(PrefService* local_prefs); | 43 bool CreateTrialsFromSeed(PrefService* local_prefs); |
| 44 | 44 |
| 45 // Calls FetchVariationsSeed once and repeats this periodically. See | 45 // Calls FetchVariationsSeed once and repeats this periodically. See |
| 46 // implementation for details on the period. Must be called after | 46 // implementation for details on the period. Must be called after |
| 47 // |CreateTrialsFromSeed|. | 47 // |CreateTrialsFromSeed|. |
| 48 void StartRepeatedVariationsSeedFetch(); | 48 void StartRepeatedVariationsSeedFetch(); |
| 49 | 49 |
| 50 // TODO(mad): Remove this once NetworkTimeService is extracted as stand alone. | |
| 51 bool GetNetworkTime(base::Time* network_time, | |
| 52 base::TimeDelta* uncertainty) const; | |
| 53 | |
| 50 #if defined(OS_WIN) | 54 #if defined(OS_WIN) |
| 51 // Starts syncing Google Update Variation IDs with the registry. | 55 // Starts syncing Google Update Variation IDs with the registry. |
| 52 void StartGoogleUpdateRegistrySync(); | 56 void StartGoogleUpdateRegistrySync(); |
| 53 #endif | 57 #endif |
| 54 | 58 |
| 55 // Exposed for testing. | 59 // Exposed for testing. |
| 56 void SetCreateTrialsFromSeedCalledForTesting(bool called); | 60 void SetCreateTrialsFromSeedCalledForTesting(bool called); |
| 57 | 61 |
| 58 // Register Variations related prefs in Local State. | 62 // Register Variations related prefs in Local State. |
| 59 static void RegisterPrefs(PrefServiceSimple* prefs); | 63 static void RegisterPrefs(PrefServiceSimple* prefs); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 base::RepeatingTimer<VariationsService> timer_; | 180 base::RepeatingTimer<VariationsService> timer_; |
| 177 | 181 |
| 178 // Helper class used to tell this service if it's allowed to make network | 182 // Helper class used to tell this service if it's allowed to make network |
| 179 // resource requests. | 183 // resource requests. |
| 180 scoped_ptr<ResourceRequestAllowedNotifier> resource_request_allowed_notifier_; | 184 scoped_ptr<ResourceRequestAllowedNotifier> resource_request_allowed_notifier_; |
| 181 | 185 |
| 182 // The start time of the last seed request. This is used to measure the | 186 // The start time of the last seed request. This is used to measure the |
| 183 // latency of seed requests. Initially zero. | 187 // latency of seed requests. Initially zero. |
| 184 base::TimeTicks last_request_started_time_; | 188 base::TimeTicks last_request_started_time_; |
| 185 | 189 |
| 190 // TODO(mad): Eventually move this to a NetworkTimeService. | |
| 191 class NetworkTimeService { | |
|
Alexei Svitkine (slow)
2013/02/01 22:18:08
Put it in a separate file. "Service" is too ambiti
MAD
2013/02/04 21:07:43
Done.
| |
| 192 public: | |
| 193 NetworkTimeService() { | |
|
Alexei Svitkine (slow)
2013/02/01 22:18:08
When this is a file, add a dtor and don't inline t
MAD
2013/02/04 21:07:43
Done.
| |
| 194 }; | |
| 195 | |
| 196 // Returns a network time based on previous url request header value and CPU | |
| 197 // ticks count since then. Returns false if no network time is available | |
| 198 // yet. Can also return the error range if |uncertainty| isn't NULL. | |
| 199 bool GetNetworkTime(base::Time* network_time, | |
| 200 base::TimeDelta* uncertainty) const; | |
| 201 private: | |
| 202 // TODO(mad): Remove this once NetworkTimeService is extracted from here. | |
| 203 friend class VariationsService; | |
|
Alexei Svitkine (slow)
2013/02/01 22:18:08
Remove this and change the SetNetworkTime() call t
MAD
2013/02/04 21:07:43
Done.
| |
| 204 | |
| 205 void SetNetworkTime(const base::Time& network_time, | |
| 206 const base::TimeDelta& latency); | |
| 207 | |
| 208 // Remember the network time based on last url request header value. | |
| 209 base::Time network_time_; | |
| 210 | |
| 211 // The estimated ticks count when the date was set on the url request. | |
| 212 base::TimeTicks network_time_ticks_; | |
| 213 | |
| 214 // Uncertainty of time based on added inaccuracies of the time is acquired. | |
| 215 base::TimeDelta network_time_uncertainty_; | |
| 216 | |
| 217 DISALLOW_COPY_AND_ASSIGN(NetworkTimeService); | |
| 218 } network_service_; | |
| 219 | |
| 186 #if defined(OS_WIN) | 220 #if defined(OS_WIN) |
| 187 // Helper that handles synchronizing Variations with the Registry. | 221 // Helper that handles synchronizing Variations with the Registry. |
| 188 VariationsRegistrySyncer registry_syncer_; | 222 VariationsRegistrySyncer registry_syncer_; |
| 189 #endif | 223 #endif |
| 190 }; | 224 }; |
| 191 | 225 |
| 192 } // namespace chrome_variations | 226 } // namespace chrome_variations |
| 193 | 227 |
| 194 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_ | 228 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_ |
| OLD | NEW |