Bug: b/119276649 Merge from: http://go/wvgerrit/66367 Test: Android, CE CDM, Linux unit tests The FileSystem interface as it exists expects an Open for a file and then a Close when finished. However, the Close doesn't delete the file itself and depending on the platform, the underlying impl_ as well, leading to a memory leak. To fix this leak as well as harden against future memory issues, this change refactors the interface to shift away from raw pointers and towards smart pointers. Change-Id: I7a7132ea95cd3775796a540f510b698f4f27dd24
40 lines
1.1 KiB
C++
40 lines
1.1 KiB
C++
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
|
|
// source code may only be used and distributed under the Widevine Master
|
|
// License Agreement.
|
|
|
|
/*********************************************************************
|
|
* level3_file_system_android.h
|
|
*
|
|
* File system for Android for OEMCrypto Level3 File Operations.
|
|
*********************************************************************/
|
|
|
|
#ifndef LEVEL3_FILE_SYSTEM_ANDROID_H_
|
|
#define LEVEL3_FILE_SYSTEM_ANDROID_H_
|
|
|
|
#include "level3_file_system.h"
|
|
|
|
#include <memory>
|
|
|
|
#include "file_store.h"
|
|
|
|
namespace wvoec3 {
|
|
|
|
class OEMCrypto_Level3AndroidFileSystem : public OEMCrypto_Level3FileSystem {
|
|
public:
|
|
OEMCrypto_Level3AndroidFileSystem();
|
|
~OEMCrypto_Level3AndroidFileSystem();
|
|
ssize_t Read(const char *filename, void *buffer, size_t size);
|
|
ssize_t Write(const char *filename, const void *buffer, size_t size);
|
|
bool Exists(const char *filename);
|
|
ssize_t FileSize(const char *filename);
|
|
bool Remove(const char *filename);
|
|
|
|
private:
|
|
std::string base_path_;
|
|
std::unique_ptr<wvcdm::FileSystem> file_system_;
|
|
};
|
|
|
|
} // namespace wvoec3
|
|
|
|
#endif
|