mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1063120 - Add synchronous method to notify Gecko observer; r=snorp
This commit is contained in:
parent
f058f40bb4
commit
dffe40277e
@ -447,6 +447,9 @@ public class GeckoAppShell
|
||||
// Tell the Gecko event loop that an event is available.
|
||||
public static native void notifyGeckoOfEvent(GeckoEvent event);
|
||||
|
||||
// Synchronously notify a Gecko observer; must be called from Gecko thread.
|
||||
public static native void notifyGeckoObservers(String subject, String data);
|
||||
|
||||
/*
|
||||
* The Gecko-side API: API methods that Gecko calls
|
||||
*/
|
||||
|
@ -362,6 +362,25 @@ Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoOfEvent(JNIEnv * arg0, jclass ar
|
||||
|
||||
#ifdef JNI_STUBS
|
||||
|
||||
typedef void (*Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoObservers_t)(JNIEnv *, jclass, jstring, jstring);
|
||||
static Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoObservers_t f_Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoObservers;
|
||||
extern "C" NS_EXPORT void JNICALL
|
||||
Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoObservers(JNIEnv * arg0, jclass arg1, jstring arg2, jstring arg3) {
|
||||
if (!f_Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoObservers) {
|
||||
arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
|
||||
"JNI Function called before it was loaded");
|
||||
return ;
|
||||
}
|
||||
f_Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoObservers(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef JNI_BINDINGS
|
||||
xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoObservers", &f_Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoObservers);
|
||||
#endif
|
||||
|
||||
#ifdef JNI_STUBS
|
||||
|
||||
typedef jlong (*Java_org_mozilla_gecko_GeckoAppShell_runUiThreadCallback_t)(JNIEnv *, jclass);
|
||||
static Java_org_mozilla_gecko_GeckoAppShell_runUiThreadCallback_t f_Java_org_mozilla_gecko_GeckoAppShell_runUiThreadCallback;
|
||||
extern "C" NS_EXPORT jlong JNICALL
|
||||
|
@ -78,6 +78,29 @@ Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoOfEvent(JNIEnv *jenv, jclass jc,
|
||||
nsAppShell::gAppShell->PostEvent(AndroidGeckoEvent::MakeFromJavaObject(jenv, event));
|
||||
}
|
||||
|
||||
NS_EXPORT void JNICALL
|
||||
Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoObservers(JNIEnv *aEnv, jclass,
|
||||
jstring aTopic, jstring aData)
|
||||
{
|
||||
if (!NS_IsMainThread()) {
|
||||
AndroidBridge::ThrowException(aEnv,
|
||||
"java/lang/IllegalThreadStateException", "Not on Gecko main thread");
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> obsServ =
|
||||
mozilla::services::GetObserverService();
|
||||
if (!obsServ) {
|
||||
AndroidBridge::ThrowException(aEnv,
|
||||
"java/lang/IllegalStateException", "No observer service");
|
||||
return;
|
||||
}
|
||||
|
||||
const nsJNICString topic(aTopic, aEnv);
|
||||
const nsJNIString data(aData, aEnv);
|
||||
obsServ->NotifyObservers(nullptr, topic.get(), data.get());
|
||||
}
|
||||
|
||||
NS_EXPORT void JNICALL
|
||||
Java_org_mozilla_gecko_GeckoAppShell_processNextNativeEvent(JNIEnv *jenv, jclass, jboolean mayWait)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user