Bug 1292323 - Implement JNI thread checking and dispatching; r=snorp
Implement checking the calling thread of a JNI call based on the calledFrom attribute set in WrapForJNI. Also implement automatic call dispatching based on the dispatchTo attribute set in WrapForJNI. This eliminates the use of UsesNativeCallProxy and UsesGeckoThreadProxy.
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "AndroidBridge.h"
|
||||
#include "GeneratedJNIWrappers.h"
|
||||
#include "nsAppShell.h"
|
||||
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
#include "nsExceptionHandler.h"
|
||||
@@ -143,7 +144,7 @@ bool HandleUncaughtException(JNIEnv* aEnv)
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef MOZ_CHECK_JNI
|
||||
aEnv->ExceptionDescribe();
|
||||
#endif
|
||||
|
||||
@@ -210,5 +211,26 @@ jclass GetClassGlobalRef(JNIEnv* aEnv, const char* aClassName)
|
||||
return AndroidBridge::GetClassGlobalRef(aEnv, aClassName);
|
||||
}
|
||||
|
||||
|
||||
void DispatchToGeckoThread(UniquePtr<AbstractCall>&& aCall)
|
||||
{
|
||||
class AbstractCallEvent : public nsAppShell::Event
|
||||
{
|
||||
UniquePtr<AbstractCall> mCall;
|
||||
|
||||
public:
|
||||
AbstractCallEvent(UniquePtr<AbstractCall>&& aCall)
|
||||
: mCall(Move(aCall))
|
||||
{}
|
||||
|
||||
void Run() override
|
||||
{
|
||||
(*mCall)();
|
||||
}
|
||||
};
|
||||
|
||||
nsAppShell::PostEvent(MakeUnique<AbstractCallEvent>(Move(aCall)));
|
||||
}
|
||||
|
||||
} // jni
|
||||
} // mozilla
|
||||
|
||||
Reference in New Issue
Block a user