зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1465103 Convert service worker and clients release assertions to diagnostic assertions. r=asuth
This commit is contained in:
Родитель
6a3f757203
Коммит
08be40bcc5
|
@ -50,7 +50,7 @@ ClientHandle::StartOp(const ClientOpConstructorArgs& aArgs,
|
|||
|
||||
MaybeExecute([aArgs, kungFuGrip, aRejectCallback,
|
||||
resolve = std::move(aResolveCallback)] (ClientHandleChild* aActor) {
|
||||
MOZ_RELEASE_ASSERT(aActor);
|
||||
MOZ_DIAGNOSTIC_ASSERT(aActor);
|
||||
ClientHandleOpChild* actor =
|
||||
new ClientHandleOpChild(kungFuGrip, aArgs, std::move(resolve),
|
||||
std::move(aRejectCallback));
|
||||
|
@ -59,7 +59,7 @@ ClientHandle::StartOp(const ClientOpConstructorArgs& aArgs,
|
|||
return;
|
||||
}
|
||||
}, [aRejectCallback] {
|
||||
MOZ_RELEASE_ASSERT(aRejectCallback);
|
||||
MOZ_DIAGNOSTIC_ASSERT(aRejectCallback);
|
||||
aRejectCallback(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -39,9 +39,9 @@ ClientHandleOpChild::ClientHandleOpChild(ClientHandle* aClientHandle,
|
|||
, mResolveCallback(std::move(aResolveCallback))
|
||||
, mRejectCallback(std::move(aRejectCallback))
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(mClientHandle);
|
||||
MOZ_RELEASE_ASSERT(mResolveCallback);
|
||||
MOZ_RELEASE_ASSERT(mRejectCallback);
|
||||
MOZ_DIAGNOSTIC_ASSERT(mClientHandle);
|
||||
MOZ_DIAGNOSTIC_ASSERT(mResolveCallback);
|
||||
MOZ_DIAGNOSTIC_ASSERT(mRejectCallback);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -28,12 +28,21 @@ using mozilla::ipc::PrincipalInfo;
|
|||
namespace {
|
||||
|
||||
const uint32_t kBadThreadLocalIndex = -1;
|
||||
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
const uint32_t kThreadLocalMagic1 = 0x8d57eea6;
|
||||
const uint32_t kThreadLocalMagic2 = 0x59f375c9;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
uint32_t sClientManagerThreadLocalMagic1 = kThreadLocalMagic1;
|
||||
#endif
|
||||
|
||||
uint32_t sClientManagerThreadLocalIndex = kBadThreadLocalIndex;
|
||||
|
||||
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
uint32_t sClientManagerThreadLocalMagic2 = kThreadLocalMagic2;
|
||||
uint32_t sClientManagerThreadLocalIndexDuplicate = kBadThreadLocalIndex;
|
||||
#endif
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
@ -84,11 +93,11 @@ ClientManager::~ClientManager()
|
|||
|
||||
Shutdown();
|
||||
|
||||
MOZ_RELEASE_ASSERT(sClientManagerThreadLocalMagic1 == kThreadLocalMagic1);
|
||||
MOZ_RELEASE_ASSERT(sClientManagerThreadLocalMagic2 == kThreadLocalMagic2);
|
||||
MOZ_RELEASE_ASSERT(sClientManagerThreadLocalIndex != kBadThreadLocalIndex);
|
||||
MOZ_RELEASE_ASSERT(sClientManagerThreadLocalIndex == sClientManagerThreadLocalIndexDuplicate);
|
||||
MOZ_RELEASE_ASSERT(this == PR_GetThreadPrivate(sClientManagerThreadLocalIndex));
|
||||
MOZ_DIAGNOSTIC_ASSERT(sClientManagerThreadLocalMagic1 == kThreadLocalMagic1);
|
||||
MOZ_DIAGNOSTIC_ASSERT(sClientManagerThreadLocalMagic2 == kThreadLocalMagic2);
|
||||
MOZ_DIAGNOSTIC_ASSERT(sClientManagerThreadLocalIndex != kBadThreadLocalIndex);
|
||||
MOZ_DIAGNOSTIC_ASSERT(sClientManagerThreadLocalIndex == sClientManagerThreadLocalIndexDuplicate);
|
||||
MOZ_DIAGNOSTIC_ASSERT(this == PR_GetThreadPrivate(sClientManagerThreadLocalIndex));
|
||||
|
||||
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
PRStatus status =
|
||||
|
@ -194,10 +203,10 @@ ClientManager::StartOp(const ClientOpConstructorArgs& aArgs,
|
|||
already_AddRefed<ClientManager>
|
||||
ClientManager::GetOrCreateForCurrentThread()
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(sClientManagerThreadLocalMagic1 == kThreadLocalMagic1);
|
||||
MOZ_RELEASE_ASSERT(sClientManagerThreadLocalMagic2 == kThreadLocalMagic2);
|
||||
MOZ_RELEASE_ASSERT(sClientManagerThreadLocalIndex != kBadThreadLocalIndex);
|
||||
MOZ_RELEASE_ASSERT(sClientManagerThreadLocalIndex == sClientManagerThreadLocalIndexDuplicate);
|
||||
MOZ_DIAGNOSTIC_ASSERT(sClientManagerThreadLocalMagic1 == kThreadLocalMagic1);
|
||||
MOZ_DIAGNOSTIC_ASSERT(sClientManagerThreadLocalMagic2 == kThreadLocalMagic2);
|
||||
MOZ_DIAGNOSTIC_ASSERT(sClientManagerThreadLocalIndex != kBadThreadLocalIndex);
|
||||
MOZ_DIAGNOSTIC_ASSERT(sClientManagerThreadLocalIndex == sClientManagerThreadLocalIndexDuplicate);
|
||||
RefPtr<ClientManager> cm =
|
||||
static_cast<ClientManager*>(PR_GetThreadPrivate(sClientManagerThreadLocalIndex));
|
||||
|
||||
|
@ -211,7 +220,7 @@ ClientManager::GetOrCreateForCurrentThread()
|
|||
MOZ_DIAGNOSTIC_ASSERT(status == PR_SUCCESS);
|
||||
}
|
||||
|
||||
MOZ_RELEASE_ASSERT(cm);
|
||||
MOZ_DIAGNOSTIC_ASSERT(cm);
|
||||
return cm.forget();
|
||||
}
|
||||
|
||||
|
@ -229,10 +238,10 @@ ClientManager::Startup()
|
|||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
MOZ_RELEASE_ASSERT(sClientManagerThreadLocalMagic1 == kThreadLocalMagic1);
|
||||
MOZ_RELEASE_ASSERT(sClientManagerThreadLocalMagic2 == kThreadLocalMagic2);
|
||||
MOZ_RELEASE_ASSERT(sClientManagerThreadLocalIndex == kBadThreadLocalIndex);
|
||||
MOZ_RELEASE_ASSERT(sClientManagerThreadLocalIndex == sClientManagerThreadLocalIndexDuplicate);
|
||||
MOZ_DIAGNOSTIC_ASSERT(sClientManagerThreadLocalMagic1 == kThreadLocalMagic1);
|
||||
MOZ_DIAGNOSTIC_ASSERT(sClientManagerThreadLocalMagic2 == kThreadLocalMagic2);
|
||||
MOZ_DIAGNOSTIC_ASSERT(sClientManagerThreadLocalIndex == kBadThreadLocalIndex);
|
||||
MOZ_DIAGNOSTIC_ASSERT(sClientManagerThreadLocalIndex == sClientManagerThreadLocalIndexDuplicate);
|
||||
|
||||
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
PRStatus status =
|
||||
|
@ -240,8 +249,10 @@ ClientManager::Startup()
|
|||
PR_NewThreadPrivateIndex(&sClientManagerThreadLocalIndex, nullptr);
|
||||
MOZ_DIAGNOSTIC_ASSERT(status == PR_SUCCESS);
|
||||
|
||||
MOZ_RELEASE_ASSERT(sClientManagerThreadLocalIndex != kBadThreadLocalIndex);
|
||||
MOZ_DIAGNOSTIC_ASSERT(sClientManagerThreadLocalIndex != kBadThreadLocalIndex);
|
||||
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
sClientManagerThreadLocalIndexDuplicate = sClientManagerThreadLocalIndex;
|
||||
#endif
|
||||
|
||||
ClientPrefsInit();
|
||||
}
|
||||
|
|
|
@ -17,19 +17,25 @@ namespace dom {
|
|||
template <typename ActorType>
|
||||
class ClientThing
|
||||
{
|
||||
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
static const uint32_t kMagic1 = 0xC9FE2C9C;
|
||||
static const uint32_t kMagic2 = 0x832072D4;
|
||||
#endif
|
||||
|
||||
ActorType* mActor;
|
||||
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
uint32_t mMagic1;
|
||||
uint32_t mMagic2;
|
||||
#endif
|
||||
bool mShutdown;
|
||||
|
||||
protected:
|
||||
ClientThing()
|
||||
: mActor(nullptr)
|
||||
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
, mMagic1(kMagic1)
|
||||
, mMagic2(kMagic2)
|
||||
#endif
|
||||
, mShutdown(false)
|
||||
{
|
||||
}
|
||||
|
@ -38,15 +44,17 @@ protected:
|
|||
{
|
||||
AssertIsValid();
|
||||
ShutdownThing();
|
||||
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
mMagic1 = 0;
|
||||
mMagic2 = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
AssertIsValid() const
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(mMagic1 == kMagic1);
|
||||
MOZ_RELEASE_ASSERT(mMagic2 == kMagic2);
|
||||
MOZ_DIAGNOSTIC_ASSERT(mMagic1 == kMagic1);
|
||||
MOZ_DIAGNOSTIC_ASSERT(mMagic2 == kMagic2);
|
||||
}
|
||||
|
||||
// Return the current actor.
|
||||
|
|
|
@ -312,7 +312,7 @@ RefPtr<GenericPromise>
|
|||
ServiceWorkerManager::StartControllingClient(const ClientInfo& aClientInfo,
|
||||
ServiceWorkerRegistrationInfo* aRegistrationInfo)
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(aRegistrationInfo->GetActive());
|
||||
MOZ_DIAGNOSTIC_ASSERT(aRegistrationInfo->GetActive());
|
||||
|
||||
RefPtr<GenericPromise> ref;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче