Introduce UsageTableHeader class
[ Merge of http://go/wvgerrit/23820 ] The UsageTableHeader class is a singleton that CDM sessions will share. A separate object will be created for each security level. The class synchronizes access to usage table header and associated data-structures and controls when they are read in or written out to non-secure persistent storage. Upgrades from a fixed size usage table (supported by previous versions of the OEMCrypto API v9-12) are handled by this class. b/34327459 Test: Verified by unit/integration tests on angler Change-Id: Ifc5996985e76bc260c01e55bc12aab1248389a80
This commit is contained in:
@@ -62,6 +62,10 @@ class CdmLicense {
|
||||
return is_offline_;
|
||||
}
|
||||
|
||||
static bool ExtractProviderSessionToken(
|
||||
const CdmKeyResponse& license_response,
|
||||
std::string* provider_session_token);
|
||||
|
||||
private:
|
||||
|
||||
CdmResponseType HandleKeyErrorResponse(
|
||||
|
||||
109
libwvdrmengine/cdm/core/include/usage_table_header.h
Normal file
109
libwvdrmengine/cdm/core/include/usage_table_header.h
Normal file
@@ -0,0 +1,109 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
|
||||
#ifndef WVCDM_CORE_USAGE_TABLE_HEADER_H_
|
||||
#define WVCDM_CORE_USAGE_TABLE_HEADER_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "device_files.h"
|
||||
#include "lock.h"
|
||||
#include "metrics_group.h"
|
||||
#include "scoped_ptr.h"
|
||||
#include "timer_metric.h"
|
||||
#include "wv_cdm_types.h"
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
class FileSystem;
|
||||
class CryptoSession;
|
||||
|
||||
// The UsageTableHeader class is a singleton that CDM sessions will share.
|
||||
// A separate object will be created for each security level.
|
||||
// The class synchronizes access to usage table header and associated
|
||||
// data-structures and controls when they are read in or written out to
|
||||
// non-secure persistent storage.
|
||||
// Upgrades from a fixed size usage table (supported by previous
|
||||
// versions of the OEMCrypto API v9-12) are handled by this class.
|
||||
// |usage_entry| and |usage_entry_number|s need to be saved in the license
|
||||
// and usage info records by the caller.
|
||||
class UsageTableHeader {
|
||||
public:
|
||||
// This methods instantiates or retrieves a usage table header singleton of
|
||||
// appropriate security level as specified by the |crypto_session|
|
||||
// object.
|
||||
// |crypto_session| is used to create or load a usage master table and
|
||||
// not cached beyound this call.
|
||||
static UsageTableHeader* GetInstance(FileSystem* file_system,
|
||||
CryptoSession* crypto_session_);
|
||||
virtual ~UsageTableHeader() {}
|
||||
|
||||
// |persistent_license| false indicates usage info record
|
||||
CdmResponseType AddEntry(CryptoSession* crypto_session,
|
||||
bool persistent_license,
|
||||
const CdmKeySetId& key_set_id,
|
||||
const std::string& usage_info_filename,
|
||||
uint32_t* usage_entry_number);
|
||||
CdmResponseType LoadEntry(CryptoSession* crypto_session,
|
||||
const CdmUsageEntry& usage_entry,
|
||||
uint32_t usage_entry_number);
|
||||
CdmResponseType UpdateEntry(CryptoSession* crypto_session,
|
||||
CdmUsageEntry* usage_entry);
|
||||
|
||||
// The licenses or usage info records specified by |usage_entry_number|
|
||||
// should not be in use by any open CryptoSession objects when calls
|
||||
// to DeleteEntry and MoveEntry are made.
|
||||
CdmResponseType DeleteEntry(uint32_t usage_entry_number);
|
||||
CdmResponseType MoveEntry(uint32_t from_usage_entry_number,
|
||||
const CdmUsageEntry& from_usage_entry,
|
||||
uint32_t to_usage_entry_number);
|
||||
|
||||
private:
|
||||
UsageTableHeader(FileSystem* file_system, CryptoSession* crypto_session,
|
||||
CdmSecurityLevel security_level);
|
||||
|
||||
CdmResponseType GetEntry(uint32_t usage_entry_number,
|
||||
CdmUsageEntry* usage_entry);
|
||||
CdmResponseType StoreEntry(uint32_t usage_entry_number,
|
||||
const CdmUsageEntry& usage_entry);
|
||||
|
||||
bool DeleteLastEntry();
|
||||
|
||||
CdmResponseType UpgradeFromUsageTable();
|
||||
bool UpgradeLicensesFromUsageTable();
|
||||
bool UpgradeUsageInfoFromUsageTable();
|
||||
|
||||
virtual bool is_inited() { return is_inited_; }
|
||||
|
||||
SecurityLevel GetSecurityLevel() {
|
||||
return security_level_ == kSecurityLevelL3 ? kLevel3 : kLevelDefault;
|
||||
}
|
||||
|
||||
static UsageTableHeader* usage_table_header_l1_;
|
||||
static UsageTableHeader* usage_table_header_l3_;
|
||||
|
||||
scoped_ptr<DeviceFiles> file_handle_;
|
||||
CdmSecurityLevel security_level_;
|
||||
|
||||
CdmUsageTableHeader usage_table_header_;
|
||||
std::vector<CdmUsageEntryInfo> usage_entry_info_;
|
||||
|
||||
metrics::MetricsGroup metrics_;
|
||||
metrics::TimerMetric life_span_;
|
||||
|
||||
// Lock to ensure that a single object is created for each security level
|
||||
// and data member to represent whether an object has been correctly
|
||||
// initialized.
|
||||
bool is_inited_;
|
||||
static Lock initialization_lock_;
|
||||
|
||||
// Synchonizes access to the Usage Table Header and bookkeeping
|
||||
// data-structures
|
||||
Lock usage_table_header_lock_;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(UsageTableHeader);
|
||||
};
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_CORE_USAGE_TABLE_HEADER_H_
|
||||
@@ -279,6 +279,17 @@ enum CdmResponseType {
|
||||
INVALID_PARAMETERS_ENG_23,
|
||||
USAGE_INFORMATION_SUPPORT_FAILED,
|
||||
USAGE_SUPPORT_GET_API_FAILED,
|
||||
UNEXPECTED_EMPTY_USAGE_ENTRY, /* 240 */
|
||||
INVALID_USAGE_ENTRY_NUMBER_MODIFICATION,
|
||||
USAGE_INVALID_NEW_ENTRY,
|
||||
USAGE_INVALID_PARAMETERS_1,
|
||||
USAGE_RETRIEVE_LICENSE_FAILED,
|
||||
USAGE_RETRIEVE_USAGE_INFO_FAILED, /* 245 */
|
||||
USAGE_RETRIEVE_INVALID_STORAGE_TYPE,
|
||||
USAGE_ENTRY_NUMBER_MISMATCH,
|
||||
USAGE_STORE_LICENSE_FAILED,
|
||||
USAGE_STORE_USAGE_INFO_FAILED,
|
||||
USAGE_INVALID_LOAD_ENTRY, /* 250 */
|
||||
};
|
||||
|
||||
enum CdmKeyStatus {
|
||||
|
||||
Reference in New Issue
Block a user