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 COMPONENTS_VARIATIONS_SERVICE_VARIATIONS_SERVICE_H_ | 5 #ifndef COMPONENTS_VARIATIONS_SERVICE_VARIATIONS_SERVICE_H_ |
6 #define COMPONENTS_VARIATIONS_SERVICE_VARIATIONS_SERVICE_H_ | 6 #define COMPONENTS_VARIATIONS_SERVICE_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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 // Starts the fetching process once, where |OnURLFetchComplete| is called with | 160 // Starts the fetching process once, where |OnURLFetchComplete| is called with |
161 // the response. | 161 // the response. |
162 virtual void DoActualFetch(); | 162 virtual void DoActualFetch(); |
163 | 163 |
164 // Stores the seed to prefs. Set as virtual and protected so that it can be | 164 // Stores the seed to prefs. Set as virtual and protected so that it can be |
165 // overridden by tests. | 165 // overridden by tests. |
166 virtual bool StoreSeed(const std::string& seed_data, | 166 virtual bool StoreSeed(const std::string& seed_data, |
167 const std::string& seed_signature, | 167 const std::string& seed_signature, |
168 const std::string& country_code, | 168 const std::string& country_code, |
169 const base::Time& date_fetched, | 169 const base::Time& date_fetched, |
170 bool is_delta_compressed); | 170 bool is_delta_compressed, |
| 171 bool is_gzip_compressed); |
171 | 172 |
172 // Creates the VariationsService with the given |local_state| prefs service | 173 // Creates the VariationsService with the given |local_state| prefs service |
173 // and |state_manager|. Does not take ownership of |state_manager|. Caller | 174 // and |state_manager|. Does not take ownership of |state_manager|. Caller |
174 // should ensure that |state_manager| is valid for the lifetime of this class. | 175 // should ensure that |state_manager| is valid for the lifetime of this class. |
175 // Use the |Create| factory method to create a VariationsService. | 176 // Use the |Create| factory method to create a VariationsService. |
176 VariationsService( | 177 VariationsService( |
177 scoped_ptr<VariationsServiceClient> client, | 178 scoped_ptr<VariationsServiceClient> client, |
178 scoped_ptr<web_resource::ResourceRequestAllowedNotifier> notifier, | 179 scoped_ptr<web_resource::ResourceRequestAllowedNotifier> notifier, |
179 PrefService* local_state, | 180 PrefService* local_state, |
180 metrics::MetricsStateManager* state_manager, | 181 metrics::MetricsStateManager* state_manager, |
181 const UIStringOverrider& ui_string_overrider); | 182 const UIStringOverrider& ui_string_overrider); |
182 | 183 |
| 184 // Sets the URL for querying the variations server. Used for testing. |
| 185 void set_variations_server_url(const GURL& url) { |
| 186 variations_server_url_ = url; |
| 187 } |
| 188 |
183 private: | 189 private: |
184 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, Observer); | 190 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, Observer); |
185 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedStoredWhenOKStatus); | 191 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedStoredWhenOKStatus); |
186 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedNotStoredWhenNonOKStatus); | 192 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedNotStoredWhenNonOKStatus); |
187 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedDateUpdatedOn304Status); | 193 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, InstanceManipulations); |
188 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, | 194 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, |
189 LoadPermanentConsistencyCountry); | 195 LoadPermanentConsistencyCountry); |
190 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, CountryHeader); | 196 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, CountryHeader); |
191 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, GetVariationsServerURL); | 197 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, GetVariationsServerURL); |
192 | 198 |
193 // Set of different possible values to report for the | 199 // Set of different possible values to report for the |
194 // Variations.LoadPermanentConsistencyCountryResult histogram. This enum must | 200 // Variations.LoadPermanentConsistencyCountryResult histogram. This enum must |
195 // be kept consistent with its counterpart in histograms.xml. | 201 // be kept consistent with its counterpart in histograms.xml. |
196 enum LoadPermanentConsistencyCountryResult { | 202 enum LoadPermanentConsistencyCountryResult { |
197 LOAD_COUNTRY_NO_PREF_NO_SEED = 0, | 203 LOAD_COUNTRY_NO_PREF_NO_SEED = 0, |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 base::ThreadChecker thread_checker_; | 312 base::ThreadChecker thread_checker_; |
307 | 313 |
308 base::WeakPtrFactory<VariationsService> weak_ptr_factory_; | 314 base::WeakPtrFactory<VariationsService> weak_ptr_factory_; |
309 | 315 |
310 DISALLOW_COPY_AND_ASSIGN(VariationsService); | 316 DISALLOW_COPY_AND_ASSIGN(VariationsService); |
311 }; | 317 }; |
312 | 318 |
313 } // namespace variations | 319 } // namespace variations |
314 | 320 |
315 #endif // COMPONENTS_VARIATIONS_SERVICE_VARIATIONS_SERVICE_H_ | 321 #endif // COMPONENTS_VARIATIONS_SERVICE_VARIATIONS_SERVICE_H_ |
OLD | NEW |