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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 const base::TimeDelta latency = | 492 const base::TimeDelta latency = |
493 base::TimeTicks::Now() - last_request_started_time_; | 493 base::TimeTicks::Now() - last_request_started_time_; |
494 | 494 |
495 base::Time response_date; | 495 base::Time response_date; |
496 if (response_code == net::HTTP_OK || | 496 if (response_code == net::HTTP_OK || |
497 response_code == net::HTTP_NOT_MODIFIED) { | 497 response_code == net::HTTP_NOT_MODIFIED) { |
498 bool success = request->GetResponseHeaders()->GetDateValue(&response_date); | 498 bool success = request->GetResponseHeaders()->GetDateValue(&response_date); |
499 DCHECK(success || response_date.is_null()); | 499 DCHECK(success || response_date.is_null()); |
500 | 500 |
501 if (!response_date.is_null()) { | 501 if (!response_date.is_null()) { |
502 NetworkTimeTracker::BuildNotifierUpdateCallback().Run( | 502 g_browser_process->network_time_tracker()->UpdateNetworkTime( |
503 response_date, | 503 response_date, |
504 base::TimeDelta::FromMilliseconds(kServerTimeResolutionMs), | 504 base::TimeDelta::FromMilliseconds(kServerTimeResolutionMs), |
505 latency); | 505 latency, |
| 506 base::TimeTicks::Now()); |
506 } | 507 } |
507 } | 508 } |
508 | 509 |
509 if (response_code != net::HTTP_OK) { | 510 if (response_code != net::HTTP_OK) { |
510 DVLOG(1) << "Variations server request returned non-HTTP_OK response code: " | 511 DVLOG(1) << "Variations server request returned non-HTTP_OK response code: " |
511 << response_code; | 512 << response_code; |
512 if (response_code == net::HTTP_NOT_MODIFIED) { | 513 if (response_code == net::HTTP_NOT_MODIFIED) { |
513 RecordLastFetchTime(); | 514 RecordLastFetchTime(); |
514 // Update the seed date value in local state (used for expiry check on | 515 // Update the seed date value in local state (used for expiry check on |
515 // next start up), since 304 is a successful response. | 516 // next start up), since 304 is a successful response. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 | 548 |
548 void VariationsService::RecordLastFetchTime() { | 549 void VariationsService::RecordLastFetchTime() { |
549 // local_state_ is NULL in tests, so check it first. | 550 // local_state_ is NULL in tests, so check it first. |
550 if (local_state_) { | 551 if (local_state_) { |
551 local_state_->SetInt64(prefs::kVariationsLastFetchTime, | 552 local_state_->SetInt64(prefs::kVariationsLastFetchTime, |
552 base::Time::Now().ToInternalValue()); | 553 base::Time::Now().ToInternalValue()); |
553 } | 554 } |
554 } | 555 } |
555 | 556 |
556 } // namespace chrome_variations | 557 } // namespace chrome_variations |
OLD | NEW |