Replace scoped_ptr With std::unique_ptr
(This is a merge of http://go/wvgerrit/65782) We have had our own scoped_ptr implementation that is used throughout the codebase. Now that we support C++11, we can replace these with std::unique_ptr. Doing this replacement exposed a few places where the two were not interchangeable. OEMCrypto Ref was doing some unsafe things with passing scoped_ptrs to functions and has been updated to use move semantics. And a few constructors were explicitly constructing a scoped_ptr with NULL, which is ambiguous with std::unique_ptr. These have been replaced with default constructor calls. Bug: 111851141 Test: CE CDM Unit Tests Test: Android Unit Tests Change-Id: I37d6d7aad4906709381c74f0c5439f826d2be768
This commit is contained in:
@@ -19,7 +19,6 @@
|
|||||||
#include "lock.h"
|
#include "lock.h"
|
||||||
#include "metrics_collections.h"
|
#include "metrics_collections.h"
|
||||||
#include "oemcrypto_adapter.h"
|
#include "oemcrypto_adapter.h"
|
||||||
#include "scoped_ptr.h"
|
|
||||||
#include "service_certificate.h"
|
#include "service_certificate.h"
|
||||||
#include "wv_cdm_constants.h"
|
#include "wv_cdm_constants.h"
|
||||||
#include "wv_cdm_types.h"
|
#include "wv_cdm_types.h"
|
||||||
@@ -325,7 +324,7 @@ class CdmEngine {
|
|||||||
|
|
||||||
CdmSessionMap session_map_;
|
CdmSessionMap session_map_;
|
||||||
CdmReleaseKeySetMap release_key_sets_;
|
CdmReleaseKeySetMap release_key_sets_;
|
||||||
scoped_ptr<CertificateProvisioning> cert_provisioning_;
|
std::unique_ptr<CertificateProvisioning> cert_provisioning_;
|
||||||
SecurityLevel cert_provisioning_requested_security_level_;
|
SecurityLevel cert_provisioning_requested_security_level_;
|
||||||
FileSystem* file_system_;
|
FileSystem* file_system_;
|
||||||
Clock clock_;
|
Clock clock_;
|
||||||
@@ -334,8 +333,8 @@ class CdmEngine {
|
|||||||
static bool seeded_;
|
static bool seeded_;
|
||||||
|
|
||||||
// usage related variables
|
// usage related variables
|
||||||
scoped_ptr<CdmSession> usage_session_;
|
std::unique_ptr<CdmSession> usage_session_;
|
||||||
scoped_ptr<UsagePropertySet> usage_property_set_;
|
std::unique_ptr<UsagePropertySet> usage_property_set_;
|
||||||
int64_t last_usage_information_update_time_;
|
int64_t last_usage_information_update_time_;
|
||||||
|
|
||||||
// Protect release_key_sets_ from non-thread-safe operations.
|
// Protect release_key_sets_ from non-thread-safe operations.
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#ifndef WVCDM_CORE_CDM_SESSION_H_
|
#ifndef WVCDM_CORE_CDM_SESSION_H_
|
||||||
#define WVCDM_CORE_CDM_SESSION_H_
|
#define WVCDM_CORE_CDM_SESSION_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -18,7 +19,6 @@
|
|||||||
#include "metrics_collections.h"
|
#include "metrics_collections.h"
|
||||||
#include "oemcrypto_adapter.h"
|
#include "oemcrypto_adapter.h"
|
||||||
#include "policy_engine.h"
|
#include "policy_engine.h"
|
||||||
#include "scoped_ptr.h"
|
|
||||||
#include "timer_metric.h"
|
#include "timer_metric.h"
|
||||||
#include "wv_cdm_types.h"
|
#include "wv_cdm_types.h"
|
||||||
|
|
||||||
@@ -228,10 +228,10 @@ class CdmSession {
|
|||||||
bool closed_; // Session closed, but final shared_ptr has not been released.
|
bool closed_; // Session closed, but final shared_ptr has not been released.
|
||||||
CdmSessionId session_id_;
|
CdmSessionId session_id_;
|
||||||
FileSystem* file_system_;
|
FileSystem* file_system_;
|
||||||
scoped_ptr<CdmLicense> license_parser_;
|
std::unique_ptr<CdmLicense> license_parser_;
|
||||||
scoped_ptr<CryptoSession> crypto_session_;
|
std::unique_ptr<CryptoSession> crypto_session_;
|
||||||
scoped_ptr<PolicyEngine> policy_engine_;
|
std::unique_ptr<PolicyEngine> policy_engine_;
|
||||||
scoped_ptr<DeviceFiles> file_handle_;
|
std::unique_ptr<DeviceFiles> file_handle_;
|
||||||
bool license_received_;
|
bool license_received_;
|
||||||
bool is_offline_;
|
bool is_offline_;
|
||||||
bool is_release_;
|
bool is_release_;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#ifndef WVCDM_CORE_CERTIFICATE_PROVISIONING_H_
|
#ifndef WVCDM_CORE_CERTIFICATE_PROVISIONING_H_
|
||||||
#define WVCDM_CORE_CERTIFICATE_PROVISIONING_H_
|
#define WVCDM_CORE_CERTIFICATE_PROVISIONING_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "crypto_session.h"
|
#include "crypto_session.h"
|
||||||
@@ -12,7 +13,6 @@
|
|||||||
#include "license_protocol.pb.h"
|
#include "license_protocol.pb.h"
|
||||||
#include "metrics_collections.h"
|
#include "metrics_collections.h"
|
||||||
#include "oemcrypto_adapter.h"
|
#include "oemcrypto_adapter.h"
|
||||||
#include "scoped_ptr.h"
|
|
||||||
#include "service_certificate.h"
|
#include "service_certificate.h"
|
||||||
#include "wv_cdm_types.h"
|
#include "wv_cdm_types.h"
|
||||||
|
|
||||||
@@ -53,9 +53,9 @@ class CertificateProvisioning {
|
|||||||
video_widevine::SignedProvisioningMessage::ProtocolVersion
|
video_widevine::SignedProvisioningMessage::ProtocolVersion
|
||||||
GetProtocolVersion();
|
GetProtocolVersion();
|
||||||
|
|
||||||
scoped_ptr<CryptoSession> crypto_session_;
|
std::unique_ptr<CryptoSession> crypto_session_;
|
||||||
CdmCertificateType cert_type_;
|
CdmCertificateType cert_type_;
|
||||||
scoped_ptr<ServiceCertificate> service_certificate_;
|
std::unique_ptr<ServiceCertificate> service_certificate_;
|
||||||
|
|
||||||
CORE_DISALLOW_COPY_AND_ASSIGN(CertificateProvisioning);
|
CORE_DISALLOW_COPY_AND_ASSIGN(CertificateProvisioning);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#define WVCDM_CORE_CRYPTO_SESSION_H_
|
#define WVCDM_CORE_CRYPTO_SESSION_H_
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -15,7 +16,6 @@
|
|||||||
#include "lock.h"
|
#include "lock.h"
|
||||||
#include "metrics_collections.h"
|
#include "metrics_collections.h"
|
||||||
#include "oemcrypto_adapter.h"
|
#include "oemcrypto_adapter.h"
|
||||||
#include "scoped_ptr.h"
|
|
||||||
#include "timer_metric.h"
|
#include "timer_metric.h"
|
||||||
#include "wv_cdm_types.h"
|
#include "wv_cdm_types.h"
|
||||||
|
|
||||||
@@ -295,7 +295,7 @@ class CryptoSession {
|
|||||||
SubLicenseSessionMap sub_license_oec_sessions_;
|
SubLicenseSessionMap sub_license_oec_sessions_;
|
||||||
// Used for sub license sessions.
|
// Used for sub license sessions.
|
||||||
std::string wrapped_key_;
|
std::string wrapped_key_;
|
||||||
scoped_ptr<KeySession> key_session_;
|
std::unique_ptr<KeySession> key_session_;
|
||||||
|
|
||||||
OEMCryptoBufferType destination_buffer_type_;
|
OEMCryptoBufferType destination_buffer_type_;
|
||||||
bool is_destination_buffer_type_valid_;
|
bool is_destination_buffer_type_valid_;
|
||||||
@@ -313,7 +313,7 @@ class CryptoSession {
|
|||||||
CdmCipherMode cipher_mode_;
|
CdmCipherMode cipher_mode_;
|
||||||
uint32_t api_version_;
|
uint32_t api_version_;
|
||||||
|
|
||||||
static scoped_ptr<CryptoSessionFactory> factory_;
|
static std::unique_ptr<CryptoSessionFactory> factory_;
|
||||||
|
|
||||||
CORE_DISALLOW_COPY_AND_ASSIGN(CryptoSession);
|
CORE_DISALLOW_COPY_AND_ASSIGN(CryptoSession);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
#include "device_files.pb.h"
|
#include "device_files.pb.h"
|
||||||
#include "disallow_copy_and_assign.h"
|
#include "disallow_copy_and_assign.h"
|
||||||
#include "scoped_ptr.h"
|
|
||||||
#include "wv_cdm_types.h"
|
#include "wv_cdm_types.h"
|
||||||
|
|
||||||
#if defined(UNIT_TEST)
|
#if defined(UNIT_TEST)
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
#ifndef WVCDM_CORE_LICENSE_H_
|
#ifndef WVCDM_CORE_LICENSE_H_
|
||||||
#define WVCDM_CORE_LICENSE_H_
|
#define WVCDM_CORE_LICENSE_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include "disallow_copy_and_assign.h"
|
#include "disallow_copy_and_assign.h"
|
||||||
#include "initialization_data.h"
|
#include "initialization_data.h"
|
||||||
#include "license_protocol.pb.h"
|
#include "license_protocol.pb.h"
|
||||||
#include "scoped_ptr.h"
|
|
||||||
#include "service_certificate.h"
|
#include "service_certificate.h"
|
||||||
#include "wv_cdm_types.h"
|
#include "wv_cdm_types.h"
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ class CdmLicense {
|
|||||||
CdmClientTokenType client_token_type_;
|
CdmClientTokenType client_token_type_;
|
||||||
std::string device_id_;
|
std::string device_id_;
|
||||||
const CdmSessionId session_id_;
|
const CdmSessionId session_id_;
|
||||||
scoped_ptr<InitializationData> stored_init_data_;
|
std::unique_ptr<InitializationData> stored_init_data_;
|
||||||
bool initialized_;
|
bool initialized_;
|
||||||
std::set<KeyId> loaded_keys_;
|
std::set<KeyId> loaded_keys_;
|
||||||
std::string provider_session_token_;
|
std::string provider_session_token_;
|
||||||
@@ -135,7 +135,7 @@ class CdmLicense {
|
|||||||
// Used for certificate based licensing
|
// Used for certificate based licensing
|
||||||
CdmKeyMessage key_request_;
|
CdmKeyMessage key_request_;
|
||||||
|
|
||||||
scoped_ptr<Clock> clock_;
|
std::unique_ptr<Clock> clock_;
|
||||||
|
|
||||||
// For testing
|
// For testing
|
||||||
// CdmLicense takes ownership of the clock.
|
// CdmLicense takes ownership of the clock.
|
||||||
|
|||||||
@@ -6,12 +6,12 @@
|
|||||||
#define WVCDM_CORE_POLICY_ENGINE_H_
|
#define WVCDM_CORE_POLICY_ENGINE_H_
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "disallow_copy_and_assign.h"
|
#include "disallow_copy_and_assign.h"
|
||||||
#include "license_key_status.h"
|
#include "license_key_status.h"
|
||||||
#include "license_protocol.pb.h"
|
#include "license_protocol.pb.h"
|
||||||
#include "scoped_ptr.h"
|
|
||||||
#include "wv_cdm_types.h"
|
#include "wv_cdm_types.h"
|
||||||
|
|
||||||
namespace wvcdm {
|
namespace wvcdm {
|
||||||
@@ -212,14 +212,14 @@ class PolicyEngine {
|
|||||||
|
|
||||||
// Keys associated with license - holds allowed usage, usage constraints,
|
// Keys associated with license - holds allowed usage, usage constraints,
|
||||||
// and current status (CdmKeyStatus)
|
// and current status (CdmKeyStatus)
|
||||||
scoped_ptr<LicenseKeys> license_keys_;
|
std::unique_ptr<LicenseKeys> license_keys_;
|
||||||
|
|
||||||
// Device checks
|
// Device checks
|
||||||
int64_t next_device_check_;
|
int64_t next_device_check_;
|
||||||
uint32_t current_resolution_;
|
uint32_t current_resolution_;
|
||||||
CryptoSession* crypto_session_;
|
CryptoSession* crypto_session_;
|
||||||
|
|
||||||
scoped_ptr<Clock> clock_;
|
std::unique_ptr<Clock> clock_;
|
||||||
|
|
||||||
CORE_DISALLOW_COPY_AND_ASSIGN(PolicyEngine);
|
CORE_DISALLOW_COPY_AND_ASSIGN(PolicyEngine);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,12 +6,12 @@
|
|||||||
#define WVCDM_CORE_PROPERTIES_H_
|
#define WVCDM_CORE_PROPERTIES_H_
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "cdm_client_property_set.h"
|
#include "cdm_client_property_set.h"
|
||||||
#include "disallow_copy_and_assign.h"
|
#include "disallow_copy_and_assign.h"
|
||||||
#include "lock.h"
|
#include "lock.h"
|
||||||
#include "scoped_ptr.h"
|
|
||||||
#include "wv_cdm_types.h"
|
#include "wv_cdm_types.h"
|
||||||
|
|
||||||
#if defined(UNIT_TEST)
|
#if defined(UNIT_TEST)
|
||||||
@@ -115,7 +115,7 @@ class Properties {
|
|||||||
static bool use_certificates_as_identification_;
|
static bool use_certificates_as_identification_;
|
||||||
static bool provisioning_messages_are_binary_;
|
static bool provisioning_messages_are_binary_;
|
||||||
static bool allow_service_certificate_requests_;
|
static bool allow_service_certificate_requests_;
|
||||||
static scoped_ptr<CdmClientPropertySetMap> session_property_set_;
|
static std::unique_ptr<CdmClientPropertySetMap> session_property_set_;
|
||||||
|
|
||||||
CORE_DISALLOW_COPY_AND_ASSIGN(Properties);
|
CORE_DISALLOW_COPY_AND_ASSIGN(Properties);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
// 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.
|
|
||||||
//
|
|
||||||
// A simple and partial implementation of scoped_ptr class.
|
|
||||||
// The implementation is copied from gtest/include/gtest/internal/gtest-port.h.
|
|
||||||
//
|
|
||||||
#ifndef WVCDM_CORE_SCOPED_PTR_H_
|
|
||||||
#define WVCDM_CORE_SCOPED_PTR_H_
|
|
||||||
|
|
||||||
#include "disallow_copy_and_assign.h"
|
|
||||||
|
|
||||||
namespace wvcdm {
|
|
||||||
|
|
||||||
// A scoped_ptr<T> is like a T*, except that the destructor of scoped_ptr<T>
|
|
||||||
// automatically deletes the pointer it holds (if any).
|
|
||||||
// That is, scoped_ptr<T> owns the T object that it points to.
|
|
||||||
// Like a T*, a scoped_ptr<T> may hold either NULL or a pointer to a T object.
|
|
||||||
// Also like T*, scoped_ptr<T> is thread-compatible, and once you
|
|
||||||
// dereference it, you get the thread safety guarantees of T.
|
|
||||||
//
|
|
||||||
// The size of scoped_ptr is small. On most compilers, sizeof(scoped_ptr<T>)
|
|
||||||
// == sizeof(T*).
|
|
||||||
//
|
|
||||||
// Current implementation targets having a strict subset of C++11's
|
|
||||||
// unique_ptr<> features. Known deficiencies include not supporting move-only
|
|
||||||
// deleteres, function pointers as deleters, and deleters with reference
|
|
||||||
// types.
|
|
||||||
|
|
||||||
// This implementation of scoped_ptr is PARTIAL, e.g. it does not support move,
|
|
||||||
// custom deleter etc.
|
|
||||||
template <typename T>
|
|
||||||
class scoped_ptr {
|
|
||||||
public:
|
|
||||||
typedef T element_type;
|
|
||||||
|
|
||||||
explicit scoped_ptr(T* p = NULL) : ptr_(p) {}
|
|
||||||
~scoped_ptr() { reset(); }
|
|
||||||
|
|
||||||
T& operator*() const { return *ptr_; }
|
|
||||||
T* operator->() const { return ptr_; }
|
|
||||||
T* get() const { return ptr_; }
|
|
||||||
|
|
||||||
T* release() {
|
|
||||||
T* const ptr = ptr_;
|
|
||||||
ptr_ = NULL;
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void reset(T* p = NULL) {
|
|
||||||
if (p != ptr_) {
|
|
||||||
if (sizeof(T) > 0) { // Makes sure T is a complete type.
|
|
||||||
delete ptr_;
|
|
||||||
}
|
|
||||||
ptr_ = p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
T* ptr_;
|
|
||||||
|
|
||||||
CORE_DISALLOW_COPY_AND_ASSIGN(scoped_ptr);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace wvcdm
|
|
||||||
|
|
||||||
#endif // WVCDM_CORE_SCOPED_PTR_H_
|
|
||||||
@@ -18,7 +18,6 @@
|
|||||||
#include "disallow_copy_and_assign.h"
|
#include "disallow_copy_and_assign.h"
|
||||||
#include "license_protocol.pb.h"
|
#include "license_protocol.pb.h"
|
||||||
#include "privacy_crypto.h"
|
#include "privacy_crypto.h"
|
||||||
#include "scoped_ptr.h"
|
|
||||||
#include "wv_cdm_types.h"
|
#include "wv_cdm_types.h"
|
||||||
|
|
||||||
namespace wvcdm {
|
namespace wvcdm {
|
||||||
@@ -79,7 +78,7 @@ class ServiceCertificate {
|
|||||||
std::string provider_id_;
|
std::string provider_id_;
|
||||||
|
|
||||||
// Public key.
|
// Public key.
|
||||||
scoped_ptr<RsaPublicKey> public_key_;
|
std::unique_ptr<RsaPublicKey> public_key_;
|
||||||
|
|
||||||
CORE_DISALLOW_COPY_AND_ASSIGN(ServiceCertificate);
|
CORE_DISALLOW_COPY_AND_ASSIGN(ServiceCertificate);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#ifndef WVCDM_CORE_USAGE_TABLE_HEADER_H_
|
#ifndef WVCDM_CORE_USAGE_TABLE_HEADER_H_
|
||||||
#define WVCDM_CORE_USAGE_TABLE_HEADER_H_
|
#define WVCDM_CORE_USAGE_TABLE_HEADER_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -14,7 +15,6 @@
|
|||||||
#include "file_store.h"
|
#include "file_store.h"
|
||||||
#include "lock.h"
|
#include "lock.h"
|
||||||
#include "metrics_collections.h"
|
#include "metrics_collections.h"
|
||||||
#include "scoped_ptr.h"
|
|
||||||
#include "wv_cdm_types.h"
|
#include "wv_cdm_types.h"
|
||||||
|
|
||||||
namespace wvcdm {
|
namespace wvcdm {
|
||||||
@@ -100,8 +100,8 @@ class UsageTableHeader {
|
|||||||
// This handle and file system is only to be used when accessing
|
// This handle and file system is only to be used when accessing
|
||||||
// usage_table_header. Usage entries should use the file system provided
|
// usage_table_header. Usage entries should use the file system provided
|
||||||
// by CdmSession.
|
// by CdmSession.
|
||||||
scoped_ptr<DeviceFiles> file_handle_;
|
std::unique_ptr<DeviceFiles> file_handle_;
|
||||||
scoped_ptr<FileSystem> file_system_;
|
std::unique_ptr<FileSystem> file_system_;
|
||||||
CdmSecurityLevel security_level_;
|
CdmSecurityLevel security_level_;
|
||||||
SecurityLevel requested_security_level_;
|
SecurityLevel requested_security_level_;
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ class UsageTableHeader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Test related data members
|
// Test related data members
|
||||||
scoped_ptr<CryptoSession> test_crypto_session_;
|
std::unique_ptr<CryptoSession> test_crypto_session_;
|
||||||
|
|
||||||
CORE_DISALLOW_COPY_AND_ASSIGN(UsageTableHeader);
|
CORE_DISALLOW_COPY_AND_ASSIGN(UsageTableHeader);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -60,11 +60,12 @@ class UsagePropertySet : public CdmClientPropertySet {
|
|||||||
bool CdmEngine::seeded_ = false;
|
bool CdmEngine::seeded_ = false;
|
||||||
|
|
||||||
CdmEngine::CdmEngine(FileSystem* file_system, const std::string& spoid)
|
CdmEngine::CdmEngine(FileSystem* file_system, const std::string& spoid)
|
||||||
: cert_provisioning_(NULL),
|
: cert_provisioning_(),
|
||||||
cert_provisioning_requested_security_level_(kLevelDefault),
|
cert_provisioning_requested_security_level_(kLevelDefault),
|
||||||
file_system_(file_system),
|
file_system_(file_system),
|
||||||
spoid_(spoid),
|
spoid_(spoid),
|
||||||
usage_session_(NULL),
|
usage_session_(),
|
||||||
|
usage_property_set_(),
|
||||||
last_usage_information_update_time_(0) {
|
last_usage_information_update_time_(0) {
|
||||||
assert(file_system);
|
assert(file_system);
|
||||||
if (!seeded_) {
|
if (!seeded_) {
|
||||||
@@ -126,7 +127,7 @@ CdmResponseType CdmEngine::OpenSession(
|
|||||||
|
|
||||||
CloseExpiredReleaseSessions();
|
CloseExpiredReleaseSessions();
|
||||||
|
|
||||||
scoped_ptr<CdmSession> new_session(new CdmSession(file_system_,
|
std::unique_ptr<CdmSession> new_session(new CdmSession(file_system_,
|
||||||
metrics_.AddSession()));
|
metrics_.AddSession()));
|
||||||
CdmResponseType sts = new_session->Init(property_set, forced_session_id,
|
CdmResponseType sts = new_session->Init(property_set, forced_session_id,
|
||||||
event_listener);
|
event_listener);
|
||||||
@@ -491,7 +492,7 @@ CdmResponseType CdmEngine::QueryStatus(SecurityLevel security_level,
|
|||||||
const std::string& query_token,
|
const std::string& query_token,
|
||||||
std::string* query_response) {
|
std::string* query_response) {
|
||||||
LOGI("CdmEngine::QueryStatus");
|
LOGI("CdmEngine::QueryStatus");
|
||||||
scoped_ptr<CryptoSession> crypto_session(
|
std::unique_ptr<CryptoSession> crypto_session(
|
||||||
CryptoSession::MakeCryptoSession(metrics_.GetCryptoMetrics()));
|
CryptoSession::MakeCryptoSession(metrics_.GetCryptoMetrics()));
|
||||||
CdmResponseType status;
|
CdmResponseType status;
|
||||||
M_TIME(
|
M_TIME(
|
||||||
@@ -833,7 +834,7 @@ CdmResponseType CdmEngine::HandleProvisioningResponse(
|
|||||||
if (NULL == cert_provisioning_.get()) {
|
if (NULL == cert_provisioning_.get()) {
|
||||||
// Certificate provisioning object has been released. Check if a concurrent
|
// Certificate provisioning object has been released. Check if a concurrent
|
||||||
// provisioning attempt has succeeded before declaring failure.
|
// provisioning attempt has succeeded before declaring failure.
|
||||||
scoped_ptr<CryptoSession> crypto_session(
|
std::unique_ptr<CryptoSession> crypto_session(
|
||||||
CryptoSession::MakeCryptoSession(metrics_.GetCryptoMetrics()));
|
CryptoSession::MakeCryptoSession(metrics_.GetCryptoMetrics()));
|
||||||
CdmResponseType status;
|
CdmResponseType status;
|
||||||
M_TIME(
|
M_TIME(
|
||||||
@@ -889,7 +890,7 @@ bool CdmEngine::IsProvisioned(CdmSecurityLevel security_level) {
|
|||||||
CdmResponseType CdmEngine::Unprovision(CdmSecurityLevel security_level) {
|
CdmResponseType CdmEngine::Unprovision(CdmSecurityLevel security_level) {
|
||||||
// Devices with baked-in DRM certs cannot be reprovisioned and therefore must
|
// Devices with baked-in DRM certs cannot be reprovisioned and therefore must
|
||||||
// not be unprovisioned.
|
// not be unprovisioned.
|
||||||
scoped_ptr<CryptoSession> crypto_session(
|
std::unique_ptr<CryptoSession> crypto_session(
|
||||||
CryptoSession::MakeCryptoSession(metrics_.GetCryptoMetrics()));
|
CryptoSession::MakeCryptoSession(metrics_.GetCryptoMetrics()));
|
||||||
CdmClientTokenType token_type = kClientTokenUninitialized;
|
CdmClientTokenType token_type = kClientTokenUninitialized;
|
||||||
CdmResponseType res = crypto_session->GetProvisioningMethod(
|
CdmResponseType res = crypto_session->GetProvisioningMethod(
|
||||||
@@ -923,7 +924,7 @@ CdmResponseType CdmEngine::Unprovision(CdmSecurityLevel security_level) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CdmResponseType CdmEngine::DeleteUsageTable(CdmSecurityLevel security_level) {
|
CdmResponseType CdmEngine::DeleteUsageTable(CdmSecurityLevel security_level) {
|
||||||
scoped_ptr<CryptoSession> crypto_session(
|
std::unique_ptr<CryptoSession> crypto_session(
|
||||||
CryptoSession::MakeCryptoSession(metrics_.GetCryptoMetrics()));
|
CryptoSession::MakeCryptoSession(metrics_.GetCryptoMetrics()));
|
||||||
CdmResponseType status;
|
CdmResponseType status;
|
||||||
M_TIME(
|
M_TIME(
|
||||||
@@ -1006,7 +1007,7 @@ CdmResponseType CdmEngine::DeleteUsageRecord(const std::string& app_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Got provider token. Remove from OEMCrypto.
|
// Got provider token. Remove from OEMCrypto.
|
||||||
scoped_ptr<CryptoSession> crypto_session(
|
std::unique_ptr<CryptoSession> crypto_session(
|
||||||
CryptoSession::MakeCryptoSession(metrics_.GetCryptoMetrics()));
|
CryptoSession::MakeCryptoSession(metrics_.GetCryptoMetrics()));
|
||||||
CdmResponseType status = crypto_session->Open(
|
CdmResponseType status = crypto_session->Open(
|
||||||
security_level == kSecurityLevelL3 ? kLevel3 : kLevelDefault);
|
security_level == kSecurityLevelL3 ? kLevel3 : kLevelDefault);
|
||||||
@@ -1215,7 +1216,7 @@ CdmResponseType CdmEngine::RemoveAllUsageInfo(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Got at least one provider token. Remove from OEMCrypto.
|
// Got at least one provider token. Remove from OEMCrypto.
|
||||||
scoped_ptr<CryptoSession> crypto_session(
|
std::unique_ptr<CryptoSession> crypto_session(
|
||||||
CryptoSession::MakeCryptoSession(metrics_.GetCryptoMetrics()));
|
CryptoSession::MakeCryptoSession(metrics_.GetCryptoMetrics()));
|
||||||
CdmResponseType status = crypto_session->Open(
|
CdmResponseType status = crypto_session->Open(
|
||||||
security_level == kSecurityLevelL3 ? kLevel3 : kLevelDefault);
|
security_level == kSecurityLevelL3 ? kLevel3 : kLevelDefault);
|
||||||
@@ -1369,7 +1370,7 @@ CdmResponseType CdmEngine::RemoveUsageInfo(
|
|||||||
handle.DeleteUsageInfo(
|
handle.DeleteUsageInfo(
|
||||||
DeviceFiles::GetUsageInfoFileName(app_id),
|
DeviceFiles::GetUsageInfoFileName(app_id),
|
||||||
provider_session_token);
|
provider_session_token);
|
||||||
scoped_ptr<CryptoSession> crypto_session(
|
std::unique_ptr<CryptoSession> crypto_session(
|
||||||
CryptoSession::MakeCryptoSession(metrics_.GetCryptoMetrics()));
|
CryptoSession::MakeCryptoSession(metrics_.GetCryptoMetrics()));
|
||||||
status = crypto_session->Open(
|
status = crypto_session->Open(
|
||||||
static_cast<CdmSecurityLevel>(j) == kSecurityLevelL3
|
static_cast<CdmSecurityLevel>(j) == kSecurityLevelL3
|
||||||
@@ -1807,7 +1808,7 @@ void CdmEngine::DeleteAllUsageReportsUponFactoryReset() {
|
|||||||
|
|
||||||
if (!file_system_->Exists(device_base_path_level1) &&
|
if (!file_system_->Exists(device_base_path_level1) &&
|
||||||
!file_system_->Exists(device_base_path_level3)) {
|
!file_system_->Exists(device_base_path_level3)) {
|
||||||
scoped_ptr<CryptoSession> crypto_session(
|
std::unique_ptr<CryptoSession> crypto_session(
|
||||||
CryptoSession::MakeCryptoSession(metrics_.GetCryptoMetrics()));
|
CryptoSession::MakeCryptoSession(metrics_.GetCryptoMetrics()));
|
||||||
CdmResponseType status;
|
CdmResponseType status;
|
||||||
M_TIME(
|
M_TIME(
|
||||||
|
|||||||
@@ -2577,7 +2577,8 @@ void CryptoSession::IncrementIV(uint64_t increase_by,
|
|||||||
|
|
||||||
// The factory will either be set by WvCdmTestBase, or a default factory is
|
// The factory will either be set by WvCdmTestBase, or a default factory is
|
||||||
// created on the first call to MakeCryptoSession.
|
// created on the first call to MakeCryptoSession.
|
||||||
scoped_ptr<CryptoSessionFactory> CryptoSession::factory_(NULL);
|
std::unique_ptr<CryptoSessionFactory> CryptoSession::factory_ =
|
||||||
|
std::unique_ptr<CryptoSessionFactory>();
|
||||||
|
|
||||||
CryptoSession* CryptoSession::MakeCryptoSession(
|
CryptoSession* CryptoSession::MakeCryptoSession(
|
||||||
metrics::CryptoMetrics* crypto_metrics) {
|
metrics::CryptoMetrics* crypto_metrics) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "file_store.h"
|
#include "file_store.h"
|
||||||
@@ -28,7 +29,6 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "metrics_collections.h"
|
#include "metrics_collections.h"
|
||||||
#include "properties.h"
|
#include "properties.h"
|
||||||
#include "scoped_ptr.h"
|
|
||||||
#include "wv_cdm_constants.h"
|
#include "wv_cdm_constants.h"
|
||||||
|
|
||||||
using namespace wvoec3;
|
using namespace wvoec3;
|
||||||
@@ -938,7 +938,7 @@ class Adapter {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static wvcdm::scoped_ptr<Adapter> gAdapter;
|
static std::unique_ptr<Adapter> gAdapter;
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace wvcdm {
|
namespace wvcdm {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ bool Properties::oem_crypto_use_fifo_;
|
|||||||
bool Properties::oem_crypto_use_userspace_buffers_;
|
bool Properties::oem_crypto_use_userspace_buffers_;
|
||||||
bool Properties::provisioning_messages_are_binary_;
|
bool Properties::provisioning_messages_are_binary_;
|
||||||
bool Properties::allow_service_certificate_requests_;
|
bool Properties::allow_service_certificate_requests_;
|
||||||
scoped_ptr<CdmClientPropertySetMap> Properties::session_property_set_;
|
std::unique_ptr<CdmClientPropertySetMap> Properties::session_property_set_;
|
||||||
|
|
||||||
bool Properties::AddSessionPropertySet(
|
bool Properties::AddSessionPropertySet(
|
||||||
const CdmSessionId& session_id, CdmClientPropertySet* property_set) {
|
const CdmSessionId& session_id, CdmClientPropertySet* property_set) {
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ CdmResponseType UsageTableHeader::MoveEntry(
|
|||||||
|
|
||||||
// crypto_session points to an object whose scope is this method or a test
|
// crypto_session points to an object whose scope is this method or a test
|
||||||
// object whose scope is the lifetime of this class
|
// object whose scope is the lifetime of this class
|
||||||
scoped_ptr<CryptoSession> scoped_crypto_session;
|
std::unique_ptr<CryptoSession> scoped_crypto_session;
|
||||||
CryptoSession* crypto_session = test_crypto_session_.get();
|
CryptoSession* crypto_session = test_crypto_session_.get();
|
||||||
if (crypto_session == NULL) {
|
if (crypto_session == NULL) {
|
||||||
scoped_crypto_session.reset((CryptoSession::MakeCryptoSession(metrics)));
|
scoped_crypto_session.reset((CryptoSession::MakeCryptoSession(metrics)));
|
||||||
@@ -476,7 +476,7 @@ CdmResponseType UsageTableHeader::Shrink(
|
|||||||
|
|
||||||
// crypto_session points to an object whose scope is this method or a test
|
// crypto_session points to an object whose scope is this method or a test
|
||||||
// object whose scope is the lifetime of this class
|
// object whose scope is the lifetime of this class
|
||||||
scoped_ptr<CryptoSession> scoped_crypto_session;
|
std::unique_ptr<CryptoSession> scoped_crypto_session;
|
||||||
CryptoSession* crypto_session = test_crypto_session_.get();
|
CryptoSession* crypto_session = test_crypto_session_.get();
|
||||||
if (crypto_session == NULL) {
|
if (crypto_session == NULL) {
|
||||||
scoped_crypto_session.reset((CryptoSession::MakeCryptoSession(metrics)));
|
scoped_crypto_session.reset((CryptoSession::MakeCryptoSession(metrics)));
|
||||||
@@ -549,7 +549,7 @@ bool UsageTableHeader::UpgradeLicensesFromUsageTable(
|
|||||||
|
|
||||||
if (provider_session_token.empty()) continue;
|
if (provider_session_token.empty()) continue;
|
||||||
|
|
||||||
scoped_ptr<CryptoSession> crypto_session(
|
std::unique_ptr<CryptoSession> crypto_session(
|
||||||
CryptoSession::MakeCryptoSession(metrics));
|
CryptoSession::MakeCryptoSession(metrics));
|
||||||
CdmResponseType status = crypto_session->Open(requested_security_level_);
|
CdmResponseType status = crypto_session->Open(requested_security_level_);
|
||||||
|
|
||||||
@@ -632,7 +632,7 @@ bool UsageTableHeader::UpgradeUsageInfoFromUsageTable(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
scoped_ptr<CryptoSession> crypto_session(
|
std::unique_ptr<CryptoSession> crypto_session(
|
||||||
CryptoSession::MakeCryptoSession(metrics));
|
CryptoSession::MakeCryptoSession(metrics));
|
||||||
CdmResponseType status = crypto_session->Open(requested_security_level_);
|
CdmResponseType status = crypto_session->Open(requested_security_level_);
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
#include "metrics.pb.h"
|
#include "metrics.pb.h"
|
||||||
#include "OEMCryptoCENC.h"
|
#include "OEMCryptoCENC.h"
|
||||||
#include "properties.h"
|
#include "properties.h"
|
||||||
#include "scoped_ptr.h"
|
|
||||||
#include "string_conversions.h"
|
#include "string_conversions.h"
|
||||||
#include "test_base.h"
|
#include "test_base.h"
|
||||||
#include "test_printers.h"
|
#include "test_printers.h"
|
||||||
|
|||||||
@@ -2,13 +2,15 @@
|
|||||||
// source code may only be used and distributed under the Widevine Master
|
// source code may only be used and distributed under the Widevine Master
|
||||||
// License Agreement.
|
// License Agreement.
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "cdm_session.h"
|
#include "cdm_session.h"
|
||||||
#include "crypto_key.h"
|
#include "crypto_key.h"
|
||||||
#include "metrics.pb.h"
|
#include "metrics.pb.h"
|
||||||
#include "properties.h"
|
#include "properties.h"
|
||||||
#include "scoped_ptr.h"
|
|
||||||
#include "service_certificate.h"
|
#include "service_certificate.h"
|
||||||
#include "string_conversions.h"
|
#include "string_conversions.h"
|
||||||
#include "test_base.h"
|
#include "test_base.h"
|
||||||
@@ -191,7 +193,7 @@ class CdmSessionTest : public WvCdmTestBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
metrics::SessionMetrics metrics_;
|
metrics::SessionMetrics metrics_;
|
||||||
scoped_ptr<CdmSession> cdm_session_;
|
std::unique_ptr<CdmSession> cdm_session_;
|
||||||
MockCdmLicense* license_parser_;
|
MockCdmLicense* license_parser_;
|
||||||
metrics::CryptoMetrics crypto_metrics_;
|
metrics::CryptoMetrics crypto_metrics_;
|
||||||
NiceMock<MockCryptoSession>* crypto_session_;
|
NiceMock<MockCryptoSession>* crypto_session_;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
// License Agreement.
|
// License Agreement.
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
@@ -14,7 +15,6 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "metrics.pb.h"
|
#include "metrics.pb.h"
|
||||||
#include "metrics_collections.h"
|
#include "metrics_collections.h"
|
||||||
#include "scoped_ptr.h"
|
|
||||||
#include "test_base.h"
|
#include "test_base.h"
|
||||||
#include "test_printers.h"
|
#include "test_printers.h"
|
||||||
#include "wv_cdm_types.h"
|
#include "wv_cdm_types.h"
|
||||||
@@ -282,7 +282,7 @@ class CryptoSessionMetricsTest : public WvCdmTestBase {
|
|||||||
|
|
||||||
TEST_F(CryptoSessionMetricsTest, OpenSessionValidMetrics) {
|
TEST_F(CryptoSessionMetricsTest, OpenSessionValidMetrics) {
|
||||||
metrics::CryptoMetrics crypto_metrics;
|
metrics::CryptoMetrics crypto_metrics;
|
||||||
scoped_ptr<CryptoSession> session(
|
std::unique_ptr<CryptoSession> session(
|
||||||
CryptoSession::MakeCryptoSession(&crypto_metrics));
|
CryptoSession::MakeCryptoSession(&crypto_metrics));
|
||||||
session->Open(wvcdm::kLevelDefault);
|
session->Open(wvcdm::kLevelDefault);
|
||||||
// Exercise a method that will touch a metric.
|
// Exercise a method that will touch a metric.
|
||||||
@@ -340,7 +340,7 @@ TEST_F(CryptoSessionMetricsTest, OpenSessionValidMetrics) {
|
|||||||
|
|
||||||
TEST_F(CryptoSessionMetricsTest, GetProvisioningTokenValidMetrics) {
|
TEST_F(CryptoSessionMetricsTest, GetProvisioningTokenValidMetrics) {
|
||||||
metrics::CryptoMetrics crypto_metrics;
|
metrics::CryptoMetrics crypto_metrics;
|
||||||
scoped_ptr<CryptoSession> session(
|
std::unique_ptr<CryptoSession> session(
|
||||||
CryptoSession::MakeCryptoSession(&crypto_metrics));
|
CryptoSession::MakeCryptoSession(&crypto_metrics));
|
||||||
|
|
||||||
ASSERT_EQ(NO_ERROR, session->Open(wvcdm::kLevelDefault));
|
ASSERT_EQ(NO_ERROR, session->Open(wvcdm::kLevelDefault));
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
#include "oemcrypto_session_tests_helper.h"
|
#include "oemcrypto_session_tests_helper.h"
|
||||||
#include "oemcrypto_types.h"
|
#include "oemcrypto_types.h"
|
||||||
#include "properties.h"
|
#include "properties.h"
|
||||||
#include "scoped_ptr.h"
|
|
||||||
#include "string_conversions.h"
|
#include "string_conversions.h"
|
||||||
#include "test_base.h"
|
#include "test_base.h"
|
||||||
#include "test_printers.h"
|
#include "test_printers.h"
|
||||||
|
|||||||
@@ -3,10 +3,12 @@
|
|||||||
// License Agreement.
|
// License Agreement.
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "http_socket.h"
|
#include "http_socket.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "scoped_ptr.h"
|
|
||||||
#include "string_conversions.h"
|
#include "string_conversions.h"
|
||||||
#include "url_request.h"
|
#include "url_request.h"
|
||||||
|
|
||||||
@@ -90,7 +92,7 @@ class HttpSocketTest : public testing::Test {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
scoped_ptr<HttpSocket> socket_;
|
std::unique_ptr<HttpSocket> socket_;
|
||||||
std::string domain_name_;
|
std::string domain_name_;
|
||||||
std::string resource_path_;
|
std::string resource_path_;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
// source code may only be used and distributed under the Widevine Master
|
// source code may only be used and distributed under the Widevine Master
|
||||||
// License Agreement.
|
// License Agreement.
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
@@ -10,7 +12,6 @@
|
|||||||
#include "metrics_collections.h"
|
#include "metrics_collections.h"
|
||||||
#include "policy_engine.h"
|
#include "policy_engine.h"
|
||||||
#include "mock_clock.h"
|
#include "mock_clock.h"
|
||||||
#include "scoped_ptr.h"
|
|
||||||
#include "test_base.h"
|
#include "test_base.h"
|
||||||
#include "test_printers.h"
|
#include "test_printers.h"
|
||||||
#include "wv_cdm_event_listener.h"
|
#include "wv_cdm_event_listener.h"
|
||||||
@@ -215,7 +216,7 @@ class PolicyEngineConstraintsTest : public WvCdmTestBase {
|
|||||||
expected_has_new_usable_key));
|
expected_has_new_usable_key));
|
||||||
}
|
}
|
||||||
|
|
||||||
scoped_ptr<PolicyEngine> policy_engine_;
|
std::unique_ptr<PolicyEngine> policy_engine_;
|
||||||
MockClock* mock_clock_;
|
MockClock* mock_clock_;
|
||||||
int64_t current_time_;
|
int64_t current_time_;
|
||||||
metrics::CryptoMetrics dummy_metrics_;
|
metrics::CryptoMetrics dummy_metrics_;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <memory>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
@@ -13,7 +14,6 @@
|
|||||||
#include "license.h"
|
#include "license.h"
|
||||||
#include "mock_clock.h"
|
#include "mock_clock.h"
|
||||||
#include "policy_engine.h"
|
#include "policy_engine.h"
|
||||||
#include "scoped_ptr.h"
|
|
||||||
#include "test_base.h"
|
#include "test_base.h"
|
||||||
#include "test_printers.h"
|
#include "test_printers.h"
|
||||||
#include "wv_cdm_event_listener.h"
|
#include "wv_cdm_event_listener.h"
|
||||||
@@ -185,7 +185,7 @@ class PolicyEngineTest : public WvCdmTestBase {
|
|||||||
NiceMock<HdcpOnlyMockCryptoSession> crypto_session_;
|
NiceMock<HdcpOnlyMockCryptoSession> crypto_session_;
|
||||||
StrictMock<MockCdmEventListener> mock_event_listener_;
|
StrictMock<MockCdmEventListener> mock_event_listener_;
|
||||||
MockClock* mock_clock_;
|
MockClock* mock_clock_;
|
||||||
scoped_ptr<PolicyEngine> policy_engine_;
|
std::unique_ptr<PolicyEngine> policy_engine_;
|
||||||
License license_;
|
License license_;
|
||||||
MockFunction<void(int i)> check_;
|
MockFunction<void(int i)> check_;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "scoped_ptr.h"
|
|
||||||
#include "string_conversions.h"
|
#include "string_conversions.h"
|
||||||
|
|
||||||
using drm_metrics::TestMetrics;
|
using drm_metrics::TestMetrics;
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "scoped_ptr.h"
|
|
||||||
#include "string_conversions.h"
|
#include "string_conversions.h"
|
||||||
|
|
||||||
using drm_metrics::TestMetrics;
|
using drm_metrics::TestMetrics;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
//
|
//
|
||||||
// Unit tests for ValueMetric.
|
// Unit tests for ValueMetric.
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "value_metric.h"
|
#include "value_metric.h"
|
||||||
@@ -9,7 +10,6 @@
|
|||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "metrics.pb.h"
|
#include "metrics.pb.h"
|
||||||
#include "scoped_ptr.h"
|
|
||||||
|
|
||||||
namespace wvcdm {
|
namespace wvcdm {
|
||||||
namespace metrics {
|
namespace metrics {
|
||||||
@@ -18,7 +18,7 @@ TEST(ValueMetricTest, StringValue) {
|
|||||||
ValueMetric<std::string> metric;
|
ValueMetric<std::string> metric;
|
||||||
metric.Record("foo");
|
metric.Record("foo");
|
||||||
|
|
||||||
wvcdm::scoped_ptr<drm_metrics::ValueMetric> metric_proto(metric.ToProto());
|
std::unique_ptr<drm_metrics::ValueMetric> metric_proto(metric.ToProto());
|
||||||
ASSERT_EQ("foo", metric_proto->string_value());
|
ASSERT_EQ("foo", metric_proto->string_value());
|
||||||
ASSERT_FALSE(metric_proto->has_error_code());
|
ASSERT_FALSE(metric_proto->has_error_code());
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ TEST(ValueMetricTest, DoubleValue) {
|
|||||||
ValueMetric<double> metric;
|
ValueMetric<double> metric;
|
||||||
metric.Record(42.0);
|
metric.Record(42.0);
|
||||||
|
|
||||||
wvcdm::scoped_ptr<drm_metrics::ValueMetric> metric_proto(metric.ToProto());
|
std::unique_ptr<drm_metrics::ValueMetric> metric_proto(metric.ToProto());
|
||||||
ASSERT_EQ(42.0, metric_proto->double_value());
|
ASSERT_EQ(42.0, metric_proto->double_value());
|
||||||
ASSERT_FALSE(metric_proto->has_error_code());
|
ASSERT_FALSE(metric_proto->has_error_code());
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ TEST(ValueMetricTest, Int32Value) {
|
|||||||
ValueMetric<int32_t> metric;
|
ValueMetric<int32_t> metric;
|
||||||
metric.Record(42);
|
metric.Record(42);
|
||||||
|
|
||||||
wvcdm::scoped_ptr<drm_metrics::ValueMetric> metric_proto(metric.ToProto());
|
std::unique_ptr<drm_metrics::ValueMetric> metric_proto(metric.ToProto());
|
||||||
ASSERT_EQ(42, metric_proto->int_value());
|
ASSERT_EQ(42, metric_proto->int_value());
|
||||||
ASSERT_FALSE(metric_proto->has_error_code());
|
ASSERT_FALSE(metric_proto->has_error_code());
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ TEST(ValueMetricTest, Int64Value) {
|
|||||||
ValueMetric<int64_t> metric;
|
ValueMetric<int64_t> metric;
|
||||||
metric.Record(42);
|
metric.Record(42);
|
||||||
|
|
||||||
wvcdm::scoped_ptr<drm_metrics::ValueMetric> metric_proto(metric.ToProto());
|
std::unique_ptr<drm_metrics::ValueMetric> metric_proto(metric.ToProto());
|
||||||
ASSERT_EQ(42, metric_proto->int_value());
|
ASSERT_EQ(42, metric_proto->int_value());
|
||||||
ASSERT_FALSE(metric_proto->has_error_code());
|
ASSERT_FALSE(metric_proto->has_error_code());
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,7 @@ TEST(ValueMetricTest, SetError) {
|
|||||||
metric.Record(42);
|
metric.Record(42);
|
||||||
metric.SetError(7);
|
metric.SetError(7);
|
||||||
|
|
||||||
wvcdm::scoped_ptr<drm_metrics::ValueMetric> metric_proto(metric.ToProto());
|
std::unique_ptr<drm_metrics::ValueMetric> metric_proto(metric.ToProto());
|
||||||
ASSERT_EQ(7, metric_proto->error_code());
|
ASSERT_EQ(7, metric_proto->error_code());
|
||||||
ASSERT_FALSE(metric_proto->has_int_value());
|
ASSERT_FALSE(metric_proto->has_int_value());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#define OEMCRYPTO_AUTH_REF_H_
|
#define OEMCRYPTO_AUTH_REF_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <openssl/rsa.h>
|
#include <openssl/rsa.h>
|
||||||
@@ -17,7 +18,6 @@
|
|||||||
#include "oemcrypto_key_ref.h"
|
#include "oemcrypto_key_ref.h"
|
||||||
#include "oemcrypto_keybox_ref.h"
|
#include "oemcrypto_keybox_ref.h"
|
||||||
#include "oemcrypto_rsa_key_shared.h"
|
#include "oemcrypto_rsa_key_shared.h"
|
||||||
#include "oemcrypto_scoped_ptr.h"
|
|
||||||
#include "oemcrypto_types.h"
|
#include "oemcrypto_types.h"
|
||||||
|
|
||||||
namespace wvoec_ref {
|
namespace wvoec_ref {
|
||||||
|
|||||||
@@ -7,11 +7,13 @@
|
|||||||
|
|
||||||
#include "oemcrypto_engine_ref.h"
|
#include "oemcrypto_engine_ref.h"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace wvoec_ref {
|
namespace wvoec_ref {
|
||||||
|
|
||||||
CryptoEngine* CryptoEngine::MakeCryptoEngine(
|
CryptoEngine* CryptoEngine::MakeCryptoEngine(
|
||||||
scoped_ptr<wvcdm::FileSystem> file_system) {
|
std::unique_ptr<wvcdm::FileSystem>&& file_system) {
|
||||||
return new CryptoEngine(file_system);
|
return new CryptoEngine(std::move(file_system));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace wvoec_ref
|
} // namespace wvoec_ref
|
||||||
|
|||||||
@@ -8,12 +8,14 @@
|
|||||||
// level 1 device.
|
// level 1 device.
|
||||||
#include "oemcrypto_engine_ref.h"
|
#include "oemcrypto_engine_ref.h"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace wvoec_ref {
|
namespace wvoec_ref {
|
||||||
|
|
||||||
class L1CryptoEngine : public CryptoEngine {
|
class L1CryptoEngine : public CryptoEngine {
|
||||||
public:
|
public:
|
||||||
explicit L1CryptoEngine(scoped_ptr<wvcdm::FileSystem> file_system)
|
explicit L1CryptoEngine(std::unique_ptr<wvcdm::FileSystem>&& file_system)
|
||||||
: CryptoEngine(file_system) {}
|
: CryptoEngine(std::move(file_system)) {}
|
||||||
|
|
||||||
bool config_local_display_only() { return true; }
|
bool config_local_display_only() { return true; }
|
||||||
|
|
||||||
@@ -31,8 +33,8 @@ class L1CryptoEngine : public CryptoEngine {
|
|||||||
};
|
};
|
||||||
|
|
||||||
CryptoEngine* CryptoEngine::MakeCryptoEngine(
|
CryptoEngine* CryptoEngine::MakeCryptoEngine(
|
||||||
scoped_ptr<wvcdm::FileSystem> file_system) {
|
std::unique_ptr<wvcdm::FileSystem>&& file_system) {
|
||||||
return new L1CryptoEngine(file_system);
|
return new L1CryptoEngine(std::move(file_system));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace wvoec_ref
|
} // namespace wvoec_ref
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace wvoec_ref {
|
|||||||
|
|
||||||
class CertOnlyCryptoEngine : public CryptoEngine {
|
class CertOnlyCryptoEngine : public CryptoEngine {
|
||||||
public:
|
public:
|
||||||
explicit CertOnlyCryptoEngine(scoped_ptr<wvcdm::FileSystem> file_system)
|
explicit CertOnlyCryptoEngine(std::unique_ptr<wvcdm::FileSystem> file_system)
|
||||||
: CryptoEngine(file_system) {}
|
: CryptoEngine(file_system) {}
|
||||||
|
|
||||||
bool config_local_display_only() { return true; }
|
bool config_local_display_only() { return true; }
|
||||||
@@ -30,7 +30,7 @@ class CertOnlyCryptoEngine : public CryptoEngine {
|
|||||||
};
|
};
|
||||||
|
|
||||||
CryptoEngine* CryptoEngine::MakeCryptoEngine(
|
CryptoEngine* CryptoEngine::MakeCryptoEngine(
|
||||||
scoped_ptr<wvcdm::FileSystem> file_system) {
|
std::unique_ptr<wvcdm::FileSystem> file_system) {
|
||||||
return new CertOnlyCryptoEngine(file_system);
|
return new CertOnlyCryptoEngine(file_system);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "oem_cert.h"
|
#include "oem_cert.h"
|
||||||
|
|
||||||
@@ -19,8 +21,8 @@ namespace wvoec_ref {
|
|||||||
|
|
||||||
class Prov30CryptoEngine : public CryptoEngine {
|
class Prov30CryptoEngine : public CryptoEngine {
|
||||||
public:
|
public:
|
||||||
explicit Prov30CryptoEngine(scoped_ptr<wvcdm::FileSystem> file_system)
|
explicit Prov30CryptoEngine(std::unique_ptr<wvcdm::FileSystem>&& file_system)
|
||||||
: CryptoEngine(file_system) {}
|
: CryptoEngine(std::move(file_system)) {}
|
||||||
|
|
||||||
bool config_local_display_only() { return true; }
|
bool config_local_display_only() { return true; }
|
||||||
|
|
||||||
@@ -77,8 +79,8 @@ class Prov30CryptoEngine : public CryptoEngine {
|
|||||||
};
|
};
|
||||||
|
|
||||||
CryptoEngine* CryptoEngine::MakeCryptoEngine(
|
CryptoEngine* CryptoEngine::MakeCryptoEngine(
|
||||||
scoped_ptr<wvcdm::FileSystem> file_system) {
|
std::unique_ptr<wvcdm::FileSystem>&& file_system) {
|
||||||
return new Prov30CryptoEngine(file_system);
|
return new Prov30CryptoEngine(std::move(file_system));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace wvoec_ref
|
} // namespace wvoec_ref
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
@@ -27,10 +28,10 @@ namespace wvoec_ref {
|
|||||||
// all configurations. See the files oemcrypto_engine_device_properties*.cpp
|
// all configurations. See the files oemcrypto_engine_device_properties*.cpp
|
||||||
// for methods that are configured for specific configurations.
|
// for methods that are configured for specific configurations.
|
||||||
|
|
||||||
CryptoEngine::CryptoEngine(scoped_ptr<wvcdm::FileSystem> file_system)
|
CryptoEngine::CryptoEngine(std::unique_ptr<wvcdm::FileSystem>&& file_system)
|
||||||
: root_of_trust_(config_provisioning_method()),
|
: root_of_trust_(config_provisioning_method()),
|
||||||
file_system_(file_system),
|
file_system_(std::move(file_system)),
|
||||||
usage_table_(NULL) {
|
usage_table_() {
|
||||||
ERR_load_crypto_strings();
|
ERR_load_crypto_strings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
#include "oemcrypto_auth_ref.h"
|
#include "oemcrypto_auth_ref.h"
|
||||||
#include "oemcrypto_key_ref.h"
|
#include "oemcrypto_key_ref.h"
|
||||||
#include "oemcrypto_rsa_key_shared.h"
|
#include "oemcrypto_rsa_key_shared.h"
|
||||||
#include "oemcrypto_scoped_ptr.h"
|
|
||||||
#include "oemcrypto_session.h"
|
#include "oemcrypto_session.h"
|
||||||
#include "oemcrypto_usage_table_ref.h"
|
#include "oemcrypto_usage_table_ref.h"
|
||||||
#include "oemcrypto_types.h"
|
#include "oemcrypto_types.h"
|
||||||
@@ -38,7 +37,7 @@ class CryptoEngine {
|
|||||||
// NOTE: The caller must instantiate a FileSystem object - ownership
|
// NOTE: The caller must instantiate a FileSystem object - ownership
|
||||||
// will be transferred to the new CryptoEngine object.
|
// will be transferred to the new CryptoEngine object.
|
||||||
static CryptoEngine* MakeCryptoEngine(
|
static CryptoEngine* MakeCryptoEngine(
|
||||||
scoped_ptr<wvcdm::FileSystem> file_system);
|
std::unique_ptr<wvcdm::FileSystem>&& file_system);
|
||||||
|
|
||||||
virtual ~CryptoEngine();
|
virtual ~CryptoEngine();
|
||||||
|
|
||||||
@@ -189,15 +188,15 @@ class CryptoEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit CryptoEngine(scoped_ptr<wvcdm::FileSystem> file_system);
|
explicit CryptoEngine(std::unique_ptr<wvcdm::FileSystem>&& file_system);
|
||||||
virtual SessionContext* MakeSession(SessionId sid);
|
virtual SessionContext* MakeSession(SessionId sid);
|
||||||
virtual UsageTable* MakeUsageTable();
|
virtual UsageTable* MakeUsageTable();
|
||||||
uint8_t* destination_;
|
uint8_t* destination_;
|
||||||
ActiveSessions sessions_;
|
ActiveSessions sessions_;
|
||||||
AuthenticationRoot root_of_trust_;
|
AuthenticationRoot root_of_trust_;
|
||||||
wvcdm::Lock session_table_lock_;
|
wvcdm::Lock session_table_lock_;
|
||||||
scoped_ptr<wvcdm::FileSystem> file_system_;
|
std::unique_ptr<wvcdm::FileSystem> file_system_;
|
||||||
scoped_ptr<UsageTable> usage_table_;
|
std::unique_ptr<UsageTable> usage_table_;
|
||||||
|
|
||||||
CORE_DISALLOW_COPY_AND_ASSIGN(CryptoEngine);
|
CORE_DISALLOW_COPY_AND_ASSIGN(CryptoEngine);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "file_store.h"
|
#include "file_store.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
@@ -64,8 +65,8 @@ extern "C" OEMCryptoResult OEMCrypto_Initialize(void) {
|
|||||||
}
|
}
|
||||||
// NOTE: This requires a compatible Filesystem implementation.
|
// NOTE: This requires a compatible Filesystem implementation.
|
||||||
// NOTE: Ownership of the FileSystem object is transferred to CryptoEngine
|
// NOTE: Ownership of the FileSystem object is transferred to CryptoEngine
|
||||||
scoped_ptr<wvcdm::FileSystem> fs(new wvcdm::FileSystem());
|
std::unique_ptr<wvcdm::FileSystem> fs(new wvcdm::FileSystem());
|
||||||
crypto_engine = CryptoEngine::MakeCryptoEngine(fs);
|
crypto_engine = CryptoEngine::MakeCryptoEngine(std::move(fs));
|
||||||
|
|
||||||
if (!crypto_engine || !crypto_engine->Initialize()) {
|
if (!crypto_engine || !crypto_engine->Initialize()) {
|
||||||
LOGE("[OEMCrypto_Initialize(): failed]");
|
LOGE("[OEMCrypto_Initialize(): failed]");
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
// 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.
|
|
||||||
#ifndef OEMCRYPTO_SCOPED_PTR_H_
|
|
||||||
#define OEMCRYPTO_SCOPED_PTR_H_
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
|
|
||||||
namespace wvoec_ref {
|
|
||||||
|
|
||||||
// TODO(fredgc, jfore): scoped_ptr may not be the best name for this smart
|
|
||||||
// pointer type. It basically works like auto_ptr which is deprecated.
|
|
||||||
#if __cplusplus < 201103L
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
class scoped_ptr {
|
|
||||||
public:
|
|
||||||
explicit scoped_ptr(T* p = NULL) : ptr_(p) {}
|
|
||||||
T* get() const { return ptr_.get(); }
|
|
||||||
void reset(T* p = NULL) { ptr_.reset(p); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::auto_ptr<T> ptr_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
class scoped_ptr {
|
|
||||||
public:
|
|
||||||
explicit scoped_ptr(T* p = nullptr) : ptr_(p) {}
|
|
||||||
scoped_ptr(scoped_ptr& r) { ptr_ = std::move(r.ptr_); }
|
|
||||||
T& operator*() const { return *ptr_; }
|
|
||||||
T* operator->() const { return ptr_.get(); }
|
|
||||||
T* get() const { return ptr_.get(); }
|
|
||||||
void reset(T* p = NULL) { ptr_.reset(p); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::unique_ptr<T> ptr_;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace wvoec_ref
|
|
||||||
|
|
||||||
#endif // OEMCRYPTO_SCOPED_PTR_H_
|
|
||||||
Reference in New Issue
Block a user