Return error codes when storing or retrieving licenses

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

This allows error codes from device files to be added as sub-errors when
errors such as GET_LICENSE_ERROR are encountered.

Bug: 112357085
Bug: 115382201
Test: WV unit/integration tests

Change-Id: I505a87086ce584efc7e482984c0f132ac5329e16
This commit is contained in:
Rahul Frias
2019-01-14 19:09:37 -08:00
parent cfe7221d9e
commit 8b61a03b5f
6 changed files with 206 additions and 90 deletions

View File

@@ -30,6 +30,26 @@ class DeviceFiles {
kLicenseStateUnknown,
} LicenseState;
enum ResponseType {
kNoError = 0,
kObjectNotInitialized = 1,
kParameterNull = 2,
kBasePathUnavailable = 3,
kFileNotFound = 4,
kFileOpenFailed = 5,
kFileWriteError = 6,
kFileReadError = 7,
kInvalidFileSize = 8,
kHashComputationFailed = 9,
kFileHashMismatch = 10,
kFileParseError1 = 11,
kFileParseError2 = 12,
kUnknownLicenseState = 13,
kIncorrectFileType = 14,
kIncorrectFileVersion = 15,
kLicenseNotPresent = 16,
};
struct CdmUsageData {
std::string provider_session_token;
CdmKeyMessage license_request;
@@ -69,7 +89,8 @@ class DeviceFiles {
int64_t grace_period_end_time,
const CdmAppParameterMap& app_parameters,
const CdmUsageEntry& usage_entry,
uint32_t usage_entry_number);
uint32_t usage_entry_number,
ResponseType* result);
virtual bool RetrieveLicense(
const std::string& key_set_id, LicenseState* state,
CdmInitData* pssh_data, CdmKeyMessage* key_request,
@@ -77,7 +98,8 @@ class DeviceFiles {
CdmKeyResponse* key_renewal_response, std::string* release_server_url,
int64_t* playback_start_time, int64_t* last_playback_time,
int64_t* grace_period_end_time, CdmAppParameterMap* app_parameters,
CdmUsageEntry* usage_entry, uint32_t* usage_entry_number);
CdmUsageEntry* usage_entry, uint32_t* usage_entry_number,
ResponseType* result);
virtual bool DeleteLicense(const std::string& key_set_id);
virtual bool ListLicenses(std::vector<std::string>* key_set_ids);
virtual bool DeleteAllFiles();
@@ -197,12 +219,12 @@ class DeviceFiles {
// Helpers that wrap the File interface and automatically handle hashing, as
// well as adding the device files base path to to the file name.
bool StoreFileWithHash(const std::string& name,
const std::string& serialized_file);
bool StoreFileRaw(const std::string& name,
const std::string& serialized_file);
bool RetrieveHashedFile(const std::string& name,
video_widevine_client::sdk::File* file);
ResponseType StoreFileWithHash(const std::string& name,
const std::string& serialized_file);
ResponseType StoreFileRaw(const std::string& name,
const std::string& serialized_file);
ResponseType RetrieveHashedFile(const std::string& name,
video_widevine_client::sdk::File* file);
bool FileExists(const std::string& name);
bool ListFiles(std::vector<std::string>* names);
bool RemoveFile(const std::string& name);