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:
John W. Bruce
2018-11-14 10:49:53 -08:00
parent fb4d53bae6
commit b182a7445e
35 changed files with 100 additions and 208 deletions

View File

@@ -6,6 +6,7 @@
#define WVCDM_CORE_CRYPTO_SESSION_H_
#include <map>
#include <memory>
#include <string>
#include <vector>
@@ -15,7 +16,6 @@
#include "lock.h"
#include "metrics_collections.h"
#include "oemcrypto_adapter.h"
#include "scoped_ptr.h"
#include "timer_metric.h"
#include "wv_cdm_types.h"
@@ -295,7 +295,7 @@ class CryptoSession {
SubLicenseSessionMap sub_license_oec_sessions_;
// Used for sub license sessions.
std::string wrapped_key_;
scoped_ptr<KeySession> key_session_;
std::unique_ptr<KeySession> key_session_;
OEMCryptoBufferType destination_buffer_type_;
bool is_destination_buffer_type_valid_;
@@ -313,7 +313,7 @@ class CryptoSession {
CdmCipherMode cipher_mode_;
uint32_t api_version_;
static scoped_ptr<CryptoSessionFactory> factory_;
static std::unique_ptr<CryptoSessionFactory> factory_;
CORE_DISALLOW_COPY_AND_ASSIGN(CryptoSession);
};