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
3 // found in the LICENSE file.
5 #ifndef NET_DISK_CACHE_BLOCKFILE_EVICTION_V3_H_
6 #define NET_DISK_CACHE_BLOCKFILE_EVICTION_V3_H_
8 #include "base/basictypes.h"
9 #include "base/memory/weak_ptr.h"
10 #include "net/disk_cache/blockfile/disk_format_v3.h"
11 #include "net/disk_cache/blockfile/index_table_v3.h"
13 namespace disk_cache
{
16 class CacheRankingsBlock
;
23 // This class implements the eviction algorithm for the cache and it is tightly
24 // integrated with BackendImpl.
30 void Init(BackendImplV3
* backend
);
33 // Deletes entries from the cache until the current size is below the limit.
34 // If empty is true, the whole cache will be trimmed, regardless of being in
36 void TrimCache(bool empty
);
38 // Notifications of interesting events for a given entry.
39 void OnOpenEntry(EntryImplV3
* entry
);
40 void OnCreateEntry(EntryImplV3
* entry
);
44 void TrimDeletedList(bool empty
);
47 void PostDelayedTrim();
50 bool ShouldTrimDeleted();
51 bool EvictEntry(CacheRankingsBlock
* node
, bool empty
, Rankings::List list
);
53 void TrimCacheV2(bool empty
);
54 void TrimDeleted(bool empty
);
56 bool NodeIsOldEnough(CacheRankingsBlock
* node
, int list
);
57 int SelectListByLength();
58 void ReportListStats();
60 BackendImplV3
* backend_
;
62 IndexHeaderV3
* header_
;
71 base::WeakPtrFactory
<EvictionV3
> ptr_factory_
;
73 DISALLOW_COPY_AND_ASSIGN(EvictionV3
);
76 } // namespace disk_cache
78 #endif // NET_DISK_CACHE_BLOCKFILE_EVICTION_V3_H_