1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "PromiseNativeWrapper.h"
9 NS_IMPL_ISUPPORTS0(PromiseNativeWrapper
);
11 RefPtr
<GenericNonExclusivePromise
>
12 PromiseNativeWrapper::ConvertJSPromiseToMozPromise(
13 const RefPtr
<dom::Promise
>& jsPromise
) {
14 MozPromiseHolder
<GenericNonExclusivePromise
> holder
;
15 RefPtr
<GenericNonExclusivePromise
> mozPromise
= holder
.Ensure(__func__
);
17 // The handler will resolve mozPromise once jsPromise resolves.
18 RefPtr
<PromiseNativeWrapper
> handler
=
19 new PromiseNativeWrapper(std::move(holder
));
20 jsPromise
->AppendNativeHandler(handler
);
22 return mozPromise
.forget();
25 } // namespace mozilla