Usage table LRU only retrieves a single entry.
[ Merge of http://go/wvgerrit/102167 ] After changes made to how the usage table is defragged by the CDM, it was determined that there is no use in selecting more than a single entry from the usage table to evict. The only failure that can occur when evicting an entry is if the last entry is in use, in that case, evicting other entries will still result in a failure. This change cleans up the LRU algorithm and test cases to reflect the new functionality. Bug: 155230578 Test: Linux unit tests Change-Id: I817c039670d9f72c0e4f6c3fdac45c98ed5b6b21
This commit is contained in:
@@ -114,11 +114,10 @@ class UsageTableHeader {
|
||||
|
||||
static bool DetermineLicenseToRemoveForTesting(
|
||||
const std::vector<CdmUsageEntryInfo>& usage_entry_info_list,
|
||||
int64_t current_time, size_t unexpired_threshold, size_t removal_count,
|
||||
std::vector<uint32_t>* removal_candidates) {
|
||||
int64_t current_time, size_t unexpired_threshold,
|
||||
uint32_t* entry_to_remove) {
|
||||
return DetermineLicenseToRemove(usage_entry_info_list, current_time,
|
||||
unexpired_threshold, removal_count,
|
||||
removal_candidates);
|
||||
unexpired_threshold, entry_to_remove);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -156,7 +155,7 @@ class UsageTableHeader {
|
||||
// device file that had not yet been upgraded to use the LRU data.
|
||||
virtual bool LruUpgradeAllUsageEntries();
|
||||
|
||||
virtual bool GetRemovalCandidates(std::vector<uint32_t>* removal_candidates);
|
||||
virtual bool GetRemovalCandidate(uint32_t* entry_to_remove);
|
||||
|
||||
int64_t GetCurrentTime() { return clock_ref_->GetCurrentTime(); }
|
||||
|
||||
@@ -166,7 +165,7 @@ class UsageTableHeader {
|
||||
uint64_t staleness,
|
||||
CdmUsageEntryStorageType storage_type);
|
||||
|
||||
// Uses an LRU-base algorithm to determine which licenses should be
|
||||
// Uses an LRU-base algorithm to determine which license should be
|
||||
// removed. This is intended to be used if the usage table is full
|
||||
// and a new entry needs to be added.
|
||||
//
|
||||
@@ -181,8 +180,6 @@ class UsageTableHeader {
|
||||
// 2) Unexpired offline licenses will only be considered for
|
||||
// removal if the number of unexpired offline licenses exceeds
|
||||
// |unexpired_threshold|.
|
||||
// The number of licenses to be considered will be less than or
|
||||
// equal to the requested |removal_count|.
|
||||
//
|
||||
// Unknown storage types will be considered above all other entry
|
||||
// types.
|
||||
@@ -195,21 +192,17 @@ class UsageTableHeader {
|
||||
// [in] unexpired_threshold: The maximum number of unexpired
|
||||
// offline licenses that are present, before offline
|
||||
// licenses would be considered for removal.
|
||||
// [in] removal_count: The desired number of removal candidate to
|
||||
// find. Note that the actual number will be anywhere
|
||||
// between 1 and |removal_count|. Must be greater than or
|
||||
// equal to 1.
|
||||
// [out] removal_candidates: List of usage entry numbers of the
|
||||
// entries to be removed. Assume to be unaffected if the
|
||||
// [out] entry_to_remove: Usage entry index of the entry selected
|
||||
// to be removed. Assume to be unaffected if the
|
||||
// function returns |false|.
|
||||
//
|
||||
// Returns:
|
||||
// |true| if at least one removal candidate can be determined.
|
||||
// |true| if an entry has been determined to be removed.
|
||||
// Otherwise returns |false|.
|
||||
static bool DetermineLicenseToRemove(
|
||||
const std::vector<CdmUsageEntryInfo>& usage_entry_info_list,
|
||||
int64_t current_time, size_t unexpired_threshold, size_t removal_count,
|
||||
std::vector<uint32_t>* removal_candidates);
|
||||
int64_t current_time, size_t unexpired_threshold,
|
||||
uint32_t* entry_to_remove);
|
||||
|
||||
// This handle and file system is only to be used when accessing
|
||||
// usage_table_header. Usage entries should use the file system provided
|
||||
|
||||
Reference in New Issue
Block a user