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

@@ -47,7 +47,7 @@ class Key {
Key(const std::vector<uint8_t>& key_string, const KeyControlBlock& control)
: value_(key_string), control_(control), ctr_mode_(true){};
virtual ~Key(){};
virtual ~Key() {};
void UpdateDuration(const KeyControlBlock& control);
virtual const std::vector<uint8_t>& value() const { return value_; }
const KeyControlBlock& control() const { return control_; }
@@ -65,8 +65,8 @@ class Key {
class EntitlementKey : public Key {
public:
EntitlementKey(const Key& key) : Key(key) {}
virtual ~EntitlementKey() {}
virtual const std::vector<uint8_t>& value() const { return content_key_; }
~EntitlementKey() override {}
const std::vector<uint8_t>& value() const override { return content_key_; }
const std::vector<uint8_t>& content_key() { return content_key_; }
const std::vector<uint8_t>& content_key_id() { return content_key_id_; }
const std::vector<uint8_t>& entitlement_key() { return Key::value(); }

View File

@@ -55,20 +55,20 @@ namespace wvoec_ref {
class ContentKeysContext : public SessionContextKeys {
public:
explicit ContentKeysContext() {}
virtual ~ContentKeysContext() {}
virtual size_t size() { return session_keys_.size(); }
bool Insert(const KeyId& key_id, const Key& key_data);
virtual Key* Find(const KeyId& key_id);
virtual void Remove(const KeyId& key_id);
virtual void UpdateDuration(const KeyControlBlock& control);
~ContentKeysContext() override {}
size_t size() override { return session_keys_.size(); }
bool Insert(const KeyId& key_id, const Key& key_data) override;
Key* Find(const KeyId& key_id) override;
void Remove(const KeyId& key_id) override;
void UpdateDuration(const KeyControlBlock& control) override;
virtual OEMCrypto_LicenseType type() { return OEMCrypto_ContentLicense; }
OEMCrypto_LicenseType type() override { return OEMCrypto_ContentLicense; }
virtual bool SetContentKey(const KeyId& entitlement_id,
const KeyId& content_key_id,
const std::vector<uint8_t>& content_key);
virtual bool GetEntitlementKey(const KeyId& entitlement_id,
const std::vector<uint8_t>** entitlement_key);
bool SetContentKey(const KeyId& entitlement_id,
const KeyId& content_key_id,
const std::vector<uint8_t>& content_key) override;
bool GetEntitlementKey(const KeyId& entitlement_id,
const std::vector<uint8_t>** entitlement_key) override;
private:
SessionKeyTable session_keys_;
@@ -109,19 +109,19 @@ bool ContentKeysContext::GetEntitlementKey(const KeyId& entitlement_id,
class EntitlementKeysContext : public SessionContextKeys {
public:
EntitlementKeysContext() {}
virtual ~EntitlementKeysContext() {}
virtual size_t size() { return session_keys_.size(); }
bool Insert(const KeyId& key_id, const Key& key_data);
virtual Key* Find(const KeyId& key_id);
virtual void Remove(const KeyId& key_id);
virtual void UpdateDuration(const KeyControlBlock& control);
virtual bool SetContentKey(const KeyId& entitlement_id,
const KeyId& content_key_id,
const std::vector<uint8_t>& content_key);
virtual bool GetEntitlementKey(const KeyId& entitlement_id,
const std::vector<uint8_t>** key);
~EntitlementKeysContext() override {}
size_t size() override { return session_keys_.size(); }
bool Insert(const KeyId& key_id, const Key& key_data) override;
Key* Find(const KeyId& key_id) override;
void Remove(const KeyId& key_id) override;
void UpdateDuration(const KeyControlBlock& control) override;
bool SetContentKey(const KeyId& entitlement_id,
const KeyId& content_key_id,
const std::vector<uint8_t>& content_key) override;
bool GetEntitlementKey(const KeyId& entitlement_id,
const std::vector<uint8_t>** key) override;
virtual OEMCrypto_LicenseType type() { return OEMCrypto_EntitlementLicense; }
OEMCrypto_LicenseType type() override { return OEMCrypto_EntitlementLicense; }
private:
EntitlementKeyTable session_keys_;

View File

@@ -90,7 +90,7 @@ class OEMCryptoClientTest : public ::testing::Test, public SessionUtil {
protected:
OEMCryptoClientTest() {}
virtual void SetUp() {
void SetUp() override {
::testing::Test::SetUp();
wvcdm::g_cutoff = wvcdm::LOG_INFO;
const ::testing::TestInfo* const test_info =
@@ -100,7 +100,7 @@ class OEMCryptoClientTest : public ::testing::Test, public SessionUtil {
ASSERT_EQ(OEMCrypto_SUCCESS, OEMCrypto_Initialize());
}
virtual void TearDown() {
void TearDown() override {
OEMCrypto_Terminate();
::testing::Test::TearDown();
}
@@ -492,7 +492,7 @@ TEST_F(OEMCryptoClientTest, CanLoadTestKeys) {
}
class OEMCryptoKeyboxTest : public OEMCryptoClientTest {
virtual void SetUp() {
void SetUp() override {
OEMCryptoClientTest::SetUp();
OEMCryptoResult sts = OEMCrypto_IsKeyboxValid();
// If the production keybox is valid, use it for these tests. Most of the
@@ -710,7 +710,7 @@ class OEMCryptoSessionTests : public OEMCryptoClientTest {
protected:
OEMCryptoSessionTests() {}
virtual void SetUp() {
void SetUp() override {
OEMCryptoClientTest::SetUp();
EnsureTestKeys();
if (global_features.usage_table) {
@@ -738,7 +738,7 @@ class OEMCryptoSessionTests : public OEMCryptoClientTest {
}
}
virtual void TearDown() {
void TearDown() override {
// If we installed a bad keybox, end with a good one installed.
if (global_features.derive_key_method == DeviceFeatures::FORCE_TEST_KEYBOX)
InstallKeybox(kTestKeybox, true);
@@ -1294,7 +1294,7 @@ TEST_F(OEMCryptoSessionTests, LoadKeyUnalignedMessage) {
class SessionTestAlternateVerification : public OEMCryptoSessionTests,
public WithParamInterface<int> {
public:
virtual void SetUp() {
void SetUp() override {
OEMCryptoSessionTests::SetUp();
target_api_ = static_cast<uint32_t>(GetParam());
}
@@ -1569,7 +1569,7 @@ class SessionTestRefreshKeyTest
: public OEMCryptoSessionTests,
public WithParamInterface<std::pair<bool, int> > {
public:
virtual void SetUp() {
void SetUp() override {
OEMCryptoSessionTests::SetUp();
new_mac_keys_ =
GetParam().first; // Whether to put new mac keys in LoadKeys.
@@ -1831,7 +1831,7 @@ class OEMCryptoSessionTestsDecryptTests
public WithParamInterface<tuple<OEMCrypto_CENCEncryptPatternDesc,
OEMCryptoCipherMode, bool> > {
protected:
virtual void SetUp() {
void SetUp() override {
OEMCryptoSessionTests::SetUp();
pattern_ = ::testing::get<0>(GetParam());
cipher_mode_ = ::testing::get<1>(GetParam());
@@ -2789,7 +2789,7 @@ TEST_F(OEMCryptoLoadsCertificate, SupportsCertificatesAPI13) {
class OEMCryptoUsesCertificate : public OEMCryptoLoadsCertificate {
protected:
virtual void SetUp() {
void SetUp() override {
OEMCryptoLoadsCertificate::SetUp();
ASSERT_NO_FATAL_FAILURE(session_.open());
if (global_features.derive_key_method !=
@@ -2802,7 +2802,7 @@ class OEMCryptoUsesCertificate : public OEMCryptoLoadsCertificate {
}
}
virtual void TearDown() {
void TearDown() override {
session_.close();
OEMCryptoLoadsCertificate::TearDown();
}
@@ -4067,14 +4067,14 @@ class GenericCryptoTest : public OEMCryptoSessionTests {
// reasonable number of blocks for most of the tests.
GenericCryptoTest() : buffer_size_(160) {}
virtual void SetUp() {
void SetUp() override {
OEMCryptoSessionTests::SetUp();
ASSERT_NO_FATAL_FAILURE(session_.open());
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&session_));
ASSERT_NO_FATAL_FAILURE(MakeFourKeys());
}
virtual void TearDown() {
void TearDown() override {
session_.close();
OEMCryptoSessionTests::TearDown();
}
@@ -4626,7 +4626,7 @@ const unsigned int kLongKeyId = 2;
class GenericCryptoKeyIdLengthTest : public GenericCryptoTest {
protected:
virtual void SetUp() {
void SetUp() override {
GenericCryptoTest::SetUp();
const uint32_t kNoNonce = 0;
session_.set_num_keys(5);
@@ -4702,7 +4702,7 @@ TEST_F(GenericCryptoKeyIdLengthTest, UniformLongKeyId) {
class UsageTableTest : public GenericCryptoTest {
public:
virtual void SetUp() {
void SetUp() override {
GenericCryptoTest::SetUp();
new_mac_keys_ = true;
}
@@ -4758,7 +4758,7 @@ class UsageTableTest : public GenericCryptoTest {
class UsageTableTestWithMAC : public UsageTableTest,
public WithParamInterface<bool> {
public:
virtual void SetUp() {
void SetUp() override {
UsageTableTest::SetUp();
new_mac_keys_ = GetParam();
}

View File

@@ -23,12 +23,12 @@ namespace wvoec {
// These tests are required for LollyPop Android devices.
class OEMCryptoAndroidLMPTest : public ::testing::Test {
protected:
virtual void SetUp() {
void SetUp() override {
OEMCrypto_SetSandbox(kTestSandbox, sizeof(kTestSandbox));
ASSERT_EQ(OEMCrypto_SUCCESS, OEMCrypto_Initialize());
}
virtual void TearDown() { OEMCrypto_Terminate(); }
void TearDown() override { OEMCrypto_Terminate(); }
};
// Android devices must have a keybox, or use provisioning 3.0.