Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
* License, v. 2.0. If a copy of the MPL was not distributed with this
5
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "ServiceWorkerUnregisterCallback.h"
8
9
namespace mozilla {
10
namespace dom {
11
12
NS_IMPL_ISUPPORTS(UnregisterCallback, nsIServiceWorkerUnregisterCallback)
13
14
UnregisterCallback::UnregisterCallback()
15
: mPromise(new GenericPromise::Private(__func__)) {}
16
17
UnregisterCallback::UnregisterCallback(GenericPromise::Private* aPromise)
18
: mPromise(aPromise) {
19
MOZ_DIAGNOSTIC_ASSERT(mPromise);
20
}
21
22
NS_IMETHODIMP
23
UnregisterCallback::UnregisterSucceeded(bool aState) {
24
mPromise->Resolve(aState, __func__);
25
return NS_OK;
26
}
27
28
NS_IMETHODIMP
29
UnregisterCallback::UnregisterFailed() {
30
mPromise->Reject(NS_ERROR_DOM_SECURITY_ERR, __func__);
31
return NS_OK;
32
}
33
34
RefPtr<GenericPromise> UnregisterCallback::Promise() const { return mPromise; }
35
36
} // namespace dom
37
} // namespace mozilla