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_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_METRICS_VARIATIONS_SERVICE_H_ |
6 #define CHROME_BROWSER_METRICS_VARIATIONS_SERVICE_H_ | 6 #define CHROME_BROWSER_METRICS_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 22 matching lines...) Expand all Loading... | |
33 public: | 33 public: |
34 VariationsService(); | 34 VariationsService(); |
35 virtual ~VariationsService(); | 35 virtual ~VariationsService(); |
36 | 36 |
37 // Creates field trials based on Variations Seed loaded from local prefs. If | 37 // Creates field trials based on Variations Seed loaded from local prefs. If |
38 // there is a problem loading the seed data, all trials specified by the seed | 38 // there is a problem loading the seed data, all trials specified by the seed |
39 // may not be created. | 39 // may not be created. |
40 bool CreateTrialsFromSeed(PrefService* local_prefs); | 40 bool CreateTrialsFromSeed(PrefService* local_prefs); |
41 | 41 |
42 // Calls FetchVariationsSeed once and repeats this periodically. See | 42 // Calls FetchVariationsSeed once and repeats this periodically. See |
43 // implementation for details on the period. | 43 // implementation for details on the period. Must be called after |
44 // |CreateTrialsFromSeed|. | |
44 void StartRepeatedVariationsSeedFetch(); | 45 void StartRepeatedVariationsSeedFetch(); |
45 | 46 |
46 // Starts the fetching process once, where |OnURLFetchComplete| is called with | 47 // Starts the fetching process once, where |OnURLFetchComplete| is called with |
47 // the response. | 48 // the response. |
48 void FetchVariationsSeed(); | 49 void FetchVariationsSeed(); |
49 | 50 |
50 // net::URLFetcherDelegate implementation: | 51 // net::URLFetcherDelegate implementation: |
51 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 52 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
52 | 53 |
53 // Register Variations related prefs in Local State. | 54 // Register Variations related prefs in Local State. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 void CreateTrialFromStudy(const Study& study, | 121 void CreateTrialFromStudy(const Study& study, |
121 const base::Time& reference_date); | 122 const base::Time& reference_date); |
122 | 123 |
123 // Contains the current seed request. Will only have a value while a request | 124 // Contains the current seed request. Will only have a value while a request |
124 // is pending, and will be reset by |OnURLFetchComplete|. | 125 // is pending, and will be reset by |OnURLFetchComplete|. |
125 scoped_ptr<net::URLFetcher> pending_seed_request_; | 126 scoped_ptr<net::URLFetcher> pending_seed_request_; |
126 | 127 |
127 // The URL to use for querying the variations server. | 128 // The URL to use for querying the variations server. |
128 GURL variations_server_url_; | 129 GURL variations_server_url_; |
129 | 130 |
131 // Cached serial number from the most recently fetched variations seed. | |
132 std::string variations_serial_number_; | |
133 | |
134 // Tracks whether |CreateTrialsFromSeed| has been called, to ensure that | |
135 // it gets called prior to |StartRepeatedVariationsSeedFetch|. | |
136 bool create_trials_from_seed_called_; | |
Ilya Sherman
2012/08/02 23:40:49
nit: This seems a little hacky. Is there any way
Alexei Svitkine (slow)
2012/08/02 23:51:02
I can't think of a good way - the issue is that it
| |
137 | |
130 // The timer used to repeatedly ping the server. Keep this as an instance | 138 // The timer used to repeatedly ping the server. Keep this as an instance |
131 // member so if VariationsService goes out of scope, the timer is | 139 // member so if VariationsService goes out of scope, the timer is |
132 // automatically cancelled. | 140 // automatically canceled. |
133 base::RepeatingTimer<VariationsService> timer_; | 141 base::RepeatingTimer<VariationsService> timer_; |
134 }; | 142 }; |
135 | 143 |
136 } // namespace chrome_variations | 144 } // namespace chrome_variations |
137 | 145 |
138 #endif // CHROME_BROWSER_METRICS_VARIATIONS_SERVICE_H_ | 146 #endif // CHROME_BROWSER_METRICS_VARIATIONS_SERVICE_H_ |
OLD | NEW |