Update AddEntry() for usage table changes.
[ Merge of http://go/wvgerrit/96071 ] Changes to how the usage table method InvalidateEntry() behaves required additional changes to CDM code that uses this method. This involved some refactoring to AddEntry(), moving the LRU related code to its own function. A few unittests had to be changed / removed as the moving multiple entries changes expectations of several existing tests. Several additional helper methods have been created to improve readability. These include getters for information about the usage table, a method for releasing stale entries, and a method of recording LRU metrics. Bug: 150890014 Bug: 150887808 Bug: 154269671 Test: Linux unit tests and Android unit tests Change-Id: I11a98f9a2dea9b2ae57b37d7d4483a37be721763
This commit is contained in:
@@ -93,6 +93,13 @@ class UsageTableHeader {
|
||||
|
||||
size_t potential_table_capacity() const { return potential_table_capacity_; }
|
||||
|
||||
// Returns the number of entries currently tracked by the CDM that
|
||||
// are related to usage info (streaming licenses).
|
||||
size_t UsageInfoCount() const;
|
||||
// Returns the number of entries currently tracked by the CDM that
|
||||
// are related to offline licenses.
|
||||
size_t OfflineEntryCount() const;
|
||||
|
||||
const std::vector<CdmUsageEntryInfo>& usage_entry_info() const {
|
||||
return usage_entry_info_;
|
||||
}
|
||||
@@ -139,6 +146,10 @@ class UsageTableHeader {
|
||||
CdmResponseType DefragTable(DeviceFiles* device_files,
|
||||
metrics::CryptoMetrics* metrics);
|
||||
|
||||
// This will use the LRU algorithm to decide which entry is to be
|
||||
// evicted.
|
||||
CdmResponseType ReleaseOldestEntry(metrics::CryptoMetrics* metrics);
|
||||
|
||||
virtual bool is_inited() { return is_inited_; }
|
||||
|
||||
// Performs and LRU upgrade on all loaded CdmUsageEntryInfo from a
|
||||
@@ -149,6 +160,12 @@ class UsageTableHeader {
|
||||
|
||||
int64_t GetCurrentTime() { return clock_ref_->GetCurrentTime(); }
|
||||
|
||||
// Sets LRU related metrics based on the provided |staleness| (in
|
||||
// seconds) and |storage_type| of the entry removed.
|
||||
void RecordLruEventMetrics(metrics::CryptoMetrics* metrics,
|
||||
uint64_t staleness,
|
||||
CdmUsageEntryStorageType storage_type);
|
||||
|
||||
// Uses an LRU-base algorithm to determine which licenses should be
|
||||
// removed. This is intended to be used if the usage table is full
|
||||
// and a new entry needs to be added.
|
||||
@@ -212,7 +229,7 @@ class UsageTableHeader {
|
||||
|
||||
// Synchonizes access to the Usage Table Header and bookkeeping
|
||||
// data-structures
|
||||
std::mutex usage_table_header_lock_;
|
||||
mutable std::mutex usage_table_header_lock_;
|
||||
|
||||
metrics::CryptoMetrics alternate_crypto_metrics_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user