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

Side by Side Diff: net/disk_cache/eviction.cc

Issue 149218: Disk cache: Keep a map of all open entries.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // The eviction policy is a very simple pure LRU, so the elements at the end of 5 // The eviction policy is a very simple pure LRU, so the elements at the end of
6 // the list are evicted until kCleanUpMargin free space is available. There is 6 // the list are evicted until kCleanUpMargin free space is available. There is
7 // only one list in use (Rankings::NO_USE), and elements are sent to the front 7 // only one list in use (Rankings::NO_USE), and elements are sent to the front
8 // of the list whenever they are accessed. 8 // of the list whenever they are accessed.
9 9
10 // The new (in-development) eviction policy ads re-use as a factor to evict 10 // The new (in-development) eviction policy ads re-use as a factor to evict
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 175
176 bool Eviction::EvictEntry(CacheRankingsBlock* node, bool empty) { 176 bool Eviction::EvictEntry(CacheRankingsBlock* node, bool empty) {
177 EntryImpl* entry; 177 EntryImpl* entry;
178 bool dirty; 178 bool dirty;
179 if (backend_->NewEntry(Addr(node->Data()->contents), &entry, &dirty)) { 179 if (backend_->NewEntry(Addr(node->Data()->contents), &entry, &dirty)) {
180 Trace("NewEntry failed on Trim 0x%x", node->address().value()); 180 Trace("NewEntry failed on Trim 0x%x", node->address().value());
181 return false; 181 return false;
182 } 182 }
183 183
184 if (node->Data()->pointer) { 184 if (node->Data()->pointer) {
185 entry = EntryImpl::Update(entry); 185 // We ignore the failure; we're removing the entry anyway.
186 entry->Update();
186 } 187 }
187 ReportTrimTimes(entry); 188 ReportTrimTimes(entry);
188 if (empty || !new_eviction_) { 189 if (empty || !new_eviction_) {
189 entry->Doom(); 190 entry->Doom();
190 } else { 191 } else {
191 entry->DeleteEntryData(false); 192 entry->DeleteEntryData(false);
192 EntryStore* info = entry->entry()->Data(); 193 EntryStore* info = entry->entry()->Data();
193 DCHECK(ENTRY_NORMAL == info->state); 194 DCHECK(ENTRY_NORMAL == info->state);
194 195
195 rankings_->Remove(entry->rankings(), GetListForEntryV2(entry)); 196 rankings_->Remove(entry->rankings(), GetListForEntryV2(entry));
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 394
394 bool Eviction::RemoveDeletedNode(CacheRankingsBlock* node) { 395 bool Eviction::RemoveDeletedNode(CacheRankingsBlock* node) {
395 EntryImpl* entry; 396 EntryImpl* entry;
396 bool dirty; 397 bool dirty;
397 if (backend_->NewEntry(Addr(node->Data()->contents), &entry, &dirty)) { 398 if (backend_->NewEntry(Addr(node->Data()->contents), &entry, &dirty)) {
398 Trace("NewEntry failed on Trim 0x%x", node->address().value()); 399 Trace("NewEntry failed on Trim 0x%x", node->address().value());
399 return false; 400 return false;
400 } 401 }
401 402
402 if (node->Data()->pointer) { 403 if (node->Data()->pointer) {
403 entry = EntryImpl::Update(entry); 404 // We ignore the failure; we're removing the entry anyway.
405 entry->Update();
404 } 406 }
405 entry->entry()->Data()->state = ENTRY_DOOMED; 407 entry->entry()->Data()->state = ENTRY_DOOMED;
406 entry->Doom(); 408 entry->Doom();
407 entry->Release(); 409 entry->Release();
408 return true; 410 return true;
409 } 411 }
410 412
411 bool Eviction::NodeIsOldEnough(CacheRankingsBlock* node, int list) { 413 bool Eviction::NodeIsOldEnough(CacheRankingsBlock* node, int list) {
412 if (!node) 414 if (!node)
413 return false; 415 return false;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 Time::FromInternalValue(last2.get()->Data()->last_used)); 454 Time::FromInternalValue(last2.get()->Data()->last_used));
453 if (last3.get()) 455 if (last3.get())
454 CACHE_UMA(AGE, "HighUseAge", header_->experiment, 456 CACHE_UMA(AGE, "HighUseAge", header_->experiment,
455 Time::FromInternalValue(last3.get()->Data()->last_used)); 457 Time::FromInternalValue(last3.get()->Data()->last_used));
456 if (last4.get()) 458 if (last4.get())
457 CACHE_UMA(AGE, "DeletedAge", header_->experiment, 459 CACHE_UMA(AGE, "DeletedAge", header_->experiment,
458 Time::FromInternalValue(last4.get()->Data()->last_used)); 460 Time::FromInternalValue(last4.get()->Data()->last_used));
459 } 461 }
460 462
461 } // namespace disk_cache 463 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698