From 28bc1f81d209523d937c6239e16149782549a9ae Mon Sep 17 00:00:00 2001 From: Gabriel Ivanica Date: Wed, 29 Oct 2014 00:43:18 +0200 Subject: [PATCH] Bug 1089705 - Replace "assert" with "MOZ_ASSERT" in some media code. r=dholbert --- dom/media/gmp-plugin/gmp-test-decryptor.cpp | 6 +++--- dom/media/gmp-plugin/gmp-test-storage.cpp | 11 ++++++----- media/gmp-clearkey/0.1/ClearKeyDecryptionManager.cpp | 11 ++++++----- media/gmp-clearkey/0.1/ClearKeyUtils.cpp | 9 ++++----- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/dom/media/gmp-plugin/gmp-test-decryptor.cpp b/dom/media/gmp-plugin/gmp-test-decryptor.cpp index 903ddd0133a..12619152ea5 100644 --- a/dom/media/gmp-plugin/gmp-test-decryptor.cpp +++ b/dom/media/gmp-plugin/gmp-test-decryptor.cpp @@ -12,8 +12,8 @@ #include #include #include -#include +#include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/NullPtr.h" @@ -36,7 +36,7 @@ MaybeFinish() FakeDecryptor::FakeDecryptor() : mCallback(nullptr) { - assert(!sInstance); + MOZ_ASSERT(!sInstance); sInstance = this; } @@ -49,7 +49,7 @@ void FakeDecryptor::DecryptingComplete() void FakeDecryptor::Message(const std::string& aMessage) { - assert(sInstance); + MOZ_ASSERT(sInstance); const static std::string sid("fake-session-id"); sInstance->mCallback->SessionMessage(sid.c_str(), sid.size(), (const uint8_t*)aMessage.c_str(), aMessage.size(), diff --git a/dom/media/gmp-plugin/gmp-test-storage.cpp b/dom/media/gmp-plugin/gmp-test-storage.cpp index 4fc1432a41e..eb4c957f11f 100644 --- a/dom/media/gmp-plugin/gmp-test-storage.cpp +++ b/dom/media/gmp-plugin/gmp-test-storage.cpp @@ -5,7 +5,8 @@ #include "gmp-test-storage.h" #include -#include + +#include "mozilla/Assertions.h" #include "mozilla/Attributes.h" class WriteRecordClient : public GMPRecordClient { @@ -119,7 +120,7 @@ GMPErr ReadRecord(const std::string& aRecordName, ReadContinuation* aContinuation) { - assert(aContinuation); + MOZ_ASSERT(aContinuation); GMPRecord* record; ReadRecordClient* client = new ReadRecordClient(); auto err = GMPOpenRecord(aRecordName.c_str(), @@ -140,14 +141,14 @@ GMPOpenRecord(const char* aName, GMPRecord** aOutRecord, GMPRecordClient* aClient) { - assert(g_platform_api); + MOZ_ASSERT(g_platform_api); return g_platform_api->createrecord(aName, aNameLength, aOutRecord, aClient); } GMPErr GMPRunOnMainThread(GMPTask* aTask) { - assert(g_platform_api); + MOZ_ASSERT(g_platform_api); return g_platform_api->runonmainthread(aTask); } @@ -180,7 +181,7 @@ GMPErr GMPOpenRecord(const std::string& aRecordName, OpenContinuation* aContinuation) { - assert(aContinuation); + MOZ_ASSERT(aContinuation); GMPRecord* record; OpenRecordClient* client = new OpenRecordClient(); auto err = GMPOpenRecord(aRecordName.c_str(), diff --git a/media/gmp-clearkey/0.1/ClearKeyDecryptionManager.cpp b/media/gmp-clearkey/0.1/ClearKeyDecryptionManager.cpp index 8ce47a52fba..7dfa9476358 100644 --- a/media/gmp-clearkey/0.1/ClearKeyDecryptionManager.cpp +++ b/media/gmp-clearkey/0.1/ClearKeyDecryptionManager.cpp @@ -2,13 +2,14 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include #include #include #include #include "ClearKeyDecryptionManager.h" #include "ClearKeyUtils.h" + +#include "mozilla/Assertions.h" #include "mozilla/NullPtr.h" using namespace mozilla; @@ -129,7 +130,7 @@ ClearKeyDecryptionManager::CreateSession(uint32_t aPromiseId, } string sessionId = GetNewSessionId(); - assert(mSessions.find(sessionId) == mSessions.end()); + MOZ_ASSERT(mSessions.find(sessionId) == mSessions.end()); ClearKeySession* session = new ClearKeySession(sessionId, mCallback); session->Init(aPromiseId, aInitData, aInitDataSize); @@ -221,11 +222,11 @@ ClearKeyDecryptionManager::CloseSession(uint32_t aPromiseId, string sessionId(aSessionId, aSessionId + aSessionIdLength); ClearKeySession* session = mSessions[sessionId]; - assert(session); + MOZ_ASSERT(session); const vector& keyIds = session->GetKeyIds(); for (auto it = keyIds.begin(); it != keyIds.end(); it++) { - assert(mDecryptors.find(*it) != mDecryptors.end()); + MOZ_ASSERT(mDecryptors.find(*it) != mDecryptors.end()); if (!mDecryptors[*it]->Release()) { mDecryptors.erase(*it); @@ -332,7 +333,7 @@ ClearKeyDecryptor::Decrypt(GMPBuffer* aBuffer, memcpy(&tmp[0], aBuffer->Data(), aBuffer->Size()); } - assert(aMetadata->IVSize() == 8 || aMetadata->IVSize() == 16); + MOZ_ASSERT(aMetadata->IVSize() == 8 || aMetadata->IVSize() == 16); vector iv(aMetadata->IV(), aMetadata->IV() + aMetadata->IVSize()); iv.insert(iv.end(), CLEARKEY_KEY_LEN - aMetadata->IVSize(), 0); diff --git a/media/gmp-clearkey/0.1/ClearKeyUtils.cpp b/media/gmp-clearkey/0.1/ClearKeyUtils.cpp index b5bea0a73d1..5aba7f503d5 100644 --- a/media/gmp-clearkey/0.1/ClearKeyUtils.cpp +++ b/media/gmp-clearkey/0.1/ClearKeyUtils.cpp @@ -3,7 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include -#include #include #include #include @@ -43,7 +42,7 @@ static void IncrementIV(vector& aIV) { using mozilla::BigEndian; - assert(aIV.size() == 16); + MOZ_ASSERT(aIV.size() == 16); BigEndian::writeUint64(&aIV[8], BigEndian::readUint64(&aIV[8]) + 1); } @@ -51,8 +50,8 @@ IncrementIV(vector& aIV) { ClearKeyUtils::DecryptAES(const vector& aKey, vector& aData, vector& aIV) { - assert(aIV.size() == CLEARKEY_KEY_LEN); - assert(aKey.size() == CLEARKEY_KEY_LEN); + MOZ_ASSERT(aIV.size() == CLEARKEY_KEY_LEN); + MOZ_ASSERT(aKey.size() == CLEARKEY_KEY_LEN); OAES_CTX* aes = oaes_alloc(); oaes_key_import_data(aes, &aKey[0], aKey.size()); @@ -65,7 +64,7 @@ ClearKeyUtils::DecryptAES(const vector& aKey, vector enc(encLen); oaes_encrypt(aes, &aIV[0], CLEARKEY_KEY_LEN, &enc[0], &encLen); - assert(encLen >= 2 * OAES_BLOCK_SIZE + CLEARKEY_KEY_LEN); + MOZ_ASSERT(encLen >= 2 * OAES_BLOCK_SIZE + CLEARKEY_KEY_LEN); size_t blockLen = std::min(aData.size() - i, CLEARKEY_KEY_LEN); for (size_t j = 0; j < blockLen; j++) { aData[i + j] ^= enc[2 * OAES_BLOCK_SIZE + j];