Save usage information before closing a session

[ Merge of http://go/wvgerrit/48640 ]

Usage information is saved periodically, in order to avoid excessive
flash writes. This limits our session usage accuracy to
within a usage save period. Saving usage information when
closing a session is an improvement and addresses some failures
seen with Netflix compliance tests.

Bug: 74015553
Test: WV unit/integration tests
Change-Id: I680aad05922f334df0611ff3933082a512f7c002
This commit is contained in:
Rahul Frias
2018-04-24 22:59:55 -07:00
parent 40b1131c13
commit 9ba6493e1b
2 changed files with 10 additions and 3 deletions

View File

@@ -54,6 +54,12 @@ CdmSession::CdmSession(FileSystem* file_system,
}
CdmSession::~CdmSession() {
if (usage_support_type_ == kUsageEntrySupport &&
has_provider_session_token() &&
usage_table_header_ != NULL) {
UpdateUsageEntryInformation();
}
if (!key_set_id_.empty()) {
// Unreserve the license ID.
file_handle_->UnreserveLicenseId(key_set_id_);

View File

@@ -338,11 +338,12 @@ TEST_F(CdmSessionTest, UpdateUsageEntry) {
// Set up mocks and expectations for the UpdateUsageEntryInformation call.
EXPECT_CALL(*crypto_session_, GetUsageSupportType(_))
.WillOnce(DoAll(SetArgPointee<0>(kUsageEntrySupport), Return(NO_ERROR)));
.WillRepeatedly(DoAll(
SetArgPointee<0>(kUsageEntrySupport), Return(NO_ERROR)));
EXPECT_CALL(*license_parser_, provider_session_token())
.WillOnce(Return("Mock provider session token"));
.WillRepeatedly(Return("Mock provider session token"));
EXPECT_CALL(usage_table_header_, UpdateEntry(NotNull(), NotNull()))
.WillOnce(Return(NO_ERROR));
.WillRepeatedly(Return(NO_ERROR));
EXPECT_EQ(NO_ERROR, cdm_session_->Init(NULL));
EXPECT_EQ(kUsageEntrySupport, cdm_session_->get_usage_support_type())