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

Side by Side Diff: net/disk_cache/blockfile/backend_impl.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/blockfile/backend_impl.h" 5 #include "net/disk_cache/blockfile/backend_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file.h" 10 #include "base/files/file.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // Sets group for the current experiment. Returns false if the files should be 78 // Sets group for the current experiment. Returns false if the files should be
79 // discarded. 79 // discarded.
80 bool InitExperiment(disk_cache::IndexHeader* header, bool cache_created) { 80 bool InitExperiment(disk_cache::IndexHeader* header, bool cache_created) {
81 if (header->experiment == disk_cache::EXPERIMENT_OLD_FILE1 || 81 if (header->experiment == disk_cache::EXPERIMENT_OLD_FILE1 ||
82 header->experiment == disk_cache::EXPERIMENT_OLD_FILE2) { 82 header->experiment == disk_cache::EXPERIMENT_OLD_FILE2) {
83 // Discard current cache. 83 // Discard current cache.
84 return false; 84 return false;
85 } 85 }
86 86
87 if (base::FieldTrialList::FindFullName("SimpleCacheTrial") == 87 if (base::FieldTrialList::FindFullName("SimpleCacheTrial") ==
88 "ExperimentControl") { 88 "ExperimentControl") {
89 if (cache_created) { 89 if (cache_created) {
90 header->experiment = disk_cache::EXPERIMENT_SIMPLE_CONTROL; 90 header->experiment = disk_cache::EXPERIMENT_SIMPLE_CONTROL;
91 return true; 91 return true;
92 } 92 }
93 return header->experiment == disk_cache::EXPERIMENT_SIMPLE_CONTROL; 93 return header->experiment == disk_cache::EXPERIMENT_SIMPLE_CONTROL;
94 } 94 }
95 95
96 header->experiment = disk_cache::NO_EXPERIMENT; 96 header->experiment = disk_cache::NO_EXPERIMENT;
97 return true; 97 return true;
98 } 98 }
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } else if (!restarted_) { 283 } else if (!restarted_) {
284 ReportError(ERR_NO_ERROR); 284 ReportError(ERR_NO_ERROR);
285 } 285 }
286 286
287 FlushIndex(); 287 FlushIndex();
288 288
289 if (!disabled_ && should_create_timer) { 289 if (!disabled_ && should_create_timer) {
290 // Create a recurrent timer of 30 secs. 290 // Create a recurrent timer of 30 secs.
291 int timer_delay = unit_test_ ? 1000 : 30000; 291 int timer_delay = unit_test_ ? 1000 : 30000;
292 timer_.reset(new base::RepeatingTimer<BackendImpl>()); 292 timer_.reset(new base::RepeatingTimer<BackendImpl>());
293 timer_->Start(FROM_HERE, TimeDelta::FromMilliseconds(timer_delay), this, 293 timer_->Start(FROM_HERE,
294 TimeDelta::FromMilliseconds(timer_delay),
295 this,
294 &BackendImpl::OnStatsTimer); 296 &BackendImpl::OnStatsTimer);
295 } 297 }
296 298
297 return disabled_ ? net::ERR_FAILED : net::OK; 299 return disabled_ ? net::ERR_FAILED : net::OK;
298 } 300 }
299 301
300 void BackendImpl::CleanupCache() { 302 void BackendImpl::CleanupCache() {
301 Trace("Backend Cleanup"); 303 Trace("Backend Cleanup");
302 eviction_.Stop(); 304 eviction_.Stop();
303 timer_.reset(); 305 timer_.reset();
(...skipping 13 matching lines...) Expand all
317 } 319 }
318 block_files_.CloseFiles(); 320 block_files_.CloseFiles();
319 FlushIndex(); 321 FlushIndex();
320 index_ = NULL; 322 index_ = NULL;
321 ptr_factory_.InvalidateWeakPtrs(); 323 ptr_factory_.InvalidateWeakPtrs();
322 done_.Signal(); 324 done_.Signal();
323 } 325 }
324 326
325 // ------------------------------------------------------------------------ 327 // ------------------------------------------------------------------------
326 328
327 int BackendImpl::OpenPrevEntry(void** iter, Entry** prev_entry, 329 int BackendImpl::OpenPrevEntry(void** iter,
330 Entry** prev_entry,
328 const CompletionCallback& callback) { 331 const CompletionCallback& callback) {
329 DCHECK(!callback.is_null()); 332 DCHECK(!callback.is_null());
330 background_queue_.OpenPrevEntry(iter, prev_entry, callback); 333 background_queue_.OpenPrevEntry(iter, prev_entry, callback);
331 return net::ERR_IO_PENDING; 334 return net::ERR_IO_PENDING;
332 } 335 }
333 336
334 int BackendImpl::SyncOpenEntry(const std::string& key, Entry** entry) { 337 int BackendImpl::SyncOpenEntry(const std::string& key, Entry** entry) {
335 DCHECK(entry); 338 DCHECK(entry);
336 *entry = OpenEntryImpl(key); 339 *entry = OpenEntryImpl(key);
337 return (*entry) ? net::OK : net::ERR_FAILED; 340 return (*entry) ? net::OK : net::ERR_FAILED;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 EntryImpl* node; 389 EntryImpl* node;
387 void* iter = NULL; 390 void* iter = NULL;
388 EntryImpl* next = OpenNextEntryImpl(&iter); 391 EntryImpl* next = OpenNextEntryImpl(&iter);
389 if (!next) 392 if (!next)
390 return net::OK; 393 return net::OK;
391 394
392 while (next) { 395 while (next) {
393 node = next; 396 node = next;
394 next = OpenNextEntryImpl(&iter); 397 next = OpenNextEntryImpl(&iter);
395 398
396 if (node->GetLastUsed() >= initial_time && 399 if (node->GetLastUsed() >= initial_time && node->GetLastUsed() < end_time) {
397 node->GetLastUsed() < end_time) {
398 node->DoomImpl(); 400 node->DoomImpl();
399 } else if (node->GetLastUsed() < initial_time) { 401 } else if (node->GetLastUsed() < initial_time) {
400 if (next) 402 if (next)
401 next->Release(); 403 next->Release();
402 next = NULL; 404 next = NULL;
403 SyncEndEnumeration(iter); 405 SyncEndEnumeration(iter);
404 } 406 }
405 407
406 node->Release(); 408 node->Release();
407 } 409 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 CACHE_UMA(COUNTS_10000, "AllOpenBySize.Miss", 0, current_size); 493 CACHE_UMA(COUNTS_10000, "AllOpenBySize.Miss", 0, current_size);
492 CACHE_UMA(HOURS, "AllOpenByTotalHours.Miss", 0, total_hours); 494 CACHE_UMA(HOURS, "AllOpenByTotalHours.Miss", 0, total_hours);
493 CACHE_UMA(HOURS, "AllOpenByUseHours.Miss", 0, use_hours); 495 CACHE_UMA(HOURS, "AllOpenByUseHours.Miss", 0, use_hours);
494 stats_.OnEvent(Stats::OPEN_MISS); 496 stats_.OnEvent(Stats::OPEN_MISS);
495 return NULL; 497 return NULL;
496 } 498 }
497 499
498 eviction_.OnOpenEntry(cache_entry); 500 eviction_.OnOpenEntry(cache_entry);
499 entry_count_++; 501 entry_count_++;
500 502
501 Trace("Open hash 0x%x end: 0x%x", hash, 503 Trace("Open hash 0x%x end: 0x%x",
504 hash,
502 cache_entry->entry()->address().value()); 505 cache_entry->entry()->address().value());
503 CACHE_UMA(AGE_MS, "OpenTime", 0, start); 506 CACHE_UMA(AGE_MS, "OpenTime", 0, start);
504 CACHE_UMA(COUNTS_10000, "AllOpenBySize.Hit", 0, current_size); 507 CACHE_UMA(COUNTS_10000, "AllOpenBySize.Hit", 0, current_size);
505 CACHE_UMA(HOURS, "AllOpenByTotalHours.Hit", 0, total_hours); 508 CACHE_UMA(HOURS, "AllOpenByTotalHours.Hit", 0, total_hours);
506 CACHE_UMA(HOURS, "AllOpenByUseHours.Hit", 0, use_hours); 509 CACHE_UMA(HOURS, "AllOpenByUseHours.Hit", 0, use_hours);
507 stats_.OnEvent(Stats::OPEN_HIT); 510 stats_.OnEvent(Stats::OPEN_HIT);
508 SIMPLE_STATS_COUNTER("disk_cache.hit"); 511 SIMPLE_STATS_COUNTER("disk_cache.hit");
509 return cache_entry; 512 return cache_entry;
510 } 513 }
511 514
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 690
688 DCHECK(success); 691 DCHECK(success);
689 if (!success) 692 if (!success)
690 return false; 693 return false;
691 694
692 data_->header.last_file = file_number; 695 data_->header.last_file = file_number;
693 address->set_value(file_address.value()); 696 address->set_value(file_address.value());
694 return true; 697 return true;
695 } 698 }
696 699
697 bool BackendImpl::CreateBlock(FileType block_type, int block_count, 700 bool BackendImpl::CreateBlock(FileType block_type,
698 Addr* block_address) { 701 int block_count,
702 Addr* block_address) {
699 return block_files_.CreateBlock(block_type, block_count, block_address); 703 return block_files_.CreateBlock(block_type, block_count, block_address);
700 } 704 }
701 705
702 void BackendImpl::DeleteBlock(Addr block_address, bool deep) { 706 void BackendImpl::DeleteBlock(Addr block_address, bool deep) {
703 block_files_.DeleteBlock(block_address, deep); 707 block_files_.DeleteBlock(block_address, deep);
704 } 708 }
705 709
706 LruData* BackendImpl::GetLruData() { 710 LruData* BackendImpl::GetLruData() {
707 return &data_->header.lru; 711 return &data_->header.lru;
708 } 712 }
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 CACHE_UMA(COUNTS, "PendingIO", 0, num_pending_io_); 888 CACHE_UMA(COUNTS, "PendingIO", 0, num_pending_io_);
885 if (user_flags_ & kNoLoadProtection) 889 if (user_flags_ & kNoLoadProtection)
886 return false; 890 return false;
887 891
888 return (num_pending_io_ > 5 || user_load_); 892 return (num_pending_io_ > 5 || user_load_);
889 } 893 }
890 894
891 std::string BackendImpl::HistogramName(const char* name, int experiment) const { 895 std::string BackendImpl::HistogramName(const char* name, int experiment) const {
892 if (!experiment) 896 if (!experiment)
893 return base::StringPrintf("DiskCache.%d.%s", cache_type_, name); 897 return base::StringPrintf("DiskCache.%d.%s", cache_type_, name);
894 return base::StringPrintf("DiskCache.%d.%s_%d", cache_type_, 898 return base::StringPrintf(
895 name, experiment); 899 "DiskCache.%d.%s_%d", cache_type_, name, experiment);
896 } 900 }
897 901
898 base::WeakPtr<BackendImpl> BackendImpl::GetWeakPtr() { 902 base::WeakPtr<BackendImpl> BackendImpl::GetWeakPtr() {
899 return ptr_factory_.GetWeakPtr(); 903 return ptr_factory_.GetWeakPtr();
900 } 904 }
901 905
902 // We want to remove biases from some histograms so we only send data once per 906 // We want to remove biases from some histograms so we only send data once per
903 // week. 907 // week.
904 bool BackendImpl::ShouldReportAgain() { 908 bool BackendImpl::ShouldReportAgain() {
905 if (uma_report_) 909 if (uma_report_)
(...skipping 17 matching lines...) Expand all
923 927
924 Time create_time = Time::FromInternalValue(data_->header.create_time); 928 Time create_time = Time::FromInternalValue(data_->header.create_time);
925 CACHE_UMA(AGE, "FillupAge", 0, create_time); 929 CACHE_UMA(AGE, "FillupAge", 0, create_time);
926 930
927 int64 use_time = stats_.GetCounter(Stats::TIMER); 931 int64 use_time = stats_.GetCounter(Stats::TIMER);
928 CACHE_UMA(HOURS, "FillupTime", 0, static_cast<int>(use_time / 120)); 932 CACHE_UMA(HOURS, "FillupTime", 0, static_cast<int>(use_time / 120));
929 CACHE_UMA(PERCENTAGE, "FirstHitRatio", 0, stats_.GetHitRatio()); 933 CACHE_UMA(PERCENTAGE, "FirstHitRatio", 0, stats_.GetHitRatio());
930 934
931 if (!use_time) 935 if (!use_time)
932 use_time = 1; 936 use_time = 1;
933 CACHE_UMA(COUNTS_10000, "FirstEntryAccessRate", 0, 937 CACHE_UMA(COUNTS_10000,
938 "FirstEntryAccessRate",
939 0,
934 static_cast<int>(data_->header.num_entries / use_time)); 940 static_cast<int>(data_->header.num_entries / use_time));
935 CACHE_UMA(COUNTS, "FirstByteIORate", 0, 941 CACHE_UMA(COUNTS,
942 "FirstByteIORate",
943 0,
936 static_cast<int>((data_->header.num_bytes / 1024) / use_time)); 944 static_cast<int>((data_->header.num_bytes / 1024) / use_time));
937 945
938 int avg_size = data_->header.num_bytes / GetEntryCount(); 946 int avg_size = data_->header.num_bytes / GetEntryCount();
939 CACHE_UMA(COUNTS, "FirstEntrySize", 0, avg_size); 947 CACHE_UMA(COUNTS, "FirstEntrySize", 0, avg_size);
940 948
941 int large_entries_bytes = stats_.GetLargeEntriesSize(); 949 int large_entries_bytes = stats_.GetLargeEntriesSize();
942 int large_ratio = large_entries_bytes * 100 / data_->header.num_bytes; 950 int large_ratio = large_entries_bytes * 100 / data_->header.num_bytes;
943 CACHE_UMA(PERCENTAGE, "FirstLargeEntriesRatio", 0, large_ratio); 951 CACHE_UMA(PERCENTAGE, "FirstLargeEntriesRatio", 0, large_ratio);
944 952
945 if (new_eviction_) { 953 if (new_eviction_) {
946 CACHE_UMA(PERCENTAGE, "FirstResurrectRatio", 0, stats_.GetResurrectRatio()); 954 CACHE_UMA(PERCENTAGE, "FirstResurrectRatio", 0, stats_.GetResurrectRatio());
947 CACHE_UMA(PERCENTAGE, "FirstNoUseRatio", 0, 955 CACHE_UMA(PERCENTAGE,
956 "FirstNoUseRatio",
957 0,
948 data_->header.lru.sizes[0] * 100 / data_->header.num_entries); 958 data_->header.lru.sizes[0] * 100 / data_->header.num_entries);
949 CACHE_UMA(PERCENTAGE, "FirstLowUseRatio", 0, 959 CACHE_UMA(PERCENTAGE,
960 "FirstLowUseRatio",
961 0,
950 data_->header.lru.sizes[1] * 100 / data_->header.num_entries); 962 data_->header.lru.sizes[1] * 100 / data_->header.num_entries);
951 CACHE_UMA(PERCENTAGE, "FirstHighUseRatio", 0, 963 CACHE_UMA(PERCENTAGE,
964 "FirstHighUseRatio",
965 0,
952 data_->header.lru.sizes[2] * 100 / data_->header.num_entries); 966 data_->header.lru.sizes[2] * 100 / data_->header.num_entries);
953 } 967 }
954 968
955 stats_.ResetRatios(); 969 stats_.ResetRatios();
956 } 970 }
957 971
958 void BackendImpl::CriticalError(int error) { 972 void BackendImpl::CriticalError(int error) {
959 STRESS_NOTREACHED(); 973 STRESS_NOTREACHED();
960 LOG(ERROR) << "Critical error found " << error; 974 LOG(ERROR) << "Critical error found " << error;
961 if (disabled_) 975 if (disabled_)
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 // ------------------------------------------------------------------------ 1145 // ------------------------------------------------------------------------
1132 1146
1133 net::CacheType BackendImpl::GetCacheType() const { 1147 net::CacheType BackendImpl::GetCacheType() const {
1134 return cache_type_; 1148 return cache_type_;
1135 } 1149 }
1136 1150
1137 int32 BackendImpl::GetEntryCount() const { 1151 int32 BackendImpl::GetEntryCount() const {
1138 if (!index_.get() || disabled_) 1152 if (!index_.get() || disabled_)
1139 return 0; 1153 return 0;
1140 // num_entries includes entries already evicted. 1154 // num_entries includes entries already evicted.
1141 int32 not_deleted = data_->header.num_entries - 1155 int32 not_deleted =
1142 data_->header.lru.sizes[Rankings::DELETED]; 1156 data_->header.num_entries - data_->header.lru.sizes[Rankings::DELETED];
1143 1157
1144 if (not_deleted < 0) { 1158 if (not_deleted < 0) {
1145 NOTREACHED(); 1159 NOTREACHED();
1146 not_deleted = 0; 1160 not_deleted = 0;
1147 } 1161 }
1148 1162
1149 return not_deleted; 1163 return not_deleted;
1150 } 1164 }
1151 1165
1152 int BackendImpl::OpenEntry(const std::string& key, Entry** entry, 1166 int BackendImpl::OpenEntry(const std::string& key,
1167 Entry** entry,
1153 const CompletionCallback& callback) { 1168 const CompletionCallback& callback) {
1154 DCHECK(!callback.is_null()); 1169 DCHECK(!callback.is_null());
1155 background_queue_.OpenEntry(key, entry, callback); 1170 background_queue_.OpenEntry(key, entry, callback);
1156 return net::ERR_IO_PENDING; 1171 return net::ERR_IO_PENDING;
1157 } 1172 }
1158 1173
1159 int BackendImpl::CreateEntry(const std::string& key, Entry** entry, 1174 int BackendImpl::CreateEntry(const std::string& key,
1175 Entry** entry,
1160 const CompletionCallback& callback) { 1176 const CompletionCallback& callback) {
1161 DCHECK(!callback.is_null()); 1177 DCHECK(!callback.is_null());
1162 background_queue_.CreateEntry(key, entry, callback); 1178 background_queue_.CreateEntry(key, entry, callback);
1163 return net::ERR_IO_PENDING; 1179 return net::ERR_IO_PENDING;
1164 } 1180 }
1165 1181
1166 int BackendImpl::DoomEntry(const std::string& key, 1182 int BackendImpl::DoomEntry(const std::string& key,
1167 const CompletionCallback& callback) { 1183 const CompletionCallback& callback) {
1168 DCHECK(!callback.is_null()); 1184 DCHECK(!callback.is_null());
1169 background_queue_.DoomEntry(key, callback); 1185 background_queue_.DoomEntry(key, callback);
(...skipping 14 matching lines...) Expand all
1184 return net::ERR_IO_PENDING; 1200 return net::ERR_IO_PENDING;
1185 } 1201 }
1186 1202
1187 int BackendImpl::DoomEntriesSince(const base::Time initial_time, 1203 int BackendImpl::DoomEntriesSince(const base::Time initial_time,
1188 const CompletionCallback& callback) { 1204 const CompletionCallback& callback) {
1189 DCHECK(!callback.is_null()); 1205 DCHECK(!callback.is_null());
1190 background_queue_.DoomEntriesSince(initial_time, callback); 1206 background_queue_.DoomEntriesSince(initial_time, callback);
1191 return net::ERR_IO_PENDING; 1207 return net::ERR_IO_PENDING;
1192 } 1208 }
1193 1209
1194 int BackendImpl::OpenNextEntry(void** iter, Entry** next_entry, 1210 int BackendImpl::OpenNextEntry(void** iter,
1211 Entry** next_entry,
1195 const CompletionCallback& callback) { 1212 const CompletionCallback& callback) {
1196 DCHECK(!callback.is_null()); 1213 DCHECK(!callback.is_null());
1197 background_queue_.OpenNextEntry(iter, next_entry, callback); 1214 background_queue_.OpenNextEntry(iter, next_entry, callback);
1198 return net::ERR_IO_PENDING; 1215 return net::ERR_IO_PENDING;
1199 } 1216 }
1200 1217
1201 void BackendImpl::EndEnumeration(void** iter) { 1218 void BackendImpl::EndEnumeration(void** iter) {
1202 background_queue_.EndEnumeration(*iter); 1219 background_queue_.EndEnumeration(*iter);
1203 *iter = NULL; 1220 *iter = NULL;
1204 } 1221 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 available += data_->header.num_bytes; 1335 available += data_->header.num_bytes;
1319 1336
1320 max_size_ = PreferredCacheSize(available); 1337 max_size_ = PreferredCacheSize(available);
1321 1338
1322 if (!table_len) 1339 if (!table_len)
1323 return; 1340 return;
1324 1341
1325 // If we already have a table, adjust the size to it. 1342 // If we already have a table, adjust the size to it.
1326 int current_max_size = MaxStorageSizeForTable(table_len); 1343 int current_max_size = MaxStorageSizeForTable(table_len);
1327 if (max_size_ > current_max_size) 1344 if (max_size_ > current_max_size)
1328 max_size_= current_max_size; 1345 max_size_ = current_max_size;
1329 } 1346 }
1330 1347
1331 bool BackendImpl::InitStats() { 1348 bool BackendImpl::InitStats() {
1332 Addr address(data_->header.stats); 1349 Addr address(data_->header.stats);
1333 int size = stats_.StorageSize(); 1350 int size = stats_.StorageSize();
1334 1351
1335 if (!address.is_initialized()) { 1352 if (!address.is_initialized()) {
1336 FileType file_type = Addr::RequiredFileType(size); 1353 FileType file_type = Addr::RequiredFileType(size);
1337 DCHECK_NE(file_type, EXTERNAL); 1354 DCHECK_NE(file_type, EXTERNAL);
1338 int num_blocks = Addr::RequiredBlocks(size, file_type); 1355 int num_blocks = Addr::RequiredBlocks(size, file_type);
(...skipping 10 matching lines...) Expand all
1349 return false; 1366 return false;
1350 } 1367 }
1351 1368
1352 // Load the required data. 1369 // Load the required data.
1353 size = address.num_blocks() * address.BlockSize(); 1370 size = address.num_blocks() * address.BlockSize();
1354 MappedFile* file = File(address); 1371 MappedFile* file = File(address);
1355 if (!file) 1372 if (!file)
1356 return false; 1373 return false;
1357 1374
1358 scoped_ptr<char[]> data(new char[size]); 1375 scoped_ptr<char[]> data(new char[size]);
1359 size_t offset = address.start_block() * address.BlockSize() + 1376 size_t offset =
1360 kBlockHeaderSize; 1377 address.start_block() * address.BlockSize() + kBlockHeaderSize;
1361 if (!file->Read(data.get(), size, offset)) 1378 if (!file->Read(data.get(), size, offset))
1362 return false; 1379 return false;
1363 1380
1364 if (!stats_.Init(data.get(), size, address)) 1381 if (!stats_.Init(data.get(), size, address))
1365 return false; 1382 return false;
1366 if (cache_type_ == net::DISK_CACHE && ShouldReportAgain()) 1383 if (cache_type_ == net::DISK_CACHE && ShouldReportAgain())
1367 stats_.InitSizeHistogram(); 1384 stats_.InitSizeHistogram();
1368 return true; 1385 return true;
1369 } 1386 }
1370 1387
1371 void BackendImpl::StoreStats() { 1388 void BackendImpl::StoreStats() {
1372 int size = stats_.StorageSize(); 1389 int size = stats_.StorageSize();
1373 scoped_ptr<char[]> data(new char[size]); 1390 scoped_ptr<char[]> data(new char[size]);
1374 Addr address; 1391 Addr address;
1375 size = stats_.SerializeStats(data.get(), size, &address); 1392 size = stats_.SerializeStats(data.get(), size, &address);
1376 DCHECK(size); 1393 DCHECK(size);
1377 if (!address.is_initialized()) 1394 if (!address.is_initialized())
1378 return; 1395 return;
1379 1396
1380 MappedFile* file = File(address); 1397 MappedFile* file = File(address);
1381 if (!file) 1398 if (!file)
1382 return; 1399 return;
1383 1400
1384 size_t offset = address.start_block() * address.BlockSize() + 1401 size_t offset =
1385 kBlockHeaderSize; 1402 address.start_block() * address.BlockSize() + kBlockHeaderSize;
1386 file->Write(data.get(), size, offset); // ignore result. 1403 file->Write(data.get(), size, offset); // ignore result.
1387 } 1404 }
1388 1405
1389 void BackendImpl::RestartCache(bool failure) { 1406 void BackendImpl::RestartCache(bool failure) {
1390 int64 errors = stats_.GetCounter(Stats::FATAL_ERROR); 1407 int64 errors = stats_.GetCounter(Stats::FATAL_ERROR);
1391 int64 full_dooms = stats_.GetCounter(Stats::DOOM_CACHE); 1408 int64 full_dooms = stats_.GetCounter(Stats::DOOM_CACHE);
1392 int64 partial_dooms = stats_.GetCounter(Stats::DOOM_RECENT); 1409 int64 partial_dooms = stats_.GetCounter(Stats::DOOM_RECENT);
1393 int64 last_report = stats_.GetCounter(Stats::LAST_REPORT); 1410 int64 last_report = stats_.GetCounter(Stats::LAST_REPORT);
1394 1411
1395 PrepareForRestart(); 1412 PrepareForRestart();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 if (IsLoaded()) { 1479 if (IsLoaded()) {
1463 CACHE_UMA(AGE_MS, "LoadTime", 0, start); 1480 CACHE_UMA(AGE_MS, "LoadTime", 0, start);
1464 } 1481 }
1465 1482
1466 if (!cache_entry->SanityCheck()) { 1483 if (!cache_entry->SanityCheck()) {
1467 LOG(WARNING) << "Messed up entry found."; 1484 LOG(WARNING) << "Messed up entry found.";
1468 STRESS_NOTREACHED(); 1485 STRESS_NOTREACHED();
1469 return ERR_INVALID_ENTRY; 1486 return ERR_INVALID_ENTRY;
1470 } 1487 }
1471 1488
1472 STRESS_DCHECK(block_files_.IsValid( 1489 STRESS_DCHECK(
1473 Addr(cache_entry->entry()->Data()->rankings_node))); 1490 block_files_.IsValid(Addr(cache_entry->entry()->Data()->rankings_node)));
1474 1491
1475 if (!cache_entry->LoadNodeAddress()) 1492 if (!cache_entry->LoadNodeAddress())
1476 return ERR_READ_FAILURE; 1493 return ERR_READ_FAILURE;
1477 1494
1478 if (!rankings_.SanityCheck(cache_entry->rankings(), false)) { 1495 if (!rankings_.SanityCheck(cache_entry->rankings(), false)) {
1479 STRESS_NOTREACHED(); 1496 STRESS_NOTREACHED();
1480 cache_entry->SetDirtyFlag(0); 1497 cache_entry->SetDirtyFlag(0);
1481 // Don't remove this from the list (it is not linked properly). Instead, 1498 // Don't remove this from the list (it is not linked properly). Instead,
1482 // break the link back to the entry because it is going away, and leave the 1499 // break the link back to the entry because it is going away, and leave the
1483 // rankings node to be deleted if we find it through a list. 1500 // rankings node to be deleted if we find it through a list.
1484 rankings_.SetContents(cache_entry->rankings(), 0); 1501 rankings_.SetContents(cache_entry->rankings(), 0);
1485 } else if (!rankings_.DataSanityCheck(cache_entry->rankings(), false)) { 1502 } else if (!rankings_.DataSanityCheck(cache_entry->rankings(), false)) {
1486 STRESS_NOTREACHED(); 1503 STRESS_NOTREACHED();
1487 cache_entry->SetDirtyFlag(0); 1504 cache_entry->SetDirtyFlag(0);
1488 rankings_.SetContents(cache_entry->rankings(), address.value()); 1505 rankings_.SetContents(cache_entry->rankings(), address.value());
1489 } 1506 }
1490 1507
1491 if (!cache_entry->DataSanityCheck()) { 1508 if (!cache_entry->DataSanityCheck()) {
1492 LOG(WARNING) << "Messed up entry found."; 1509 LOG(WARNING) << "Messed up entry found.";
1493 cache_entry->SetDirtyFlag(0); 1510 cache_entry->SetDirtyFlag(0);
1494 cache_entry->FixForDelete(); 1511 cache_entry->FixForDelete();
1495 } 1512 }
1496 1513
1497 // Prevent overwriting the dirty flag on the destructor. 1514 // Prevent overwriting the dirty flag on the destructor.
1498 cache_entry->SetDirtyFlag(GetCurrentEntryId()); 1515 cache_entry->SetDirtyFlag(GetCurrentEntryId());
1499 1516
1500 if (cache_entry->dirty()) { 1517 if (cache_entry->dirty()) {
1501 Trace("Dirty entry 0x%p 0x%x", reinterpret_cast<void*>(cache_entry.get()), 1518 Trace("Dirty entry 0x%p 0x%x",
1519 reinterpret_cast<void*>(cache_entry.get()),
1502 address.value()); 1520 address.value());
1503 } 1521 }
1504 1522
1505 open_entries_[address.value()] = cache_entry.get(); 1523 open_entries_[address.value()] = cache_entry.get();
1506 1524
1507 cache_entry->BeginLogging(net_log_, false); 1525 cache_entry->BeginLogging(net_log_, false);
1508 cache_entry.swap(entry); 1526 cache_entry.swap(entry);
1509 return 0; 1527 return 0;
1510 } 1528 }
1511 1529
1512 EntryImpl* BackendImpl::MatchEntry(const std::string& key, uint32 hash, 1530 EntryImpl* BackendImpl::MatchEntry(const std::string& key,
1513 bool find_parent, Addr entry_addr, 1531 uint32 hash,
1532 bool find_parent,
1533 Addr entry_addr,
1514 bool* match_error) { 1534 bool* match_error) {
1515 Addr address(data_->table[hash & mask_]); 1535 Addr address(data_->table[hash & mask_]);
1516 scoped_refptr<EntryImpl> cache_entry, parent_entry; 1536 scoped_refptr<EntryImpl> cache_entry, parent_entry;
1517 EntryImpl* tmp = NULL; 1537 EntryImpl* tmp = NULL;
1518 bool found = false; 1538 bool found = false;
1519 std::set<CacheAddr> visited; 1539 std::set<CacheAddr> visited;
1520 *match_error = false; 1540 *match_error = false;
1521 1541
1522 for (;;) { 1542 for (;;) {
1523 if (disabled_) 1543 if (disabled_)
(...skipping 24 matching lines...) Expand all
1548 if (!error) 1568 if (!error)
1549 child.set_value(cache_entry->GetNextAddress()); 1569 child.set_value(cache_entry->GetNextAddress());
1550 1570
1551 if (parent_entry.get()) { 1571 if (parent_entry.get()) {
1552 parent_entry->SetNextAddress(child); 1572 parent_entry->SetNextAddress(child);
1553 parent_entry = NULL; 1573 parent_entry = NULL;
1554 } else { 1574 } else {
1555 data_->table[hash & mask_] = child.value(); 1575 data_->table[hash & mask_] = child.value();
1556 } 1576 }
1557 1577
1558 Trace("MatchEntry dirty %d 0x%x 0x%x", find_parent, entry_addr.value(), 1578 Trace("MatchEntry dirty %d 0x%x 0x%x",
1579 find_parent,
1580 entry_addr.value(),
1559 address.value()); 1581 address.value());
1560 1582
1561 if (!error) { 1583 if (!error) {
1562 // It is important to call DestroyInvalidEntry after removing this 1584 // It is important to call DestroyInvalidEntry after removing this
1563 // entry from the table. 1585 // entry from the table.
1564 DestroyInvalidEntry(cache_entry.get()); 1586 DestroyInvalidEntry(cache_entry.get());
1565 cache_entry = NULL; 1587 cache_entry = NULL;
1566 } else { 1588 } else {
1567 Trace("NewEntry failed on MatchEntry 0x%x", address.value()); 1589 Trace("NewEntry failed on MatchEntry 0x%x", address.value());
1568 } 1590 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 reinterpret_cast<Rankings::Iterator*>(*iter)); 1646 reinterpret_cast<Rankings::Iterator*>(*iter));
1625 *iter = NULL; 1647 *iter = NULL;
1626 1648
1627 if (!iterator.get()) { 1649 if (!iterator.get()) {
1628 iterator.reset(new Rankings::Iterator(&rankings_)); 1650 iterator.reset(new Rankings::Iterator(&rankings_));
1629 bool ret = false; 1651 bool ret = false;
1630 1652
1631 // Get an entry from each list. 1653 // Get an entry from each list.
1632 for (int i = 0; i < kListsToSearch; i++) { 1654 for (int i = 0; i < kListsToSearch; i++) {
1633 EntryImpl* temp = NULL; 1655 EntryImpl* temp = NULL;
1634 ret |= OpenFollowingEntryFromList(forward, static_cast<Rankings::List>(i), 1656 ret |= OpenFollowingEntryFromList(
1635 &iterator->nodes[i], &temp); 1657 forward, static_cast<Rankings::List>(i), &iterator->nodes[i], &temp);
1636 entries[i].swap(&temp); // The entry was already addref'd. 1658 entries[i].swap(&temp); // The entry was already addref'd.
1637 } 1659 }
1638 if (!ret) 1660 if (!ret)
1639 return NULL; 1661 return NULL;
1640 } else { 1662 } else {
1641 // Get the next entry from the last list, and the actual entries for the 1663 // Get the next entry from the last list, and the actual entries for the
1642 // elements on the other lists. 1664 // elements on the other lists.
1643 for (int i = 0; i < kListsToSearch; i++) { 1665 for (int i = 0; i < kListsToSearch; i++) {
1644 EntryImpl* temp = NULL; 1666 EntryImpl* temp = NULL;
1645 if (iterator->list == i) { 1667 if (iterator->list == i) {
1646 OpenFollowingEntryFromList(forward, iterator->list, 1668 OpenFollowingEntryFromList(
1647 &iterator->nodes[i], &temp); 1669 forward, iterator->list, &iterator->nodes[i], &temp);
1648 } else { 1670 } else {
1649 temp = GetEnumeratedEntry(iterator->nodes[i], 1671 temp = GetEnumeratedEntry(iterator->nodes[i],
1650 static_cast<Rankings::List>(i)); 1672 static_cast<Rankings::List>(i));
1651 } 1673 }
1652 1674
1653 entries[i].swap(&temp); // The entry was already addref'd. 1675 entries[i].swap(&temp); // The entry was already addref'd.
1654 } 1676 }
1655 } 1677 }
1656 1678
1657 int newest = -1; 1679 int newest = -1;
(...skipping 24 matching lines...) Expand all
1682 } else { 1704 } else {
1683 next_entry = entries[oldest].get(); 1705 next_entry = entries[oldest].get();
1684 iterator->list = static_cast<Rankings::List>(oldest); 1706 iterator->list = static_cast<Rankings::List>(oldest);
1685 } 1707 }
1686 1708
1687 *iter = iterator.release(); 1709 *iter = iterator.release();
1688 next_entry->AddRef(); 1710 next_entry->AddRef();
1689 return next_entry; 1711 return next_entry;
1690 } 1712 }
1691 1713
1692 bool BackendImpl::OpenFollowingEntryFromList(bool forward, Rankings::List list, 1714 bool BackendImpl::OpenFollowingEntryFromList(bool forward,
1715 Rankings::List list,
1693 CacheRankingsBlock** from_entry, 1716 CacheRankingsBlock** from_entry,
1694 EntryImpl** next_entry) { 1717 EntryImpl** next_entry) {
1695 if (disabled_) 1718 if (disabled_)
1696 return false; 1719 return false;
1697 1720
1698 if (!new_eviction_ && Rankings::NO_USE != list) 1721 if (!new_eviction_ && Rankings::NO_USE != list)
1699 return false; 1722 return false;
1700 1723
1701 Rankings::ScopedRankingsBlock rankings(&rankings_, *from_entry); 1724 Rankings::ScopedRankingsBlock rankings(&rankings_, *from_entry);
1702 CacheRankingsBlock* next_block = forward ? 1725 CacheRankingsBlock* next_block =
1703 rankings_.GetNext(rankings.get(), list) : 1726 forward ? rankings_.GetNext(rankings.get(), list)
1704 rankings_.GetPrev(rankings.get(), list); 1727 : rankings_.GetPrev(rankings.get(), list);
1705 Rankings::ScopedRankingsBlock next(&rankings_, next_block); 1728 Rankings::ScopedRankingsBlock next(&rankings_, next_block);
1706 *from_entry = NULL; 1729 *from_entry = NULL;
1707 1730
1708 *next_entry = GetEnumeratedEntry(next.get(), list); 1731 *next_entry = GetEnumeratedEntry(next.get(), list);
1709 if (!*next_entry) 1732 if (!*next_entry)
1710 return false; 1733 return false;
1711 1734
1712 *from_entry = next.release(); 1735 *from_entry = next.release();
1713 return true; 1736 return true;
1714 } 1737 }
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1847 // For any bin in HitRatioBySize2, the hit ratio of caches of that size is the 1870 // For any bin in HitRatioBySize2, the hit ratio of caches of that size is the
1848 // ratio of that bin's total count to the count in the same bin in the Size2 1871 // ratio of that bin's total count to the count in the same bin in the Size2
1849 // histogram. 1872 // histogram.
1850 if (base::RandInt(0, 99) < hit_ratio_as_percentage) 1873 if (base::RandInt(0, 99) < hit_ratio_as_percentage)
1851 CACHE_UMA(COUNTS_10000, "HitRatioBySize2", 0, current_size); 1874 CACHE_UMA(COUNTS_10000, "HitRatioBySize2", 0, current_size);
1852 CACHE_UMA(COUNTS_10000, "MaxSize2", 0, max_size); 1875 CACHE_UMA(COUNTS_10000, "MaxSize2", 0, max_size);
1853 if (!max_size) 1876 if (!max_size)
1854 max_size++; 1877 max_size++;
1855 CACHE_UMA(PERCENTAGE, "UsedSpace", 0, current_size * 100 / max_size); 1878 CACHE_UMA(PERCENTAGE, "UsedSpace", 0, current_size * 100 / max_size);
1856 1879
1857 CACHE_UMA(COUNTS_10000, "AverageOpenEntries2", 0, 1880 CACHE_UMA(COUNTS_10000,
1881 "AverageOpenEntries2",
1882 0,
1858 static_cast<int>(stats_.GetCounter(Stats::OPEN_ENTRIES))); 1883 static_cast<int>(stats_.GetCounter(Stats::OPEN_ENTRIES)));
1859 CACHE_UMA(COUNTS_10000, "MaxOpenEntries2", 0, 1884 CACHE_UMA(COUNTS_10000,
1885 "MaxOpenEntries2",
1886 0,
1860 static_cast<int>(stats_.GetCounter(Stats::MAX_ENTRIES))); 1887 static_cast<int>(stats_.GetCounter(Stats::MAX_ENTRIES)));
1861 stats_.SetCounter(Stats::MAX_ENTRIES, 0); 1888 stats_.SetCounter(Stats::MAX_ENTRIES, 0);
1862 1889
1863 CACHE_UMA(COUNTS_10000, "TotalFatalErrors", 0, 1890 CACHE_UMA(COUNTS_10000,
1891 "TotalFatalErrors",
1892 0,
1864 static_cast<int>(stats_.GetCounter(Stats::FATAL_ERROR))); 1893 static_cast<int>(stats_.GetCounter(Stats::FATAL_ERROR)));
1865 CACHE_UMA(COUNTS_10000, "TotalDoomCache", 0, 1894 CACHE_UMA(COUNTS_10000,
1895 "TotalDoomCache",
1896 0,
1866 static_cast<int>(stats_.GetCounter(Stats::DOOM_CACHE))); 1897 static_cast<int>(stats_.GetCounter(Stats::DOOM_CACHE)));
1867 CACHE_UMA(COUNTS_10000, "TotalDoomRecentEntries", 0, 1898 CACHE_UMA(COUNTS_10000,
1899 "TotalDoomRecentEntries",
1900 0,
1868 static_cast<int>(stats_.GetCounter(Stats::DOOM_RECENT))); 1901 static_cast<int>(stats_.GetCounter(Stats::DOOM_RECENT)));
1869 stats_.SetCounter(Stats::FATAL_ERROR, 0); 1902 stats_.SetCounter(Stats::FATAL_ERROR, 0);
1870 stats_.SetCounter(Stats::DOOM_CACHE, 0); 1903 stats_.SetCounter(Stats::DOOM_CACHE, 0);
1871 stats_.SetCounter(Stats::DOOM_RECENT, 0); 1904 stats_.SetCounter(Stats::DOOM_RECENT, 0);
1872 1905
1873 int age = (Time::Now() - 1906 int age = (Time::Now() - Time::FromInternalValue(data_->header.create_time))
1874 Time::FromInternalValue(data_->header.create_time)).InHours(); 1907 .InHours();
1875 if (age) 1908 if (age)
1876 CACHE_UMA(HOURS, "FilesAge", 0, age); 1909 CACHE_UMA(HOURS, "FilesAge", 0, age);
1877 1910
1878 int64 total_hours = stats_.GetCounter(Stats::TIMER) / 120; 1911 int64 total_hours = stats_.GetCounter(Stats::TIMER) / 120;
1879 if (!data_->header.create_time || !data_->header.lru.filled) { 1912 if (!data_->header.create_time || !data_->header.lru.filled) {
1880 int cause = data_->header.create_time ? 0 : 1; 1913 int cause = data_->header.create_time ? 0 : 1;
1881 if (!data_->header.lru.filled) 1914 if (!data_->header.lru.filled)
1882 cause |= 2; 1915 cause |= 2;
1883 CACHE_UMA(CACHE_ERROR, "ShortReport", 0, cause); 1916 CACHE_UMA(CACHE_ERROR, "ShortReport", 0, cause);
1884 CACHE_UMA(HOURS, "TotalTimeNotFull", 0, static_cast<int>(total_hours)); 1917 CACHE_UMA(HOURS, "TotalTimeNotFull", 0, static_cast<int>(total_hours));
(...skipping 29 matching lines...) Expand all
1914 CACHE_UMA(HOURS, "HitRatioByUseTime", 0, implicit_cast<int>(use_hours)); 1947 CACHE_UMA(HOURS, "HitRatioByUseTime", 0, implicit_cast<int>(use_hours));
1915 CACHE_UMA(PERCENTAGE, "HitRatio", 0, hit_ratio_as_percentage); 1948 CACHE_UMA(PERCENTAGE, "HitRatio", 0, hit_ratio_as_percentage);
1916 1949
1917 int64 trim_rate = stats_.GetCounter(Stats::TRIM_ENTRY) / use_hours; 1950 int64 trim_rate = stats_.GetCounter(Stats::TRIM_ENTRY) / use_hours;
1918 CACHE_UMA(COUNTS, "TrimRate", 0, static_cast<int>(trim_rate)); 1951 CACHE_UMA(COUNTS, "TrimRate", 0, static_cast<int>(trim_rate));
1919 1952
1920 int avg_size = data_->header.num_bytes / GetEntryCount(); 1953 int avg_size = data_->header.num_bytes / GetEntryCount();
1921 CACHE_UMA(COUNTS, "EntrySize", 0, avg_size); 1954 CACHE_UMA(COUNTS, "EntrySize", 0, avg_size);
1922 CACHE_UMA(COUNTS, "EntriesFull", 0, data_->header.num_entries); 1955 CACHE_UMA(COUNTS, "EntriesFull", 0, data_->header.num_entries);
1923 1956
1924 CACHE_UMA(PERCENTAGE, "IndexLoad", 0, 1957 CACHE_UMA(PERCENTAGE,
1958 "IndexLoad",
1959 0,
1925 data_->header.num_entries * 100 / (mask_ + 1)); 1960 data_->header.num_entries * 100 / (mask_ + 1));
1926 1961
1927 int large_entries_bytes = stats_.GetLargeEntriesSize(); 1962 int large_entries_bytes = stats_.GetLargeEntriesSize();
1928 int large_ratio = large_entries_bytes * 100 / data_->header.num_bytes; 1963 int large_ratio = large_entries_bytes * 100 / data_->header.num_bytes;
1929 CACHE_UMA(PERCENTAGE, "LargeEntriesRatio", 0, large_ratio); 1964 CACHE_UMA(PERCENTAGE, "LargeEntriesRatio", 0, large_ratio);
1930 1965
1931 if (new_eviction_) { 1966 if (new_eviction_) {
1932 CACHE_UMA(PERCENTAGE, "ResurrectRatio", 0, stats_.GetResurrectRatio()); 1967 CACHE_UMA(PERCENTAGE, "ResurrectRatio", 0, stats_.GetResurrectRatio());
1933 CACHE_UMA(PERCENTAGE, "NoUseRatio", 0, 1968 CACHE_UMA(PERCENTAGE,
1969 "NoUseRatio",
1970 0,
1934 data_->header.lru.sizes[0] * 100 / data_->header.num_entries); 1971 data_->header.lru.sizes[0] * 100 / data_->header.num_entries);
1935 CACHE_UMA(PERCENTAGE, "LowUseRatio", 0, 1972 CACHE_UMA(PERCENTAGE,
1973 "LowUseRatio",
1974 0,
1936 data_->header.lru.sizes[1] * 100 / data_->header.num_entries); 1975 data_->header.lru.sizes[1] * 100 / data_->header.num_entries);
1937 CACHE_UMA(PERCENTAGE, "HighUseRatio", 0, 1976 CACHE_UMA(PERCENTAGE,
1977 "HighUseRatio",
1978 0,
1938 data_->header.lru.sizes[2] * 100 / data_->header.num_entries); 1979 data_->header.lru.sizes[2] * 100 / data_->header.num_entries);
1939 CACHE_UMA(PERCENTAGE, "DeletedRatio", 0, 1980 CACHE_UMA(PERCENTAGE,
1981 "DeletedRatio",
1982 0,
1940 data_->header.lru.sizes[4] * 100 / data_->header.num_entries); 1983 data_->header.lru.sizes[4] * 100 / data_->header.num_entries);
1941 } 1984 }
1942 1985
1943 stats_.ResetRatios(); 1986 stats_.ResetRatios();
1944 stats_.SetCounter(Stats::TRIM_ENTRY, 0); 1987 stats_.SetCounter(Stats::TRIM_ENTRY, 0);
1945 1988
1946 if (cache_type_ == net::DISK_CACHE) 1989 if (cache_type_ == net::DISK_CACHE)
1947 block_files_.ReportStats(); 1990 block_files_.ReportStats();
1948 } 1991 }
1949 1992
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
2044 2087
2045 DCHECK_EQ(i, cache_entry->entry()->Data()->hash & mask_); 2088 DCHECK_EQ(i, cache_entry->entry()->Data()->hash & mask_);
2046 address.set_value(cache_entry->GetNextAddress()); 2089 address.set_value(cache_entry->GetNextAddress());
2047 if (!address.is_initialized()) 2090 if (!address.is_initialized())
2048 break; 2091 break;
2049 } 2092 }
2050 } 2093 }
2051 2094
2052 Trace("CheckAllEntries End"); 2095 Trace("CheckAllEntries End");
2053 if (num_entries + num_dirty != data_->header.num_entries) { 2096 if (num_entries + num_dirty != data_->header.num_entries) {
2054 LOG(ERROR) << "Number of entries " << num_entries << " " << num_dirty << 2097 LOG(ERROR) << "Number of entries " << num_entries << " " << num_dirty << " "
2055 " " << data_->header.num_entries; 2098 << data_->header.num_entries;
2056 DCHECK_LT(num_entries, data_->header.num_entries); 2099 DCHECK_LT(num_entries, data_->header.num_entries);
2057 return ERR_NUM_ENTRIES_MISMATCH; 2100 return ERR_NUM_ENTRIES_MISMATCH;
2058 } 2101 }
2059 2102
2060 return num_dirty; 2103 return num_dirty;
2061 } 2104 }
2062 2105
2063 bool BackendImpl::CheckEntry(EntryImpl* cache_entry) { 2106 bool BackendImpl::CheckEntry(EntryImpl* cache_entry) {
2064 bool ok = block_files_.IsValid(cache_entry->entry()->address()); 2107 bool ok = block_files_.IsValid(cache_entry->entry()->address());
2065 ok = ok && block_files_.IsValid(cache_entry->rankings()->address()); 2108 ok = ok && block_files_.IsValid(cache_entry->rankings()->address());
(...skipping 21 matching lines...) Expand all
2087 if (total_memory > kMaxBuffersSize || total_memory <= 0) 2130 if (total_memory > kMaxBuffersSize || total_memory <= 0)
2088 total_memory = kMaxBuffersSize; 2131 total_memory = kMaxBuffersSize;
2089 2132
2090 done = true; 2133 done = true;
2091 } 2134 }
2092 2135
2093 return static_cast<int>(total_memory); 2136 return static_cast<int>(total_memory);
2094 } 2137 }
2095 2138
2096 } // namespace disk_cache 2139 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698