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:
@@ -60,11 +60,12 @@ class UsagePropertySet : public CdmClientPropertySet {
|
||||
bool CdmEngine::seeded_ = false;
|
||||
|
||||
CdmEngine::CdmEngine(FileSystem* file_system, const std::string& spoid)
|
||||
: cert_provisioning_(NULL),
|
||||
: cert_provisioning_(),
|
||||
cert_provisioning_requested_security_level_(kLevelDefault),
|
||||
file_system_(file_system),
|
||||
spoid_(spoid),
|
||||
usage_session_(NULL),
|
||||
usage_session_(),
|
||||
usage_property_set_(),
|
||||
last_usage_information_update_time_(0) {
|
||||
assert(file_system);
|
||||
if (!seeded_) {
|
||||
@@ -126,7 +127,7 @@ CdmResponseType CdmEngine::OpenSession(
|
||||
|
||||
CloseExpiredReleaseSessions();
|
||||
|
||||
scoped_ptr<CdmSession> new_session(new CdmSession(file_system_,
|
||||
std::unique_ptr<CdmSession> new_session(new CdmSession(file_system_,
|
||||
metrics_.AddSession()));
|
||||
CdmResponseType sts = new_session->Init(property_set, forced_session_id,
|
||||
event_listener);
|
||||
@@ -491,7 +492,7 @@ CdmResponseType CdmEngine::QueryStatus(SecurityLevel security_level,
|
||||
const std::string& query_token,
|
||||
std::string* query_response) {
|
||||
LOGI("CdmEngine::QueryStatus");
|
||||
scoped_ptr<CryptoSession> crypto_session(
|
||||
std::unique_ptr<CryptoSession> crypto_session(
|
||||
CryptoSession::MakeCryptoSession(metrics_.GetCryptoMetrics()));
|
||||
CdmResponseType status;
|
||||
M_TIME(
|
||||
@@ -833,7 +834,7 @@ CdmResponseType CdmEngine::HandleProvisioningResponse(
|
||||
if (NULL == cert_provisioning_.get()) {
|
||||
// Certificate provisioning object has been released. Check if a concurrent
|
||||
// provisioning attempt has succeeded before declaring failure.
|
||||
scoped_ptr<CryptoSession> crypto_session(
|
||||
std::unique_ptr<CryptoSession> crypto_session(
|
||||
CryptoSession::MakeCryptoSession(metrics_.GetCryptoMetrics()));
|
||||
CdmResponseType status;
|
||||
M_TIME(
|
||||
@@ -889,7 +890,7 @@ bool CdmEngine::IsProvisioned(CdmSecurityLevel security_level) {
|
||||
CdmResponseType CdmEngine::Unprovision(CdmSecurityLevel security_level) {
|
||||
// Devices with baked-in DRM certs cannot be reprovisioned and therefore must
|
||||
// not be unprovisioned.
|
||||
scoped_ptr<CryptoSession> crypto_session(
|
||||
std::unique_ptr<CryptoSession> crypto_session(
|
||||
CryptoSession::MakeCryptoSession(metrics_.GetCryptoMetrics()));
|
||||
CdmClientTokenType token_type = kClientTokenUninitialized;
|
||||
CdmResponseType res = crypto_session->GetProvisioningMethod(
|
||||
@@ -923,7 +924,7 @@ CdmResponseType CdmEngine::Unprovision(CdmSecurityLevel security_level) {
|
||||
}
|
||||
|
||||
CdmResponseType CdmEngine::DeleteUsageTable(CdmSecurityLevel security_level) {
|
||||
scoped_ptr<CryptoSession> crypto_session(
|
||||
std::unique_ptr<CryptoSession> crypto_session(
|
||||
CryptoSession::MakeCryptoSession(metrics_.GetCryptoMetrics()));
|
||||
CdmResponseType status;
|
||||
M_TIME(
|
||||
@@ -1006,7 +1007,7 @@ CdmResponseType CdmEngine::DeleteUsageRecord(const std::string& app_id,
|
||||
}
|
||||
|
||||
// Got provider token. Remove from OEMCrypto.
|
||||
scoped_ptr<CryptoSession> crypto_session(
|
||||
std::unique_ptr<CryptoSession> crypto_session(
|
||||
CryptoSession::MakeCryptoSession(metrics_.GetCryptoMetrics()));
|
||||
CdmResponseType status = crypto_session->Open(
|
||||
security_level == kSecurityLevelL3 ? kLevel3 : kLevelDefault);
|
||||
@@ -1215,7 +1216,7 @@ CdmResponseType CdmEngine::RemoveAllUsageInfo(
|
||||
}
|
||||
|
||||
// Got at least one provider token. Remove from OEMCrypto.
|
||||
scoped_ptr<CryptoSession> crypto_session(
|
||||
std::unique_ptr<CryptoSession> crypto_session(
|
||||
CryptoSession::MakeCryptoSession(metrics_.GetCryptoMetrics()));
|
||||
CdmResponseType status = crypto_session->Open(
|
||||
security_level == kSecurityLevelL3 ? kLevel3 : kLevelDefault);
|
||||
@@ -1369,7 +1370,7 @@ CdmResponseType CdmEngine::RemoveUsageInfo(
|
||||
handle.DeleteUsageInfo(
|
||||
DeviceFiles::GetUsageInfoFileName(app_id),
|
||||
provider_session_token);
|
||||
scoped_ptr<CryptoSession> crypto_session(
|
||||
std::unique_ptr<CryptoSession> crypto_session(
|
||||
CryptoSession::MakeCryptoSession(metrics_.GetCryptoMetrics()));
|
||||
status = crypto_session->Open(
|
||||
static_cast<CdmSecurityLevel>(j) == kSecurityLevelL3
|
||||
@@ -1807,7 +1808,7 @@ void CdmEngine::DeleteAllUsageReportsUponFactoryReset() {
|
||||
|
||||
if (!file_system_->Exists(device_base_path_level1) &&
|
||||
!file_system_->Exists(device_base_path_level3)) {
|
||||
scoped_ptr<CryptoSession> crypto_session(
|
||||
std::unique_ptr<CryptoSession> crypto_session(
|
||||
CryptoSession::MakeCryptoSession(metrics_.GetCryptoMetrics()));
|
||||
CdmResponseType status;
|
||||
M_TIME(
|
||||
|
||||
Reference in New Issue
Block a user