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 #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/build_time.h" | 9 #include "base/build_time.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 response_date, | 428 response_date, |
429 base::TimeDelta::FromMilliseconds(kServerTimeResolutionMs), | 429 base::TimeDelta::FromMilliseconds(kServerTimeResolutionMs), |
430 latency); | 430 latency); |
431 } | 431 } |
432 } | 432 } |
433 | 433 |
434 if (response_code != net::HTTP_OK) { | 434 if (response_code != net::HTTP_OK) { |
435 DVLOG(1) << "Variations server request returned non-HTTP_OK response code: " | 435 DVLOG(1) << "Variations server request returned non-HTTP_OK response code: " |
436 << response_code; | 436 << response_code; |
437 if (response_code == net::HTTP_NOT_MODIFIED) { | 437 if (response_code == net::HTTP_NOT_MODIFIED) { |
438 UMA_HISTOGRAM_MEDIUM_TIMES("Variations.FetchNotModifiedLatency", latency); | |
439 RecordLastFetchTime(); | 438 RecordLastFetchTime(); |
440 // Update the seed date value in local state (used for expiry check on | 439 // Update the seed date value in local state (used for expiry check on |
441 // next start up), since 304 is a successful response. | 440 // next start up), since 304 is a successful response. |
442 local_state_->SetInt64(prefs::kVariationsSeedDate, | 441 local_state_->SetInt64(prefs::kVariationsSeedDate, |
443 response_date.ToInternalValue()); | 442 response_date.ToInternalValue()); |
444 } else { | |
445 UMA_HISTOGRAM_MEDIUM_TIMES("Variations.FetchOtherLatency", latency); | |
446 } | 443 } |
447 return; | 444 return; |
448 } | 445 } |
449 UMA_HISTOGRAM_MEDIUM_TIMES("Variations.FetchSuccessLatency", latency); | |
450 | 446 |
451 std::string seed_data; | 447 std::string seed_data; |
452 bool success = request->GetResponseAsString(&seed_data); | 448 bool success = request->GetResponseAsString(&seed_data); |
453 DCHECK(success); | 449 DCHECK(success); |
454 | 450 |
455 std::string seed_signature; | 451 std::string seed_signature; |
456 request->GetResponseHeaders()->EnumerateHeader(NULL, | 452 request->GetResponseHeaders()->EnumerateHeader(NULL, |
457 "X-Seed-Signature", | 453 "X-Seed-Signature", |
458 &seed_signature); | 454 &seed_signature); |
459 if (seed_store_.StoreSeedData(seed_data, seed_signature, response_date)) | 455 if (seed_store_.StoreSeedData(seed_data, seed_signature, response_date)) |
(...skipping 18 matching lines...) Expand all Loading... |
478 | 474 |
479 void VariationsService::RecordLastFetchTime() { | 475 void VariationsService::RecordLastFetchTime() { |
480 // local_state_ is NULL in tests, so check it first. | 476 // local_state_ is NULL in tests, so check it first. |
481 if (local_state_) { | 477 if (local_state_) { |
482 local_state_->SetInt64(prefs::kVariationsLastFetchTime, | 478 local_state_->SetInt64(prefs::kVariationsLastFetchTime, |
483 base::Time::Now().ToInternalValue()); | 479 base::Time::Now().ToInternalValue()); |
484 } | 480 } |
485 } | 481 } |
486 | 482 |
487 } // namespace chrome_variations | 483 } // namespace chrome_variations |
OLD | NEW |