| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/variations/variations_seed_store.h" | 5 #include "components/variations/variations_seed_store.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // 2014-03-11 10:18:03.1 UTC, it will return a time representing | 105 // 2014-03-11 10:18:03.1 UTC, it will return a time representing |
| 106 // 2014-03-11 00:00:00.0 UTC. | 106 // 2014-03-11 00:00:00.0 UTC. |
| 107 base::Time TruncateToUTCDay(const base::Time& time) { | 107 base::Time TruncateToUTCDay(const base::Time& time) { |
| 108 base::Time::Exploded exploded; | 108 base::Time::Exploded exploded; |
| 109 time.UTCExplode(&exploded); | 109 time.UTCExplode(&exploded); |
| 110 exploded.hour = 0; | 110 exploded.hour = 0; |
| 111 exploded.minute = 0; | 111 exploded.minute = 0; |
| 112 exploded.second = 0; | 112 exploded.second = 0; |
| 113 exploded.millisecond = 0; | 113 exploded.millisecond = 0; |
| 114 | 114 |
| 115 return base::Time::FromUTCExploded(exploded); | 115 base::Time out_time; |
| 116 bool conversion_success = base::Time::FromUTCExploded(exploded, &out_time); |
| 117 DCHECK(conversion_success); |
| 118 return out_time; |
| 116 } | 119 } |
| 117 | 120 |
| 118 VariationsSeedDateChangeState GetSeedDateChangeState( | 121 VariationsSeedDateChangeState GetSeedDateChangeState( |
| 119 const base::Time& server_seed_date, | 122 const base::Time& server_seed_date, |
| 120 const base::Time& stored_seed_date) { | 123 const base::Time& stored_seed_date) { |
| 121 if (server_seed_date < stored_seed_date) | 124 if (server_seed_date < stored_seed_date) |
| 122 return SEED_DATE_NEW_DATE_OLDER; | 125 return SEED_DATE_NEW_DATE_OLDER; |
| 123 | 126 |
| 124 if (TruncateToUTCDay(server_seed_date) != | 127 if (TruncateToUTCDay(server_seed_date) != |
| 125 TruncateToUTCDay(stored_seed_date)) { | 128 TruncateToUTCDay(stored_seed_date)) { |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 } | 531 } |
| 529 return true; | 532 return true; |
| 530 } | 533 } |
| 531 | 534 |
| 532 void VariationsSeedStore::ReportUnsupportedSeedFormatError() { | 535 void VariationsSeedStore::ReportUnsupportedSeedFormatError() { |
| 533 RecordSeedStoreHistogram( | 536 RecordSeedStoreHistogram( |
| 534 VARIATIONS_SEED_STORE_FAILED_UNSUPPORTED_SEED_FORMAT); | 537 VARIATIONS_SEED_STORE_FAILED_UNSUPPORTED_SEED_FORMAT); |
| 535 } | 538 } |
| 536 | 539 |
| 537 } // namespace variations | 540 } // namespace variations |
| OLD | NEW |