| 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 23 matching lines...) Expand all Loading... |
| 34 } | 34 } |
| 35 | 35 |
| 36 namespace metrics { | 36 namespace metrics { |
| 37 class MetricsStateManager; | 37 class MetricsStateManager; |
| 38 } | 38 } |
| 39 | 39 |
| 40 namespace user_prefs { | 40 namespace user_prefs { |
| 41 class PrefRegistrySyncable; | 41 class PrefRegistrySyncable; |
| 42 } | 42 } |
| 43 | 43 |
| 44 namespace variations { |
| 45 class VariationsSeed; |
| 46 } |
| 47 |
| 44 namespace chrome_variations { | 48 namespace chrome_variations { |
| 45 | 49 |
| 46 class VariationsSeed; | |
| 47 | |
| 48 // Used to setup field trials based on stored variations seed data, and fetch | 50 // Used to setup field trials based on stored variations seed data, and fetch |
| 49 // new seed data from the variations server. | 51 // new seed data from the variations server. |
| 50 class VariationsService | 52 class VariationsService |
| 51 : public net::URLFetcherDelegate, | 53 : public net::URLFetcherDelegate, |
| 52 public ResourceRequestAllowedNotifier::Observer { | 54 public ResourceRequestAllowedNotifier::Observer { |
| 53 public: | 55 public: |
| 54 class Observer { | 56 class Observer { |
| 55 public: | 57 public: |
| 56 // How critical a detected experiment change is. Whether it should be | 58 // How critical a detected experiment change is. Whether it should be |
| 57 // handled on a "best-effort" basis or, for a more critical change, if it | 59 // handled on a "best-effort" basis or, for a more critical change, if it |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, Observer); | 157 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, Observer); |
| 156 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedStoredWhenOKStatus); | 158 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedStoredWhenOKStatus); |
| 157 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedNotStoredWhenNonOKStatus); | 159 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedNotStoredWhenNonOKStatus); |
| 158 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedDateUpdatedOn304Status); | 160 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedDateUpdatedOn304Status); |
| 159 | 161 |
| 160 // Checks if prerequisites for fetching the Variations seed are met, and if | 162 // Checks if prerequisites for fetching the Variations seed are met, and if |
| 161 // so, performs the actual fetch using |DoActualFetch|. | 163 // so, performs the actual fetch using |DoActualFetch|. |
| 162 void FetchVariationsSeed(); | 164 void FetchVariationsSeed(); |
| 163 | 165 |
| 164 // Notify any observers of this service based on the simulation |result|. | 166 // Notify any observers of this service based on the simulation |result|. |
| 165 void NotifyObservers(const VariationsSeedSimulator::Result& result); | 167 void NotifyObservers( |
| 168 const variations::VariationsSeedSimulator::Result& result); |
| 166 | 169 |
| 167 // net::URLFetcherDelegate implementation: | 170 // net::URLFetcherDelegate implementation: |
| 168 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 171 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
| 169 | 172 |
| 170 // ResourceRequestAllowedNotifier::Observer implementation: | 173 // ResourceRequestAllowedNotifier::Observer implementation: |
| 171 virtual void OnResourceRequestsAllowed() OVERRIDE; | 174 virtual void OnResourceRequestsAllowed() OVERRIDE; |
| 172 | 175 |
| 173 // Performs a variations seed simulation with the given |seed| and |version| | 176 // Performs a variations seed simulation with the given |seed| and |version| |
| 174 // and logs the simulation results as histograms. | 177 // and logs the simulation results as histograms. |
| 175 void PerformSimulationWithVersion(scoped_ptr<VariationsSeed> seed, | 178 void PerformSimulationWithVersion(scoped_ptr<variations::VariationsSeed> seed, |
| 176 const base::Version& version); | 179 const base::Version& version); |
| 177 | 180 |
| 178 // Record the time of the most recent successful fetch. | 181 // Record the time of the most recent successful fetch. |
| 179 void RecordLastFetchTime(); | 182 void RecordLastFetchTime(); |
| 180 | 183 |
| 181 // The pref service used to store persist the variations seed. | 184 // The pref service used to store persist the variations seed. |
| 182 PrefService* local_state_; | 185 PrefService* local_state_; |
| 183 | 186 |
| 184 // Used for instantiating entropy providers for variations seed simulation. | 187 // Used for instantiating entropy providers for variations seed simulation. |
| 185 // Weak pointer. | 188 // Weak pointer. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 #endif | 230 #endif |
| 228 | 231 |
| 229 base::WeakPtrFactory<VariationsService> weak_ptr_factory_; | 232 base::WeakPtrFactory<VariationsService> weak_ptr_factory_; |
| 230 | 233 |
| 231 DISALLOW_COPY_AND_ASSIGN(VariationsService); | 234 DISALLOW_COPY_AND_ASSIGN(VariationsService); |
| 232 }; | 235 }; |
| 233 | 236 |
| 234 } // namespace chrome_variations | 237 } // namespace chrome_variations |
| 235 | 238 |
| 236 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_ | 239 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_ |
| OLD | NEW |