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

Unified Diff: net/disk_cache/simple/simple_index.cc

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/disk_cache/simple/simple_index.h ('k') | net/disk_cache/simple/simple_index_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/simple/simple_index.cc
diff --git a/net/disk_cache/simple/simple_index.cc b/net/disk_cache/simple/simple_index.cc
index 555780119d3f147341c4cb40a8bd600f0ca42d21..0051cd0a3e8d71e3a8c3eae47e799960ec697632 100644
--- a/net/disk_cache/simple/simple_index.cc
+++ b/net/disk_cache/simple/simple_index.cc
@@ -45,9 +45,9 @@ const int kWriteToDiskOnBackgroundDelayMSecs = 100;
// Divides the cache space into this amount of parts to evict when only one part
// is left.
-const uint32 kEvictionMarginDivisor = 20;
+const uint32_t kEvictionMarginDivisor = 20;
-const uint32 kBytesInKb = 1024;
+const uint32_t kBytesInKb = 1024;
// Utility class used for timestamp comparisons in entry metadata while sorting.
class CompareHashesForTimestamp {
@@ -56,7 +56,8 @@ class CompareHashesForTimestamp {
public:
explicit CompareHashesForTimestamp(const EntrySet& set);
- bool operator()(uint64 hash1, uint64 hash2);
+ bool operator()(uint64_t hash1, uint64_t hash2);
+
private:
const EntrySet& entry_set_;
};
@@ -65,7 +66,7 @@ CompareHashesForTimestamp::CompareHashesForTimestamp(const EntrySet& set)
: entry_set_(set) {
}
-bool CompareHashesForTimestamp::operator()(uint64 hash1, uint64 hash2) {
+bool CompareHashesForTimestamp::operator()(uint64_t hash1, uint64_t hash2) {
EntrySet::const_iterator it1 = entry_set_.find(hash1);
DCHECK(it1 != entry_set_.end());
EntrySet::const_iterator it2 = entry_set_.find(hash2);
@@ -82,9 +83,9 @@ EntryMetadata::EntryMetadata()
entry_size_(0) {
}
-EntryMetadata::EntryMetadata(base::Time last_used_time, uint64 entry_size)
+EntryMetadata::EntryMetadata(base::Time last_used_time, uint64_t entry_size)
: last_used_time_seconds_since_epoch_(0),
- entry_size_(base::checked_cast<int32>(entry_size)) {
+ entry_size_(base::checked_cast<int32_t>(entry_size)) {
SetLastUsedTime(last_used_time);
}
@@ -104,37 +105,38 @@ void EntryMetadata::SetLastUsedTime(const base::Time& last_used_time) {
return;
}
- last_used_time_seconds_since_epoch_ = base::checked_cast<uint32>(
+ last_used_time_seconds_since_epoch_ = base::checked_cast<uint32_t>(
(last_used_time - base::Time::UnixEpoch()).InSeconds());
// Avoid accidental nullity.
if (last_used_time_seconds_since_epoch_ == 0)
last_used_time_seconds_since_epoch_ = 1;
}
-uint64 EntryMetadata::GetEntrySize() const {
+uint64_t EntryMetadata::GetEntrySize() const {
return entry_size_;
}
-void EntryMetadata::SetEntrySize(uint64 entry_size) {
- entry_size_ = base::checked_cast<int32>(entry_size);
+void EntryMetadata::SetEntrySize(uint64_t entry_size) {
+ entry_size_ = base::checked_cast<int32_t>(entry_size);
}
void EntryMetadata::Serialize(base::Pickle* pickle) const {
DCHECK(pickle);
- int64 internal_last_used_time = GetLastUsedTime().ToInternalValue();
+ int64_t internal_last_used_time = GetLastUsedTime().ToInternalValue();
pickle->WriteInt64(internal_last_used_time);
pickle->WriteUInt64(entry_size_);
}
bool EntryMetadata::Deserialize(base::PickleIterator* it) {
DCHECK(it);
- int64 tmp_last_used_time;
- uint64 tmp_entry_size;
+ int64_t tmp_last_used_time;
+ uint64_t tmp_entry_size;
if (!it->ReadInt64(&tmp_last_used_time) || !it->ReadUInt64(&tmp_entry_size) ||
- tmp_entry_size > static_cast<uint64>(std::numeric_limits<int32>::max()))
+ tmp_entry_size >
+ static_cast<uint64_t>(std::numeric_limits<int32_t>::max()))
return false;
SetLastUsedTime(base::Time::FromInternalValue(tmp_last_used_time));
- entry_size_ = static_cast<int32>(tmp_entry_size);
+ entry_size_ = static_cast<int32_t>(tmp_entry_size);
return true;
}
@@ -188,7 +190,7 @@ void SimpleIndex::Initialize(base::Time cache_mtime) {
index_file_->LoadIndexEntries(cache_mtime, reply, load_result);
}
-void SimpleIndex::SetMaxSize(uint64 max_bytes) {
+void SimpleIndex::SetMaxSize(uint64_t max_bytes) {
// Zero size means use the default.
if (max_bytes) {
max_size_ = max_bytes;
@@ -234,17 +236,17 @@ scoped_ptr<SimpleIndex::HashList> SimpleIndex::GetAllHashes() {
return GetEntriesBetween(base::Time(), base::Time());
}
-int32 SimpleIndex::GetEntryCount() const {
+int32_t SimpleIndex::GetEntryCount() const {
// TODO(pasko): return a meaningful initial estimate before initialized.
return entries_set_.size();
}
-uint64 SimpleIndex::GetCacheSize() const {
+uint64_t SimpleIndex::GetCacheSize() const {
DCHECK(initialized_);
return cache_size_;
}
-void SimpleIndex::Insert(uint64 entry_hash) {
+void SimpleIndex::Insert(uint64_t entry_hash) {
DCHECK(io_thread_checker_.CalledOnValidThread());
// Upon insert we don't know yet the size of the entry.
// It will be updated later when the SimpleEntryImpl finishes opening or
@@ -256,7 +258,7 @@ void SimpleIndex::Insert(uint64 entry_hash) {
PostponeWritingToDisk();
}
-void SimpleIndex::Remove(uint64 entry_hash) {
+void SimpleIndex::Remove(uint64_t entry_hash) {
DCHECK(io_thread_checker_.CalledOnValidThread());
EntrySet::iterator it = entries_set_.find(entry_hash);
if (it != entries_set_.end()) {
@@ -269,13 +271,13 @@ void SimpleIndex::Remove(uint64 entry_hash) {
PostponeWritingToDisk();
}
-bool SimpleIndex::Has(uint64 hash) const {
+bool SimpleIndex::Has(uint64_t hash) const {
DCHECK(io_thread_checker_.CalledOnValidThread());
// If not initialized, always return true, forcing it to go to the disk.
return !initialized_ || entries_set_.count(hash) > 0;
}
-bool SimpleIndex::UseIfExists(uint64 entry_hash) {
+bool SimpleIndex::UseIfExists(uint64_t entry_hash) {
DCHECK(io_thread_checker_.CalledOnValidThread());
// Always update the last used time, even if it is during initialization.
// It will be merged later.
@@ -301,7 +303,7 @@ void SimpleIndex::StartEvictionIfNeeded() {
SIMPLE_CACHE_UMA(
MEMORY_KB, "Eviction.MaxCacheSizeOnStart2", cache_type_,
static_cast<base::HistogramBase::Sample>(max_size_ / kBytesInKb));
- std::vector<uint64> entry_hashes;
+ std::vector<uint64_t> entry_hashes;
entry_hashes.reserve(entries_set_.size());
for (EntrySet::const_iterator it = entries_set_.begin(),
end = entries_set_.end(); it != end; ++it) {
@@ -311,8 +313,8 @@ void SimpleIndex::StartEvictionIfNeeded() {
CompareHashesForTimestamp(entries_set_));
// Remove as many entries from the index to get below |low_watermark_|.
- std::vector<uint64>::iterator it = entry_hashes.begin();
- uint64 evicted_so_far_size = 0;
+ std::vector<uint64_t>::iterator it = entry_hashes.begin();
+ uint64_t evicted_so_far_size = 0;
while (evicted_so_far_size < cache_size_ - low_watermark_) {
DCHECK(it != entry_hashes.end());
EntrySet::iterator found_meta = entries_set_.find(*it);
@@ -337,7 +339,7 @@ void SimpleIndex::StartEvictionIfNeeded() {
AsWeakPtr()));
}
-bool SimpleIndex::UpdateEntrySize(uint64 entry_hash, int64 entry_size) {
+bool SimpleIndex::UpdateEntrySize(uint64_t entry_hash, int64_t entry_size) {
DCHECK(io_thread_checker_.CalledOnValidThread());
EntrySet::iterator it = entries_set_.find(entry_hash);
if (it == entries_set_.end())
@@ -365,7 +367,7 @@ void SimpleIndex::EvictionDone(int result) {
// static
void SimpleIndex::InsertInEntrySet(
- uint64 entry_hash,
+ uint64_t entry_hash,
const disk_cache::EntryMetadata& entry_metadata,
EntrySet* entry_set) {
DCHECK(entry_set);
@@ -383,7 +385,7 @@ void SimpleIndex::PostponeWritingToDisk() {
}
void SimpleIndex::UpdateEntryIteratorSize(EntrySet::iterator* it,
- int64 entry_size) {
+ int64_t entry_size) {
// Update the total cache size with the new entry size.
DCHECK(io_thread_checker_.CalledOnValidThread());
DCHECK_GE(cache_size_, (*it)->second.GetEntrySize());
@@ -399,7 +401,7 @@ void SimpleIndex::MergeInitializingSet(
EntrySet* index_file_entries = &load_result->entries;
- for (base::hash_set<uint64>::const_iterator it = removed_entries_.begin();
+ for (base::hash_set<uint64_t>::const_iterator it = removed_entries_.begin();
it != removed_entries_.end(); ++it) {
index_file_entries->erase(*it);
}
@@ -407,7 +409,7 @@ void SimpleIndex::MergeInitializingSet(
for (EntrySet::const_iterator it = entries_set_.begin();
it != entries_set_.end(); ++it) {
- const uint64 entry_hash = it->first;
+ const uint64_t entry_hash = it->first;
std::pair<EntrySet::iterator, bool> insert_result =
index_file_entries->insert(EntrySet::value_type(entry_hash,
EntryMetadata()));
@@ -415,7 +417,7 @@ void SimpleIndex::MergeInitializingSet(
possibly_inserted_entry->second = it->second;
}
- uint64 merged_cache_size = 0;
+ uint64_t merged_cache_size = 0;
for (EntrySet::iterator it = index_file_entries->begin();
it != index_file_entries->end(); ++it) {
merged_cache_size += it->second.GetEntrySize();
« no previous file with comments | « net/disk_cache/simple/simple_index.h ('k') | net/disk_cache/simple/simple_index_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698