Bug 1753919 - Allow non-copy C++ object for GeckoResult paramenter. r=geckoview-reviewers,bholley,agi

Actually, we require that the parameter of promise by `GeckoResult` has copy
constructor. We should allow non-copy C++ class for this parameter.

Differential Revision: https://phabricator.services.mozilla.com/D137974
This commit is contained in:
Makoto Kato 2022-02-09 06:59:52 +00:00
parent 926307a1d7
commit b2edc6930a
2 changed files with 5 additions and 3 deletions

View File

@ -34,7 +34,7 @@ class GeckoResultCallback final
OuterCallback outerCallback =
[inner{std::move(aInnerCallback)}](mozilla::jni::Object::Param aParam) {
ArgType converted = Java2Native<ArgType>(aParam);
inner(converted);
inner(std::move(converted));
};
auto native = MakeUnique<GeckoResultCallback>(std::move(outerCallback));
Base::AttachNative(java, std::move(native));

View File

@ -1087,9 +1087,11 @@ class MozPromise : public MozPromiseBase {
using jni::GeckoResultCallback;
RefPtr<Private> p = new Private("GeckoResult Glue", false);
auto resolve = GeckoResultCallback::CreateAndAttach<ResolveValueType>(
[p](ResolveValueType aArg) { p->Resolve(aArg, __func__); });
[p](ResolveValueType&& aArg) {
p->Resolve(MaybeMove(aArg), __func__);
});
auto reject = GeckoResultCallback::CreateAndAttach<RejectValueType>(
[p](RejectValueType aArg) { p->Reject(aArg, __func__); });
[p](RejectValueType&& aArg) { p->Reject(MaybeMove(aArg), __func__); });
aGeckoResult->NativeThen(resolve, reject);
return p;
}