Bug 1382861 - 1. Replace jni::AbstractCall with nsIRunnable; r=esawin

The native binding code used `jni::AbstractCall` as the interface
between `ProxyNativeCall` and `DispatchToGeckoPriorityQueue`. However,
we already make use of `nsIRunnable` for dispatching to the XPCOM queue,
so we should just use `nsIRunnable` for the priority queue as well.

MozReview-Commit-ID: KmuNMZZkXX3
This commit is contained in:
Jim Chen
2017-07-25 17:25:58 -04:00
parent 56082c0320
commit 75e3ec1d7a
3 changed files with 23 additions and 30 deletions

View File

@@ -288,24 +288,17 @@ jclass GetClassRef(JNIEnv* aEnv, const char* aClassName)
return nullptr;
}
void DispatchToGeckoPriorityQueue(UniquePtr<AbstractCall>&& aCall)
void DispatchToGeckoPriorityQueue(already_AddRefed<nsIRunnable> aCall)
{
class AbstractCallEvent : public nsAppShell::Event
class RunnableEvent : public nsAppShell::Event
{
UniquePtr<AbstractCall> mCall;
nsCOMPtr<nsIRunnable> mCall;
public:
AbstractCallEvent(UniquePtr<AbstractCall>&& aCall)
: mCall(Move(aCall))
{}
void Run() override
{
(*mCall)();
}
RunnableEvent(already_AddRefed<nsIRunnable> aCall) : mCall(aCall) {}
void Run() override { NS_ENSURE_SUCCESS_VOID(mCall->Run()); }
};
nsAppShell::PostEvent(MakeUnique<AbstractCallEvent>(Move(aCall)));
nsAppShell::PostEvent(MakeUnique<RunnableEvent>(Move(aCall)));
}
bool IsFennec()