Chromium Code Reviews| 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 if (!base::Time::FromUTCExploded(exploded, &out_time)) { | |
| 117 // TODO(maksims): implement failure handling. | |
| 118 // We might just return |out_time|, which is Time(0). | |
| 119 NOTIMPLEMENTED(); | |
|
Alexei Svitkine (slow)
2016/06/28 15:27:40
Similar comment as vabr's - how can this fail? Sho
maksims (do not use this acc)
2016/06/29 05:48:59
In this case, DCHECK should be enough here as vabr
| |
| 120 } | |
| 121 return out_time; | |
| 116 } | 122 } |
| 117 | 123 |
| 118 VariationsSeedDateChangeState GetSeedDateChangeState( | 124 VariationsSeedDateChangeState GetSeedDateChangeState( |
| 119 const base::Time& server_seed_date, | 125 const base::Time& server_seed_date, |
| 120 const base::Time& stored_seed_date) { | 126 const base::Time& stored_seed_date) { |
| 121 if (server_seed_date < stored_seed_date) | 127 if (server_seed_date < stored_seed_date) |
| 122 return SEED_DATE_NEW_DATE_OLDER; | 128 return SEED_DATE_NEW_DATE_OLDER; |
| 123 | 129 |
| 124 if (TruncateToUTCDay(server_seed_date) != | 130 if (TruncateToUTCDay(server_seed_date) != |
| 125 TruncateToUTCDay(stored_seed_date)) { | 131 TruncateToUTCDay(stored_seed_date)) { |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 528 } | 534 } |
| 529 return true; | 535 return true; |
| 530 } | 536 } |
| 531 | 537 |
| 532 void VariationsSeedStore::ReportUnsupportedSeedFormatError() { | 538 void VariationsSeedStore::ReportUnsupportedSeedFormatError() { |
| 533 RecordSeedStoreHistogram( | 539 RecordSeedStoreHistogram( |
| 534 VARIATIONS_SEED_STORE_FAILED_UNSUPPORTED_SEED_FORMAT); | 540 VARIATIONS_SEED_STORE_FAILED_UNSUPPORTED_SEED_FORMAT); |
| 535 } | 541 } |
| 536 | 542 |
| 537 } // namespace variations | 543 } // namespace variations |
| OLD | NEW |