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