Google-style override & virtual

(This is a merge of http://go/wvgerrit/66625)

Google C++ Style dictates that methods which override base class or
interface methods should be declared "override" but not "virtual". Since
our codebase has not had access to "override" until now, many of our
classes do not follow this rule. I've updated as many places as I could
find to follow Google C++ Style, which should hopefully help us catch
errors better in the future.

Bug: 111851141
Test: CE CDM Unit Tests
Test: Android Unit Tests
Change-Id: Ic23e2e482e967256da306791532b5fec7b81b2f2
This commit is contained in:
John W. Bruce
2018-12-06 09:01:18 -08:00
parent 5629a646d8
commit b771d93514
19 changed files with 111 additions and 112 deletions

View File

@@ -18,38 +18,38 @@ class ContentKeySession : public KeySession {
: KeySession(metrics),
oec_session_id_(oec_session_id),
cipher_mode_(kCipherModeCtr) {}
virtual ~ContentKeySession() {}
~ContentKeySession() override {}
virtual KeySessionType Type() override { return kDefault; }
KeySessionType Type() override { return kDefault; }
// Generate Derived Keys for ContentKeySession
virtual bool GenerateDerivedKeys(const std::string& message) override;
bool GenerateDerivedKeys(const std::string& message) override;
// Generate Derived Keys (from session key) for ContentKeySession
virtual bool GenerateDerivedKeys(const std::string& message,
const std::string& session_key) override;
bool GenerateDerivedKeys(const std::string& message,
const std::string& session_key) override;
// Load Keys for ContentKeySession
virtual OEMCryptoResult LoadKeys(const std::string& message,
const std::string& signature,
const std::string& mac_key_iv,
const std::string& mac_key,
const std::vector<CryptoKey>& keys,
const std::string& provider_session_token,
CdmCipherMode* cipher_mode,
const std::string& srm_requirement) override;
OEMCryptoResult LoadKeys(const std::string& message,
const std::string& signature,
const std::string& mac_key_iv,
const std::string& mac_key,
const std::vector<CryptoKey>& keys,
const std::string& provider_session_token,
CdmCipherMode* cipher_mode,
const std::string& srm_requirement) override;
virtual OEMCryptoResult LoadEntitledContentKeys(
OEMCryptoResult LoadEntitledContentKeys(
const std::vector<CryptoKey>&) override {
return OEMCrypto_ERROR_INVALID_CONTEXT;
}
// Select Key for ContentKeySession
virtual OEMCryptoResult SelectKey(const std::string& key_id,
CdmCipherMode cipher_mode) override;
OEMCryptoResult SelectKey(const std::string& key_id,
CdmCipherMode cipher_mode) override;
// Decrypt for ContentKeySession
virtual OEMCryptoResult Decrypt(
OEMCryptoResult Decrypt(
const CdmDecryptionParameters& params,
OEMCrypto_DestBufferDesc& buffer_descriptor,
OEMCrypto_CENCEncryptPatternDesc& pattern_descriptor) override;
@@ -60,8 +60,7 @@ class ContentKeySession : public KeySession {
const std::string& mac_key_iv, const std::string& mac_key,
const std::vector<CryptoKey>& keys,
const std::string& provider_session_token, CdmCipherMode* cipher_mode,
const std::string& srm_requirement,
OEMCrypto_LicenseType license_type);
const std::string& srm_requirement, OEMCrypto_LicenseType license_type);
CryptoSessionId oec_session_id_;

View File

@@ -19,23 +19,23 @@ class EntitlementKeySession : public ContentKeySession {
public:
EntitlementKeySession(CryptoSessionId oec_session_id,
metrics::CryptoMetrics* metrics);
virtual ~EntitlementKeySession() {}
~EntitlementKeySession() override {}
KeySessionType Type() { return kEntitlement; }
// Load Keys for ContentKeySession
virtual OEMCryptoResult LoadKeys(const std::string& message,
const std::string& signature,
const std::string& mac_key_iv,
const std::string& mac_key,
const std::vector<CryptoKey>& keys,
const std::string& provider_session_token,
CdmCipherMode* cipher_mode,
const std::string& srm_requirement) override;
virtual OEMCryptoResult LoadEntitledContentKeys(
OEMCryptoResult LoadKeys(const std::string& message,
const std::string& signature,
const std::string& mac_key_iv,
const std::string& mac_key,
const std::vector<CryptoKey>& keys,
const std::string& provider_session_token,
CdmCipherMode* cipher_mode,
const std::string& srm_requirement) override;
OEMCryptoResult LoadEntitledContentKeys(
const std::vector<CryptoKey>& keys) override;
virtual OEMCryptoResult SelectKey(const std::string& key_id,
CdmCipherMode cipher_mode) override;
OEMCryptoResult SelectKey(const std::string& key_id,
CdmCipherMode cipher_mode) override;
private:
// The message is populated with the fields of the provided CryptoKey and the

View File

@@ -34,21 +34,21 @@ namespace wvcdm {
class UsagePropertySet : public CdmClientPropertySet {
public:
UsagePropertySet() {}
virtual ~UsagePropertySet() {}
~UsagePropertySet() override {}
void set_security_level(SecurityLevel security_level) {
if (kLevel3 == security_level)
security_level_ = QUERY_VALUE_SECURITY_LEVEL_L3;
else
security_level_.clear();
}
virtual const std::string& security_level() const { return security_level_; }
virtual bool use_privacy_mode() const { return false; }
virtual const std::string& service_certificate() const { return empty_; }
virtual void set_service_certificate(const std::string&) {}
virtual bool is_session_sharing_enabled() const { return false; }
virtual uint32_t session_sharing_id() const { return 0; }
virtual void set_session_sharing_id(uint32_t /* id */) {}
virtual const std::string& app_id() const { return app_id_; }
const std::string& security_level() const override { return security_level_; }
bool use_privacy_mode() const override { return false; }
const std::string& service_certificate() const override { return empty_; }
void set_service_certificate(const std::string&) override {}
bool is_session_sharing_enabled() const override { return false; }
uint32_t session_sharing_id() const override { return 0; }
void set_session_sharing_id(uint32_t /* id */) override {}
const std::string& app_id() const override { return app_id_; }
void set_app_id(const std::string& appId) { app_id_ = appId; }
private:

View File

@@ -48,9 +48,9 @@ class WvCdmEnginePreProvTest : public WvCdmTestBase {
WvCdmEnginePreProvTest()
: cdm_engine_(&file_system_), session_opened_(false) {}
virtual ~WvCdmEnginePreProvTest() {}
~WvCdmEnginePreProvTest() override {}
virtual void SetUp() {
void SetUp() override {
WvCdmTestBase::SetUp();
session_opened_ = false;
}
@@ -69,7 +69,7 @@ class WvCdmEnginePreProvTest : public WvCdmTestBase {
session_opened_ = true;
}
virtual void TearDown() {
void TearDown() override {
if (cdm_engine_.IsProvisioned(kSecurityLevelL1)) {
cdm_engine_.Unprovision(kSecurityLevelL1);
}
@@ -150,7 +150,7 @@ class WvCdmEngineTest : public WvCdmEnginePreProvTest {
public:
WvCdmEngineTest() {}
virtual void SetUp() {
void SetUp() override {
WvCdmTestBase::SetUp();
session_opened_ = false;
WvCdmEnginePreProvTest::OpenSession();

View File

@@ -172,7 +172,7 @@ class MockCdmLicense : public CdmLicense {
class CdmSessionTest : public WvCdmTestBase {
protected:
virtual void SetUp() {
void SetUp() override {
WvCdmTestBase::SetUp();
cdm_session_.reset(new CdmSession(NULL, &metrics_));
// Inject testing mocks.
@@ -186,7 +186,7 @@ class CdmSessionTest : public WvCdmTestBase {
cdm_session_->set_file_handle(file_handle_);
}
virtual void TearDown() {
void TearDown() override {
// Force the cdm_session_ to be deleted. This enforces a requirement that
// the CDM session metrics exist at least as long as the CDM session.
cdm_session_.reset();

View File

@@ -2006,7 +2006,7 @@ using ::testing::StrEq;
class DeviceFilesTest : public ::testing::Test {
protected:
virtual void SetUp() {
void SetUp() override {
ASSERT_TRUE(Properties::GetDeviceFilesBasePath(kSecurityLevelL1,
&device_base_path_));
}

View File

@@ -24,7 +24,7 @@ class FileTest : public testing::Test {
protected:
FileTest() {}
virtual void TearDown() { RemoveTestDir(); }
void TearDown() override { RemoveTestDir(); }
void RemoveTestDir() {
EXPECT_TRUE(file_system.Remove(test_vectors::kTestDir));

View File

@@ -34,7 +34,7 @@ class WvGenericOperationsTest : public WvCdmTestBase {
WvGenericOperationsTest()
: cdm_engine_(&file_system_), holder_(&cdm_engine_) {}
virtual void SetUp() {
void SetUp() override {
WvCdmTestBase::SetUp();
EnsureProvisioned();
holder_.OpenSession(config_.key_system());
@@ -61,7 +61,7 @@ class WvGenericOperationsTest : public WvCdmTestBase {
iv_ = std::string(iv_vector_.begin(), iv_vector_.end());
}
virtual void TearDown() { holder_.CloseSession(); }
void TearDown() override { holder_.CloseSession(); }
// Create a single key, and add it to the license.
void AddOneKey(const KeyId& key_id, const std::vector<uint8_t>& key_data,

View File

@@ -97,7 +97,7 @@ class LicenseKeysTest : public ::testing::Test {
static const KeyFlag kContentClearFalse = kKeyFlagFalse;
static const KeyFlag kContentClearTrue = kKeyFlagTrue;
virtual void SetUp() {
void SetUp() override {
LicenseIdentification* id = license_.mutable_id();
id->set_version(1);
id->set_type(STREAMING);

View File

@@ -207,7 +207,7 @@ class CdmLicenseTest : public WvCdmTestBase {
protected:
CdmLicenseTest(const std::string& pssh = (kCencInitDataHdr + kCencPssh))
: pssh_(pssh) {}
virtual void SetUp() {
void SetUp() override {
WvCdmTestBase::SetUp();
clock_ = new MockClock();
crypto_session_ = new MockCryptoSession(&crypto_metrics_);
@@ -219,7 +219,7 @@ class CdmLicenseTest : public WvCdmTestBase {
DoAll(SetArgPointee<0>(kDefaultSupportedCertTypes), Return(true)));
}
virtual void TearDown() {
void TearDown() override {
if (cdm_license_) delete cdm_license_;
if (policy_engine_) delete policy_engine_;
if (init_data_) delete init_data_;

View File

@@ -92,7 +92,7 @@ class PolicyEngineConstraintsTest : public WvCdmTestBase {
}
protected:
virtual void SetUp() {
void SetUp() override {
WvCdmTestBase::SetUp();
current_time_ = 0;

View File

@@ -105,7 +105,7 @@ class PolicyEngineTest : public WvCdmTestBase {
PolicyEngineTest() : crypto_session_(&dummy_metrics_) {
}
protected:
virtual void SetUp() {
void SetUp() override {
WvCdmTestBase::SetUp();
policy_engine_.reset(
new PolicyEngine(kSessionId, &mock_event_listener_,
@@ -1927,7 +1927,7 @@ TEST_F(PolicyEngineKeyAllowedUsageTest, AllowedUsageGeneric) {
class PolicyEngineQueryTest : public PolicyEngineTest {
protected:
virtual void SetUp() {
void SetUp() override {
PolicyEngineTest::SetUp();
policy_engine_.reset(new PolicyEngine(kSessionId, NULL, &crypto_session_));
InjectMockClock();

View File

@@ -57,27 +57,27 @@ class StubCdmClientPropertySet : public CdmClientPropertySet {
session_sharing_id_(0),
app_id_(kAppId) {}
virtual const std::string& security_level() const { return security_level_; }
const std::string& security_level() const override { return security_level_; }
virtual bool use_privacy_mode() const { return use_privacy_mode_; }
bool use_privacy_mode() const override { return use_privacy_mode_; }
virtual const std::string& service_certificate() const {
const std::string& service_certificate() const override {
return raw_service_certificate_;
}
virtual void set_service_certificate(const std::string& cert) {
void set_service_certificate(const std::string& cert) override {
raw_service_certificate_ = cert;
}
virtual bool is_session_sharing_enabled() const {
bool is_session_sharing_enabled() const override {
return is_session_sharing_enabled_;
}
virtual uint32_t session_sharing_id() const { return session_sharing_id_; }
uint32_t session_sharing_id() const override { return session_sharing_id_; }
virtual void set_session_sharing_id(uint32_t id) { session_sharing_id_ = id; }
void set_session_sharing_id(uint32_t id) override { session_sharing_id_ = id; }
virtual const std::string& app_id() const { return app_id_; }
const std::string& app_id() const override { return app_id_; }
void enable_privacy_mode() { use_privacy_mode_ = true; }

View File

@@ -20,8 +20,8 @@ namespace wvcdm {
class WvCdmTestBase : public ::testing::Test {
public:
WvCdmTestBase() : config_(default_config_), binary_provisioning_(false) {}
virtual ~WvCdmTestBase() {}
virtual void SetUp();
~WvCdmTestBase() override {}
void SetUp() override;
virtual std::string binary_key_id() const { return a2bs_hex(config_.key_id()); }
// Returns true if the test program should continue, if false, the caller

View File

@@ -264,7 +264,7 @@ class UsageTableHeaderTest : public WvCdmTestBase {
}
protected:
virtual void SetUp() {
void SetUp() override {
WvCdmTestBase::SetUp();
// UsageTableHeader will take ownership of the pointer
device_files_ = new MockDeviceFiles();
@@ -276,7 +276,7 @@ class UsageTableHeaderTest : public WvCdmTestBase {
usage_table_header_->SetCryptoSession(crypto_session_);
}
virtual void TearDown() {
void TearDown() override {
if (usage_table_header_ != NULL) delete usage_table_header_;
}