Always store the usage table header in global storage

(This is a merge of http://go/wvgerrit/153551.)

On CE CDM, storage is split between global and per-origin storage, and
one type of storage cannot be used to access the other. (Though, until
an upcoming commit lands, the tests will allow it.) On Android, both
types of storage access the same filesystem. This means that code may
run fine on Android but fail on CE CDM.

The Usage Table Header code normally, explicitly accesses the header
file via global storage. However, a few code paths would try to access
it inconsistently via per-origin storage. This patch updates
StoreTable() to always use the global storage, similar to how
RestoreTable() already functions.

Test: x86-64 w/ storage separated
Test: build_and_run_all_unit_tests.sh
Bug: 236400786
Bug: 192297621
Change-Id: Ie84cef43a7ad169ca8ab701d73c087294ee29705
This commit is contained in:
John "Juce" Bruce
2022-06-17 15:41:14 -07:00
parent b41eeac78c
commit f558ae4244
2 changed files with 12 additions and 12 deletions

View File

@@ -239,7 +239,7 @@ class UsageTableHeader {
// Stores the usage table and it's info. This will increment
// |store_table_counter_| if successful.
bool StoreTable(DeviceFiles* device_files);
bool StoreTable();
CdmResponseType Shrink(metrics::CryptoMetrics* metrics,
uint32_t number_of_usage_entries_to_delete);

View File

@@ -241,7 +241,7 @@ bool UsageTableHeader::CreateNewTable(CryptoSession* const crypto_session) {
LOGE("Failed to create new usage table header");
return false;
}
if (!StoreTable(device_files_.get())) {
if (!StoreTable()) {
LOGE("Failed to store new usage table header");
return false;
}
@@ -299,7 +299,7 @@ CdmResponseType UsageTableHeader::AddEntry(
usage_entry_info_[*usage_entry_number].Clear();
return status;
}
StoreTable(device_files_.get());
StoreTable();
return NO_ERROR;
}
@@ -348,7 +348,7 @@ CdmResponseType UsageTableHeader::UpdateEntry(uint32_t usage_entry_number,
if (status != NO_ERROR) return status;
usage_entry_info_[usage_entry_number].last_use_time = GetCurrentTime();
StoreTable(device_files_.get());
StoreTable();
return NO_ERROR;
}
@@ -391,14 +391,14 @@ CdmResponseType UsageTableHeader::InvalidateEntryInternal(
// changes to the table, and as a result, it will not store the
// invalidated entry.
LOGD("Table was not stored during defrag, storing now");
StoreTable(device_files);
StoreTable();
}
if (status == SYSTEM_INVALIDATED_ERROR) {
LOGE("Invalidate entry failed due to system invalidation error");
return SYSTEM_INVALIDATED_ERROR;
}
} else {
StoreTable(device_files);
StoreTable();
}
return NO_ERROR;
@@ -717,7 +717,7 @@ CdmResponseType UsageTableHeader::MoveEntry(
}
// Store the usage table and usage entry after successful move.
StoreTable(device_files);
StoreTable();
StoreEntry(to_usage_entry_number, device_files, usage_entry);
return NO_ERROR;
@@ -857,10 +857,10 @@ CdmResponseType UsageTableHeader::StoreEntry(uint32_t usage_entry_number,
return NO_ERROR;
}
bool UsageTableHeader::StoreTable(DeviceFiles* device_files) {
bool UsageTableHeader::StoreTable() {
LOGV("Storing usage table information");
const bool result =
device_files->StoreUsageTableInfo(usage_table_header_, usage_entry_info_);
const bool result = device_files_->StoreUsageTableInfo(usage_table_header_,
usage_entry_info_);
if (result) {
++store_table_counter_;
} else {
@@ -906,7 +906,7 @@ CdmResponseType UsageTableHeader::Shrink(
if (status == NO_ERROR) {
usage_entry_info_.resize(new_size);
StoreTable(device_files_.get());
StoreTable();
}
return status;
}
@@ -1128,7 +1128,7 @@ CdmResponseType UsageTableHeader::DefragTable(DeviceFiles* device_files,
// this case, nothing more to do.
if (to_remove == 0) {
LOGD("Defrag completed without shrinking table");
StoreTable(device_files);
StoreTable();
return NO_ERROR;
}