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

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

Issue 12251003: Fix variations seed being reset on a 304 response. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/metrics/variations/variations_service.h" 5 #include "chrome/browser/metrics/variations/variations_service.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/build_time.h" 10 #include "base/build_time.h"
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 response_code == net::HTTP_NOT_MODIFIED) { 280 response_code == net::HTTP_NOT_MODIFIED) {
281 bool success = request->GetResponseHeaders()->GetDateValue(&response_date); 281 bool success = request->GetResponseHeaders()->GetDateValue(&response_date);
282 DCHECK(success || response_date.is_null()); 282 DCHECK(success || response_date.is_null());
283 283
284 if (!response_date.is_null()) { 284 if (!response_date.is_null()) {
285 network_time_tracker_.UpdateNetworkTime( 285 network_time_tracker_.UpdateNetworkTime(
286 response_date, 286 response_date,
287 base::TimeDelta::FromMilliseconds(kServerTimeResolutionMs), 287 base::TimeDelta::FromMilliseconds(kServerTimeResolutionMs),
288 latency); 288 latency);
289 } 289 }
290 } else if (response_code != net::HTTP_OK) { 290 }
291
292 if (response_code != net::HTTP_OK) {
291 DVLOG(1) << "Variations server request returned non-HTTP_OK response code: " 293 DVLOG(1) << "Variations server request returned non-HTTP_OK response code: "
292 << response_code; 294 << response_code;
293 if (response_code == net::HTTP_NOT_MODIFIED) 295 if (response_code == net::HTTP_NOT_MODIFIED)
294 UMA_HISTOGRAM_MEDIUM_TIMES("Variations.FetchNotModifiedLatency", latency); 296 UMA_HISTOGRAM_MEDIUM_TIMES("Variations.FetchNotModifiedLatency", latency);
295 else 297 else
296 UMA_HISTOGRAM_MEDIUM_TIMES("Variations.FetchOtherLatency", latency); 298 UMA_HISTOGRAM_MEDIUM_TIMES("Variations.FetchOtherLatency", latency);
297 return; 299 return;
298 } 300 }
299 UMA_HISTOGRAM_MEDIUM_TIMES("Variations.FetchSuccessLatency", latency); 301 UMA_HISTOGRAM_MEDIUM_TIMES("Variations.FetchSuccessLatency", latency);
300 302
(...skipping 13 matching lines...) Expand all
314 // to call this method again until another failed attempt occurs. 316 // to call this method again until another failed attempt occurs.
315 DVLOG(1) << "Retrying fetch."; 317 DVLOG(1) << "Retrying fetch.";
316 DoActualFetch(); 318 DoActualFetch();
317 if (timer_.IsRunning()) 319 if (timer_.IsRunning())
318 timer_.Reset(); 320 timer_.Reset();
319 } 321 }
320 322
321 bool VariationsService::StoreSeedData(const std::string& seed_data, 323 bool VariationsService::StoreSeedData(const std::string& seed_data,
322 const base::Time& seed_date, 324 const base::Time& seed_date,
323 PrefService* local_prefs) { 325 PrefService* local_prefs) {
326 if (seed_data.empty()) {
327 VLOG(1) << "Variations Seed data from server is empty, rejecting the seed.";
328 return false;
329 }
330
324 // Only store the seed data if it parses correctly. 331 // Only store the seed data if it parses correctly.
325 TrialsSeed seed; 332 TrialsSeed seed;
326 if (!seed.ParseFromString(seed_data)) { 333 if (!seed.ParseFromString(seed_data)) {
327 VLOG(1) << "Variations Seed data from server is not in valid proto format, " 334 VLOG(1) << "Variations Seed data from server is not in valid proto format, "
328 << "rejecting the seed."; 335 << "rejecting the seed.";
329 return false; 336 return false;
330 } 337 }
331 338
332 std::string base64_seed_data; 339 std::string base64_seed_data;
333 if (!base::Base64Encode(seed_data, &base64_seed_data)) { 340 if (!base::Base64Encode(seed_data, &base64_seed_data)) {
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 variation_id); 586 variation_id);
580 } 587 }
581 } 588 }
582 589
583 trial->SetForced(); 590 trial->SetForced();
584 if (IsStudyExpired(study, reference_date)) 591 if (IsStudyExpired(study, reference_date))
585 trial->Disable(); 592 trial->Disable();
586 } 593 }
587 594
588 } // namespace chrome_variations 595 } // namespace chrome_variations
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698