Bug 1191495 - Relax PushManager callback assertions. r=kitcambridge

--HG--
extra : commitid : 4K4ciVH8oHB
extra : rebase_source : d68782c9d9984a08faa0c3a33197a599dc5b52e6
extra : histedit_source : a666d3f7fc6c503379f962cf40f551b52450470e
This commit is contained in:
Nikhil Marathe 2015-08-05 15:32:19 -07:00
Родитель ea58277c0d
Коммит f545f1c3eb
1 изменённых файлов: 25 добавлений и 12 удалений

Просмотреть файл

@ -286,7 +286,6 @@ public:
explicit WorkerUnsubscribeResultCallback(PromiseWorkerProxy* aProxy)
: mProxy(aProxy)
, mCallbackCalled(false)
{
AssertIsOnMainThread();
}
@ -295,7 +294,6 @@ public:
OnUnsubscribe(nsresult aStatus, bool aSuccess) override
{
AssertIsOnMainThread();
mCallbackCalled = true;
if (!mProxy) {
return NS_OK;
}
@ -314,19 +312,27 @@ public:
ReleasePromiseWorkerProxy(mProxy.forget());
}
mProxy = nullptr;
return NS_OK;
}
private:
~WorkerUnsubscribeResultCallback()
{
// Enforces that UnsubscribeRunnable uses the callback for error
// reporting once it creates the callback.
MOZ_ASSERT(mCallbackCalled);
AssertIsOnMainThread();
if (mProxy) {
MutexAutoLock lock(mProxy->GetCleanUpLock());
if (!mProxy->IsClean()) {
AutoJSAPI jsapi;
jsapi.Init();
nsRefPtr<PromiseWorkerProxyControlRunnable> cr =
new PromiseWorkerProxyControlRunnable(mProxy->GetWorkerPrivate(), mProxy);
cr->Dispatch(jsapi.cx());
}
}
}
nsRefPtr<PromiseWorkerProxy> mProxy;
DebugOnly<bool> mCallbackCalled;
};
NS_IMPL_ISUPPORTS(WorkerUnsubscribeResultCallback, nsIUnsubscribeResultCallback)
@ -477,14 +483,12 @@ public:
const nsAString& aScope)
: mProxy(aProxy)
, mScope(aScope)
, mCallbackCalled(false)
{}
NS_IMETHOD
OnPushEndpoint(nsresult aStatus, const nsAString& aEndpoint) override
{
AssertIsOnMainThread();
mCallbackCalled = true;
if (!mProxy) {
return NS_OK;
@ -503,21 +507,30 @@ public:
if (!r->Dispatch(jsapi.cx())) {
ReleasePromiseWorkerProxy(mProxy.forget());
}
mProxy = nullptr;
return NS_OK;
}
protected:
~GetSubscriptionCallback()
{
// Enforces that GetSubscriptionRunnable uses the callback for error
// reporting once it creates the callback.
MOZ_ASSERT(mCallbackCalled);
AssertIsOnMainThread();
if (mProxy) {
MutexAutoLock lock(mProxy->GetCleanUpLock());
if (!mProxy->IsClean()) {
AutoJSAPI jsapi;
jsapi.Init();
nsRefPtr<PromiseWorkerProxyControlRunnable> cr =
new PromiseWorkerProxyControlRunnable(mProxy->GetWorkerPrivate(), mProxy);
cr->Dispatch(jsapi.cx());
}
}
}
private:
nsRefPtr<PromiseWorkerProxy> mProxy;
nsString mScope;
DebugOnly<bool> mCallbackCalled;
};
NS_IMPL_ISUPPORTS(GetSubscriptionCallback, nsIPushEndpointCallback)