зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1509135 - Only define UnregisterCallback once r=mrbkap
Differential Revision: https://phabricator.services.mozilla.com/D13018 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
5208359b12
Коммит
66c2ebb86a
|
@ -26,6 +26,7 @@
|
||||||
#include "ServiceWorkerManager.h"
|
#include "ServiceWorkerManager.h"
|
||||||
#include "ServiceWorkerPrivate.h"
|
#include "ServiceWorkerPrivate.h"
|
||||||
#include "ServiceWorkerRegistration.h"
|
#include "ServiceWorkerRegistration.h"
|
||||||
|
#include "ServiceWorkerUnregisterCallback.h"
|
||||||
|
|
||||||
#include "nsIDocument.h"
|
#include "nsIDocument.h"
|
||||||
#include "nsIServiceWorkerManager.h"
|
#include "nsIServiceWorkerManager.h"
|
||||||
|
@ -394,44 +395,6 @@ private:
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS(SWRUpdateRunnable::TimerCallback, nsITimerCallback)
|
NS_IMPL_ISUPPORTS(SWRUpdateRunnable::TimerCallback, nsITimerCallback)
|
||||||
|
|
||||||
class UnregisterCallback final : public nsIServiceWorkerUnregisterCallback
|
|
||||||
{
|
|
||||||
RefPtr<GenericPromise::Private> mPromise;
|
|
||||||
|
|
||||||
public:
|
|
||||||
NS_DECL_ISUPPORTS
|
|
||||||
|
|
||||||
UnregisterCallback()
|
|
||||||
: mPromise(new GenericPromise::Private(__func__))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHOD
|
|
||||||
UnregisterSucceeded(bool aState) override
|
|
||||||
{
|
|
||||||
mPromise->Resolve(aState, __func__);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHOD
|
|
||||||
UnregisterFailed() override
|
|
||||||
{
|
|
||||||
mPromise->Reject(NS_ERROR_DOM_SECURITY_ERR, __func__);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
RefPtr<GenericPromise>
|
|
||||||
Promise() const
|
|
||||||
{
|
|
||||||
return mPromise;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
~UnregisterCallback() = default;
|
|
||||||
};
|
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS(UnregisterCallback, nsIServiceWorkerUnregisterCallback)
|
|
||||||
|
|
||||||
class WorkerUnregisterCallback final : public nsIServiceWorkerUnregisterCallback
|
class WorkerUnregisterCallback final : public nsIServiceWorkerUnregisterCallback
|
||||||
{
|
{
|
||||||
RefPtr<ThreadSafeWorkerRef> mWorkerRef;
|
RefPtr<ThreadSafeWorkerRef> mWorkerRef;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "mozilla/ipc/BackgroundParent.h"
|
#include "mozilla/ipc/BackgroundParent.h"
|
||||||
#include "ServiceWorkerManager.h"
|
#include "ServiceWorkerManager.h"
|
||||||
#include "ServiceWorkerRegistrationParent.h"
|
#include "ServiceWorkerRegistrationParent.h"
|
||||||
|
#include "ServiceWorkerUnregisterCallback.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
@ -170,42 +171,6 @@ ServiceWorkerRegistrationProxy::RevokeActor(ServiceWorkerRegistrationParent* aAc
|
||||||
MOZ_ALWAYS_SUCCEEDS(SystemGroup::Dispatch(TaskCategory::Other, r.forget()));
|
MOZ_ALWAYS_SUCCEEDS(SystemGroup::Dispatch(TaskCategory::Other, r.forget()));
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
class UnregisterCallback final : public nsIServiceWorkerUnregisterCallback
|
|
||||||
{
|
|
||||||
RefPtr<GenericPromise::Private> mPromise;
|
|
||||||
|
|
||||||
~UnregisterCallback() = default;
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit UnregisterCallback(GenericPromise::Private* aPromise)
|
|
||||||
: mPromise(aPromise)
|
|
||||||
{
|
|
||||||
MOZ_DIAGNOSTIC_ASSERT(mPromise);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHOD
|
|
||||||
UnregisterSucceeded(bool aState) override
|
|
||||||
{
|
|
||||||
mPromise->Resolve(aState, __func__);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHOD
|
|
||||||
UnregisterFailed() override
|
|
||||||
{
|
|
||||||
mPromise->Reject(NS_ERROR_DOM_SECURITY_ERR, __func__);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
|
||||||
};
|
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS(UnregisterCallback, nsIServiceWorkerUnregisterCallback)
|
|
||||||
|
|
||||||
} // anonymous namespace
|
|
||||||
|
|
||||||
RefPtr<GenericPromise>
|
RefPtr<GenericPromise>
|
||||||
ServiceWorkerRegistrationProxy::Unregister()
|
ServiceWorkerRegistrationProxy::Unregister()
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* 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 "ServiceWorkerUnregisterCallback.h"
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
namespace dom {
|
||||||
|
|
||||||
|
NS_IMPL_ISUPPORTS(UnregisterCallback, nsIServiceWorkerUnregisterCallback)
|
||||||
|
|
||||||
|
UnregisterCallback::UnregisterCallback()
|
||||||
|
: mPromise(new GenericPromise::Private(__func__)) {}
|
||||||
|
|
||||||
|
UnregisterCallback::UnregisterCallback(GenericPromise::Private* aPromise)
|
||||||
|
: mPromise(aPromise)
|
||||||
|
{
|
||||||
|
MOZ_DIAGNOSTIC_ASSERT(mPromise);
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
UnregisterCallback::UnregisterSucceeded(bool aState)
|
||||||
|
{
|
||||||
|
mPromise->Resolve(aState, __func__);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
UnregisterCallback::UnregisterFailed()
|
||||||
|
{
|
||||||
|
mPromise->Reject(NS_ERROR_DOM_SECURITY_ERR, __func__);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
RefPtr<GenericPromise>
|
||||||
|
UnregisterCallback::Promise() const
|
||||||
|
{
|
||||||
|
return mPromise;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace dom
|
||||||
|
} // namespace mozilla
|
|
@ -0,0 +1,45 @@
|
||||||
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* 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/. */
|
||||||
|
|
||||||
|
#ifndef mozilla_dom_ServiceWorkerUnregisterCallback_h
|
||||||
|
#define mozilla_dom_ServiceWorkerUnregisterCallback_h
|
||||||
|
|
||||||
|
#include "mozilla/MozPromise.h"
|
||||||
|
#include "mozilla/RefPtr.h"
|
||||||
|
#include "nsIServiceWorkerManager.h"
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
namespace dom {
|
||||||
|
|
||||||
|
class UnregisterCallback final : public nsIServiceWorkerUnregisterCallback
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
|
UnregisterCallback();
|
||||||
|
|
||||||
|
explicit UnregisterCallback(GenericPromise::Private* aPromise);
|
||||||
|
|
||||||
|
// nsIServiceWorkerUnregisterCallback implementation
|
||||||
|
NS_IMETHOD
|
||||||
|
UnregisterSucceeded(bool aState) override;
|
||||||
|
|
||||||
|
NS_IMETHOD
|
||||||
|
UnregisterFailed() override;
|
||||||
|
|
||||||
|
RefPtr<GenericPromise>
|
||||||
|
Promise() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
~UnregisterCallback() = default;
|
||||||
|
|
||||||
|
RefPtr<GenericPromise::Private> mPromise;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dom
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
|
#endif // mozilla_dom_ServiceWorkerUnregisterCallback_h
|
|
@ -64,6 +64,7 @@ UNIFIED_SOURCES += [
|
||||||
'ServiceWorkerRegistrationParent.cpp',
|
'ServiceWorkerRegistrationParent.cpp',
|
||||||
'ServiceWorkerRegistrationProxy.cpp',
|
'ServiceWorkerRegistrationProxy.cpp',
|
||||||
'ServiceWorkerScriptCache.cpp',
|
'ServiceWorkerScriptCache.cpp',
|
||||||
|
'ServiceWorkerUnregisterCallback.cpp',
|
||||||
'ServiceWorkerUnregisterJob.cpp',
|
'ServiceWorkerUnregisterJob.cpp',
|
||||||
'ServiceWorkerUpdateJob.cpp',
|
'ServiceWorkerUpdateJob.cpp',
|
||||||
'ServiceWorkerUpdaterChild.cpp',
|
'ServiceWorkerUpdaterChild.cpp',
|
||||||
|
|
Загрузка…
Ссылка в новой задаче