| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "net/disk_cache/simple/simple_index.h" | 5 #include "net/disk_cache/simple/simple_index.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 base::TimeDelta::FromSeconds(last_used_time_seconds_since_epoch_); | 98 base::TimeDelta::FromSeconds(last_used_time_seconds_since_epoch_); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void EntryMetadata::SetLastUsedTime(const base::Time& last_used_time) { | 101 void EntryMetadata::SetLastUsedTime(const base::Time& last_used_time) { |
| 102 // Preserve nullity. | 102 // Preserve nullity. |
| 103 if (last_used_time.is_null()) { | 103 if (last_used_time.is_null()) { |
| 104 last_used_time_seconds_since_epoch_ = 0; | 104 last_used_time_seconds_since_epoch_ = 0; |
| 105 return; | 105 return; |
| 106 } | 106 } |
| 107 | 107 |
| 108 last_used_time_seconds_since_epoch_ = base::checked_cast<uint32_t>( | 108 last_used_time_seconds_since_epoch_ = base::saturated_cast<uint32_t>( |
| 109 (last_used_time - base::Time::UnixEpoch()).InSeconds()); | 109 (last_used_time - base::Time::UnixEpoch()).InSeconds()); |
| 110 // Avoid accidental nullity. | 110 // Avoid accidental nullity. |
| 111 if (last_used_time_seconds_since_epoch_ == 0) | 111 if (last_used_time_seconds_since_epoch_ == 0) |
| 112 last_used_time_seconds_since_epoch_ = 1; | 112 last_used_time_seconds_since_epoch_ = 1; |
| 113 } | 113 } |
| 114 | 114 |
| 115 uint64_t EntryMetadata::GetEntrySize() const { | 115 uint64_t EntryMetadata::GetEntrySize() const { |
| 116 return entry_size_; | 116 return entry_size_; |
| 117 } | 117 } |
| 118 | 118 |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 start - last_write_to_disk_); | 483 start - last_write_to_disk_); |
| 484 } | 484 } |
| 485 } | 485 } |
| 486 last_write_to_disk_ = start; | 486 last_write_to_disk_ = start; |
| 487 | 487 |
| 488 index_file_->WriteToDisk(reason, entries_set_, cache_size_, start, | 488 index_file_->WriteToDisk(reason, entries_set_, cache_size_, start, |
| 489 app_on_background_, base::Closure()); | 489 app_on_background_, base::Closure()); |
| 490 } | 490 } |
| 491 | 491 |
| 492 } // namespace disk_cache | 492 } // namespace disk_cache |
| OLD | NEW |