Add More Base Path Helpers to DeviceFiles

(This is a merge of http://go/wvgerrit/13910/ from the Widevine CDM
repository.)

DeviceFiles has a lot of repeated code whenever it needs to check for
file existence or remove a file. When reading and writing files, it
has wrappers that handle this repeated burden. This change adds
wrappers for the other functionality used by DeviceFiles as well, to
reduce duplication.

Change-Id: If959b504672c1b907346d28f31648d8028de8bdf
This commit is contained in:
John "Juce" Bruce
2015-03-31 15:40:27 -07:00
parent 54f3b6d376
commit c66badec60
2 changed files with 87 additions and 50 deletions

View File

@@ -3,6 +3,8 @@
#ifndef WVCDM_CORE_DEVICE_FILES_H_
#define WVCDM_CORE_DEVICE_FILES_H_
#include <unistd.h>
#include "scoped_ptr.h"
#include "wv_cdm_types.h"
@@ -81,9 +83,14 @@ class DeviceFiles {
CdmKeyResponse* license_response);
private:
// 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 char* name, const std::string& serialized_file);
bool StoreFileRaw(const char* name, const std::string& serialized_file);
bool RetrieveHashedFile(const char* name, std::string* serialized_file);
bool FileExists(const char* name);
bool RemoveFile(const char* name);
ssize_t GetFileSize(const char* name);
// Certificate and offline licenses are now stored in security
// level specific directories. In an earlier version they were