Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: net/disk_cache/simple/simple_index.cc

Issue 2109503002: Use saturated_cast<> instead of checked_cast<> for converting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: checkpoint Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | net/disk_cache/simple/simple_index_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | net/disk_cache/simple/simple_index_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698