Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: chrome/browser/metrics/variations/variations_service.h

Issue 1200233005: Support delta-compressed variations server responses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing missing return in !is_compressed case. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // disabled. 145 // disabled.
146 std::string GetInvalidVariationsSeedSignature() const; 146 std::string GetInvalidVariationsSeedSignature() const;
147 147
148 protected: 148 protected:
149 // Starts the fetching process once, where |OnURLFetchComplete| is called with 149 // Starts the fetching process once, where |OnURLFetchComplete| is called with
150 // the response. 150 // the response.
151 virtual void DoActualFetch(); 151 virtual void DoActualFetch();
152 152
153 // Stores the seed to prefs. Set as virtual and protected so that it can be 153 // Stores the seed to prefs. Set as virtual and protected so that it can be
154 // overridden by tests. 154 // overridden by tests.
155 virtual void StoreSeed(const std::string& seed_data, 155 virtual bool StoreSeed(const std::string& seed_data,
156 const std::string& seed_signature, 156 const std::string& seed_signature,
157 const base::Time& date_fetched); 157 const std::string& country_code,
158 const base::Time& date_fetched,
159 bool is_delta_compressed);
158 160
159 // Creates the VariationsService with the given |local_state| prefs service 161 // Creates the VariationsService with the given |local_state| prefs service
160 // and |state_manager|. This instance will take ownership of |notifier|. 162 // and |state_manager|. This instance will take ownership of |notifier|.
161 // Does not take ownership of |state_manager|. Caller should ensure that 163 // Does not take ownership of |state_manager|. Caller should ensure that
162 // |state_manager| is valid for the lifetime of this class. Use the |Create| 164 // |state_manager| is valid for the lifetime of this class. Use the |Create|
163 // factory method to create a VariationsService. 165 // factory method to create a VariationsService.
164 VariationsService(web_resource::ResourceRequestAllowedNotifier* notifier, 166 VariationsService(web_resource::ResourceRequestAllowedNotifier* notifier,
165 PrefService* local_state, 167 PrefService* local_state,
166 metrics::MetricsStateManager* state_manager); 168 metrics::MetricsStateManager* state_manager);
167 169
168 private: 170 private:
169 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, Observer); 171 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, Observer);
170 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedStoredWhenOKStatus); 172 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedStoredWhenOKStatus);
171 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedNotStoredWhenNonOKStatus); 173 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedNotStoredWhenNonOKStatus);
172 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedDateUpdatedOn304Status); 174 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedDateUpdatedOn304Status);
173 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, 175 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest,
174 LoadPermanentConsistencyCountry); 176 LoadPermanentConsistencyCountry);
177 FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, CountryHeader);
175 178
176 // Set of different possible values to report for the 179 // Set of different possible values to report for the
177 // Variations.LoadPermanentConsistencyCountryResult histogram. This enum must 180 // Variations.LoadPermanentConsistencyCountryResult histogram. This enum must
178 // be kept consistent with its counterpart in histograms.xml. 181 // be kept consistent with its counterpart in histograms.xml.
179 enum LoadPermanentConsistencyCountryResult { 182 enum LoadPermanentConsistencyCountryResult {
180 LOAD_COUNTRY_NO_PREF_NO_SEED = 0, 183 LOAD_COUNTRY_NO_PREF_NO_SEED = 0,
181 LOAD_COUNTRY_NO_PREF_HAS_SEED, 184 LOAD_COUNTRY_NO_PREF_HAS_SEED,
182 LOAD_COUNTRY_INVALID_PREF_NO_SEED, 185 LOAD_COUNTRY_INVALID_PREF_NO_SEED,
183 LOAD_COUNTRY_INVALID_PREF_HAS_SEED, 186 LOAD_COUNTRY_INVALID_PREF_HAS_SEED,
184 LOAD_COUNTRY_HAS_PREF_NO_SEED_VERSION_EQ, 187 LOAD_COUNTRY_HAS_PREF_NO_SEED_VERSION_EQ,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 // The URL to use for querying the variations server. 254 // The URL to use for querying the variations server.
252 GURL variations_server_url_; 255 GURL variations_server_url_;
253 256
254 // Tracks whether |CreateTrialsFromSeed| has been called, to ensure that 257 // Tracks whether |CreateTrialsFromSeed| has been called, to ensure that
255 // it gets called prior to |StartRepeatedVariationsSeedFetch|. 258 // it gets called prior to |StartRepeatedVariationsSeedFetch|.
256 bool create_trials_from_seed_called_; 259 bool create_trials_from_seed_called_;
257 260
258 // Tracks whether the initial request to the variations server had completed. 261 // Tracks whether the initial request to the variations server had completed.
259 bool initial_request_completed_; 262 bool initial_request_completed_;
260 263
264 // Indicates that the next request to the variations service shouldn't specify
265 // that it supports delta compression. Set to true when a delta compressed
266 // response encountered an error.
267 bool disable_deltas_for_next_request_;
268
261 // Helper class used to tell this service if it's allowed to make network 269 // Helper class used to tell this service if it's allowed to make network
262 // resource requests. 270 // resource requests.
263 scoped_ptr<web_resource::ResourceRequestAllowedNotifier> 271 scoped_ptr<web_resource::ResourceRequestAllowedNotifier>
264 resource_request_allowed_notifier_; 272 resource_request_allowed_notifier_;
265 273
266 // The start time of the last seed request. This is used to measure the 274 // The start time of the last seed request. This is used to measure the
267 // latency of seed requests. Initially zero. 275 // latency of seed requests. Initially zero.
268 base::TimeTicks last_request_started_time_; 276 base::TimeTicks last_request_started_time_;
269 277
270 // The number of requests to the variations server that have been performed. 278 // The number of requests to the variations server that have been performed.
(...skipping 10 matching lines...) Expand all
281 base::ThreadChecker thread_checker_; 289 base::ThreadChecker thread_checker_;
282 290
283 base::WeakPtrFactory<VariationsService> weak_ptr_factory_; 291 base::WeakPtrFactory<VariationsService> weak_ptr_factory_;
284 292
285 DISALLOW_COPY_AND_ASSIGN(VariationsService); 293 DISALLOW_COPY_AND_ASSIGN(VariationsService);
286 }; 294 };
287 295
288 } // namespace chrome_variations 296 } // namespace chrome_variations
289 297
290 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_ 298 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698