| Index: net/disk_cache/blockfile/backend_impl_v3.cc
|
| diff --git a/net/disk_cache/blockfile/backend_impl_v3.cc b/net/disk_cache/blockfile/backend_impl_v3.cc
|
| index ce0b8d01f13cdb9f026dbaf2c1cda405dbf1b985..e860abafe42ed4a6f09cc72ae3ab68d35b632917 100644
|
| --- a/net/disk_cache/blockfile/backend_impl_v3.cc
|
| +++ b/net/disk_cache/blockfile/backend_impl_v3.cc
|
| @@ -90,7 +90,8 @@ int BackendImplV3::Init(const CompletionCallback& callback) {
|
| // ------------------------------------------------------------------------
|
|
|
| #if defined(V3_NOT_JUST_YET_READY)
|
| -int BackendImplV3::OpenPrevEntry(void** iter, Entry** prev_entry,
|
| +int BackendImplV3::OpenPrevEntry(void** iter,
|
| + Entry** prev_entry,
|
| const CompletionCallback& callback) {
|
| DCHECK(!callback.is_null());
|
| return OpenFollowingEntry(true, iter, prev_entry, callback);
|
| @@ -120,7 +121,8 @@ void BackendImplV3::SetType(net::CacheType type) {
|
| cache_type_ = type;
|
| }
|
|
|
| -bool BackendImplV3::CreateBlock(FileType block_type, int block_count,
|
| +bool BackendImplV3::CreateBlock(FileType block_type,
|
| + int block_count,
|
| Addr* block_address) {
|
| return block_files_.CreateBlock(block_type, block_count, block_address);
|
| }
|
| @@ -236,7 +238,7 @@ bool BackendImplV3::IsLoaded() const {
|
| }
|
|
|
| std::string BackendImplV3::HistogramName(const char* name) const {
|
| - static const char* names[] = { "Http", "", "Media", "AppCache", "Shader" };
|
| + static const char* names[] = {"Http", "", "Media", "AppCache", "Shader"};
|
| DCHECK_NE(cache_type_, net::MEMORY_CACHE);
|
| return base::StringPrintf("DiskCache3.%s_%s", name, names[cache_type_]);
|
| }
|
| @@ -279,9 +281,11 @@ void BackendImplV3::FirstEviction() {
|
|
|
| if (!use_time)
|
| use_time = 1;
|
| - CACHE_UMA(COUNTS_10000, "FirstEntryAccessRate",
|
| + CACHE_UMA(COUNTS_10000,
|
| + "FirstEntryAccessRate",
|
| static_cast<int>(header->num_entries / use_time));
|
| - CACHE_UMA(COUNTS, "FirstByteIORate",
|
| + CACHE_UMA(COUNTS,
|
| + "FirstByteIORate",
|
| static_cast<int>((header->num_bytes / 1024) / use_time));
|
|
|
| int avg_size = header->num_bytes / GetEntryCount();
|
| @@ -293,11 +297,14 @@ void BackendImplV3::FirstEviction() {
|
|
|
| if (!lru_eviction_) {
|
| CACHE_UMA(PERCENTAGE, "FirstResurrectRatio", stats_.GetResurrectRatio());
|
| - CACHE_UMA(PERCENTAGE, "FirstNoUseRatio",
|
| + CACHE_UMA(PERCENTAGE,
|
| + "FirstNoUseRatio",
|
| header->num_no_use_entries * 100 / header->num_entries);
|
| - CACHE_UMA(PERCENTAGE, "FirstLowUseRatio",
|
| + CACHE_UMA(PERCENTAGE,
|
| + "FirstLowUseRatio",
|
| header->num_low_use_entries * 100 / header->num_entries);
|
| - CACHE_UMA(PERCENTAGE, "FirstHighUseRatio",
|
| + CACHE_UMA(PERCENTAGE,
|
| + "FirstHighUseRatio",
|
| header->num_high_use_entries * 100 / header->num_entries);
|
| }
|
|
|
| @@ -430,7 +437,8 @@ int32 BackendImplV3::GetEntryCount() const {
|
| return index_.header()->num_entries;
|
| }
|
|
|
| -int BackendImplV3::OpenEntry(const std::string& key, Entry** entry,
|
| +int BackendImplV3::OpenEntry(const std::string& key,
|
| + Entry** entry,
|
| const CompletionCallback& callback) {
|
| if (disabled_)
|
| return NULL;
|
| @@ -464,7 +472,8 @@ int BackendImplV3::OpenEntry(const std::string& key, Entry** entry,
|
| eviction_.OnOpenEntry(cache_entry);
|
| entry_count_++;
|
|
|
| - Trace("Open hash 0x%x end: 0x%x", hash,
|
| + Trace("Open hash 0x%x end: 0x%x",
|
| + hash,
|
| cache_entry->entry()->address().value());
|
| CACHE_UMA(AGE_MS, "OpenTime", 0, start);
|
| CACHE_UMA(COUNTS_10000, "AllOpenBySize.Hit", 0, current_size);
|
| @@ -475,7 +484,8 @@ int BackendImplV3::OpenEntry(const std::string& key, Entry** entry,
|
| return cache_entry;
|
| }
|
|
|
| -int BackendImplV3::CreateEntry(const std::string& key, Entry** entry,
|
| +int BackendImplV3::CreateEntry(const std::string& key,
|
| + Entry** entry,
|
| const CompletionCallback& callback) {
|
| if (disabled_ || key.empty())
|
| return NULL;
|
| @@ -626,8 +636,7 @@ int BackendImplV3::DoomEntriesBetween(base::Time initial_time,
|
| node = next;
|
| next = OpenNextEntryImpl(&iter);
|
|
|
| - if (node->GetLastUsed() >= initial_time &&
|
| - node->GetLastUsed() < end_time) {
|
| + if (node->GetLastUsed() >= initial_time && node->GetLastUsed() < end_time) {
|
| node->DoomImpl();
|
| } else if (node->GetLastUsed() < initial_time) {
|
| if (next)
|
| @@ -667,7 +676,8 @@ int BackendImplV3::DoomEntriesSince(base::Time initial_time,
|
| }
|
| }
|
|
|
| -int BackendImplV3::OpenNextEntry(void** iter, Entry** next_entry,
|
| +int BackendImplV3::OpenNextEntry(void** iter,
|
| + Entry** next_entry,
|
| const CompletionCallback& callback) {
|
| DCHECK(!callback.is_null());
|
| background_queue_.OpenNextEntry(iter, next_entry, callback);
|
| @@ -675,8 +685,7 @@ int BackendImplV3::OpenNextEntry(void** iter, Entry** next_entry,
|
| }
|
|
|
| void BackendImplV3::EndEnumeration(void** iter) {
|
| - scoped_ptr<IndexIterator> iterator(
|
| - reinterpret_cast<IndexIterator*>(*iter));
|
| + scoped_ptr<IndexIterator> iterator(reinterpret_cast<IndexIterator*>(*iter));
|
| *iter = NULL;
|
| }
|
|
|
| @@ -758,7 +767,7 @@ void BackendImplV3::AdjustMaxCacheSize(int table_len) {
|
| // If we already have a table, adjust the size to it.
|
| int current_max_size = MaxStorageSizeForTable(table_len);
|
| if (max_size_ > current_max_size)
|
| - max_size_= current_max_size;
|
| + max_size_ = current_max_size;
|
| }
|
|
|
| bool BackendImplV3::InitStats() {
|
| @@ -787,8 +796,8 @@ bool BackendImplV3::InitStats() {
|
| return false;
|
|
|
| scoped_ptr<char[]> data(new char[size]);
|
| - size_t offset = address.start_block() * address.BlockSize() +
|
| - kBlockHeaderSize;
|
| + size_t offset =
|
| + address.start_block() * address.BlockSize() + kBlockHeaderSize;
|
| if (!file->Read(data.get(), size, offset))
|
| return false;
|
|
|
| @@ -812,8 +821,8 @@ void BackendImplV3::StoreStats() {
|
| if (!file)
|
| return;
|
|
|
| - size_t offset = address.start_block() * address.BlockSize() +
|
| - kBlockHeaderSize;
|
| + size_t offset =
|
| + address.start_block() * address.BlockSize() + kBlockHeaderSize;
|
| file->Write(data.get(), size, offset); // ignore result.
|
| }
|
|
|
| @@ -921,8 +930,8 @@ int BackendImplV3::NewEntry(Addr address, EntryImplV3** entry) {
|
| return ERR_INVALID_ENTRY;
|
| }
|
|
|
| - STRESS_DCHECK(block_files_.IsValid(
|
| - Addr(cache_entry->entry()->Data()->rankings_node)));
|
| + STRESS_DCHECK(
|
| + block_files_.IsValid(Addr(cache_entry->entry()->Data()->rankings_node)));
|
|
|
| if (!cache_entry->LoadNodeAddress())
|
| return ERR_READ_FAILURE;
|
| @@ -950,7 +959,8 @@ int BackendImplV3::NewEntry(Addr address, EntryImplV3** entry) {
|
| cache_entry->SetDirtyFlag(GetCurrentEntryId());
|
|
|
| if (cache_entry->dirty()) {
|
| - Trace("Dirty entry 0x%p 0x%x", reinterpret_cast<void*>(cache_entry.get()),
|
| + Trace("Dirty entry 0x%p 0x%x",
|
| + reinterpret_cast<void*>(cache_entry.get()),
|
| address.value());
|
| }
|
|
|
| @@ -962,7 +972,8 @@ int BackendImplV3::NewEntry(Addr address, EntryImplV3** entry) {
|
| }
|
|
|
| // This is the actual implementation for OpenNextEntry and OpenPrevEntry.
|
| -int BackendImplV3::OpenFollowingEntry(bool forward, void** iter,
|
| +int BackendImplV3::OpenFollowingEntry(bool forward,
|
| + void** iter,
|
| Entry** next_entry,
|
| const CompletionCallback& callback) {
|
| if (disabled_)
|
| @@ -983,8 +994,8 @@ int BackendImplV3::OpenFollowingEntry(bool forward, void** iter,
|
| // Get an entry from each list.
|
| for (int i = 0; i < kListsToSearch; i++) {
|
| EntryImpl* temp = NULL;
|
| - ret |= OpenFollowingEntryFromList(forward, static_cast<Rankings::List>(i),
|
| - &iterator->nodes[i], &temp);
|
| + ret |= OpenFollowingEntryFromList(
|
| + forward, static_cast<Rankings::List>(i), &iterator->nodes[i], &temp);
|
| entries[i].swap(&temp); // The entry was already addref'd.
|
| }
|
| if (!ret)
|
| @@ -995,8 +1006,8 @@ int BackendImplV3::OpenFollowingEntry(bool forward, void** iter,
|
| for (int i = 0; i < kListsToSearch; i++) {
|
| EntryImpl* temp = NULL;
|
| if (iterator->list == i) {
|
| - OpenFollowingEntryFromList(forward, iterator->list,
|
| - &iterator->nodes[i], &temp);
|
| + OpenFollowingEntryFromList(
|
| + forward, iterator->list, &iterator->nodes[i], &temp);
|
| } else {
|
| temp = GetEnumeratedEntry(iterator->nodes[i],
|
| static_cast<Rankings::List>(i));
|
| @@ -1103,7 +1114,9 @@ int BackendImplV3::SyncInit() {
|
| // Create a recurrent timer of 30 secs.
|
| int timer_delay = unit_test_ ? 1000 : 30000;
|
| timer_.reset(new base::RepeatingTimer<BackendImplV3>());
|
| - timer_->Start(FROM_HERE, TimeDelta::FromMilliseconds(timer_delay), this,
|
| + timer_->Start(FROM_HERE,
|
| + TimeDelta::FromMilliseconds(timer_delay),
|
| + this,
|
| &BackendImplV3::OnStatsTimer);
|
| }
|
|
|
| @@ -1322,17 +1335,22 @@ void BackendImplV3::ReportStats() {
|
| max_size++;
|
| CACHE_UMA(PERCENTAGE, "UsedSpace", current_size * 100 / max_size);
|
|
|
| - CACHE_UMA(COUNTS_10000, "AverageOpenEntries",
|
| + CACHE_UMA(COUNTS_10000,
|
| + "AverageOpenEntries",
|
| static_cast<int>(stats_.GetCounter(Stats::OPEN_ENTRIES)));
|
| - CACHE_UMA(COUNTS_10000, "MaxOpenEntries",
|
| + CACHE_UMA(COUNTS_10000,
|
| + "MaxOpenEntries",
|
| static_cast<int>(stats_.GetCounter(Stats::MAX_ENTRIES)));
|
| stats_.SetCounter(Stats::MAX_ENTRIES, 0);
|
|
|
| - CACHE_UMA(COUNTS_10000, "TotalFatalErrors",
|
| + CACHE_UMA(COUNTS_10000,
|
| + "TotalFatalErrors",
|
| static_cast<int>(stats_.GetCounter(Stats::FATAL_ERROR)));
|
| - CACHE_UMA(COUNTS_10000, "TotalDoomCache",
|
| + CACHE_UMA(COUNTS_10000,
|
| + "TotalDoomCache",
|
| static_cast<int>(stats_.GetCounter(Stats::DOOM_CACHE)));
|
| - CACHE_UMA(COUNTS_10000, "TotalDoomRecentEntries",
|
| + CACHE_UMA(COUNTS_10000,
|
| + "TotalDoomRecentEntries",
|
| static_cast<int>(stats_.GetCounter(Stats::DOOM_RECENT)));
|
| stats_.SetCounter(Stats::FATAL_ERROR, 0);
|
| stats_.SetCounter(Stats::DOOM_CACHE, 0);
|
| @@ -1375,13 +1393,17 @@ void BackendImplV3::ReportStats() {
|
|
|
| if (!lru_eviction_) {
|
| CACHE_UMA(PERCENTAGE, "ResurrectRatio", stats_.GetResurrectRatio());
|
| - CACHE_UMA(PERCENTAGE, "NoUseRatio",
|
| + CACHE_UMA(PERCENTAGE,
|
| + "NoUseRatio",
|
| header->num_no_use_entries * 100 / header->num_entries);
|
| - CACHE_UMA(PERCENTAGE, "LowUseRatio",
|
| + CACHE_UMA(PERCENTAGE,
|
| + "LowUseRatio",
|
| header->num_low_use_entries * 100 / header->num_entries);
|
| - CACHE_UMA(PERCENTAGE, "HighUseRatio",
|
| + CACHE_UMA(PERCENTAGE,
|
| + "HighUseRatio",
|
| header->num_high_use_entries * 100 / header->num_entries);
|
| - CACHE_UMA(PERCENTAGE, "DeletedRatio",
|
| + CACHE_UMA(PERCENTAGE,
|
| + "DeletedRatio",
|
| header->num_evicted_entries * 100 / header->num_entries);
|
| }
|
|
|
| @@ -1498,8 +1520,8 @@ int BackendImplV3::CheckAllEntries() {
|
|
|
| Trace("CheckAllEntries End");
|
| if (num_entries + num_dirty != data_->header.num_entries) {
|
| - LOG(ERROR) << "Number of entries " << num_entries << " " << num_dirty <<
|
| - " " << data_->header.num_entries;
|
| + LOG(ERROR) << "Number of entries " << num_entries << " " << num_dirty << " "
|
| + << data_->header.num_entries;
|
| DCHECK_LT(num_entries, data_->header.num_entries);
|
| return ERR_NUM_ENTRIES_MISMATCH;
|
| }
|
| @@ -1554,12 +1576,14 @@ int32 BackendImplV3::GetEntryCount() const {
|
| return 0;
|
| }
|
|
|
| -int BackendImplV3::OpenEntry(const std::string& key, Entry** entry,
|
| +int BackendImplV3::OpenEntry(const std::string& key,
|
| + Entry** entry,
|
| const CompletionCallback& callback) {
|
| return net::ERR_FAILED;
|
| }
|
|
|
| -int BackendImplV3::CreateEntry(const std::string& key, Entry** entry,
|
| +int BackendImplV3::CreateEntry(const std::string& key,
|
| + Entry** entry,
|
| const CompletionCallback& callback) {
|
| return net::ERR_FAILED;
|
| }
|
| @@ -1584,7 +1608,8 @@ int BackendImplV3::DoomEntriesSince(base::Time initial_time,
|
| return net::ERR_FAILED;
|
| }
|
|
|
| -int BackendImplV3::OpenNextEntry(void** iter, Entry** next_entry,
|
| +int BackendImplV3::OpenNextEntry(void** iter,
|
| + Entry** next_entry,
|
| const CompletionCallback& callback) {
|
| return net::ERR_FAILED;
|
| }
|
|
|