зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1567341 - Release EventDispatcher listeners on xpcom-shutdown. r=esawin
Differential Revision: https://phabricator.services.mozilla.com/D106204
This commit is contained in:
Родитель
7a469fd10f
Коммит
5a745c2b72
|
@ -213,6 +213,7 @@ class GeckoViewStartup {
|
|||
"GeckoView:SetLocale",
|
||||
]);
|
||||
|
||||
Services.obs.addObserver(this, "xpcom-shutdown");
|
||||
Services.obs.notifyObservers(null, "geckoview-startup-complete");
|
||||
break;
|
||||
}
|
||||
|
@ -224,6 +225,16 @@ class GeckoViewStartup {
|
|||
Services.startup.trackStartupCrashEnd();
|
||||
break;
|
||||
}
|
||||
case "xpcom-shutdown": {
|
||||
Services.obs.removeObserver(this, "xpcom-shutdown");
|
||||
EventDispatcher.instance.unregisterListener(this, [
|
||||
"GeckoView:ResetUserPrefs",
|
||||
"GeckoView:SetDefaultPrefs",
|
||||
"GeckoView:SetLocale",
|
||||
]);
|
||||
EventDispatcher.instance.shutdown();
|
||||
delete EventDispatcher.instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ public final class EventDispatcher extends JNIObject {
|
|||
@WrapForJNI @Override // JNIObject
|
||||
protected native void disposeNative();
|
||||
|
||||
@WrapForJNI(stubName = "Shutdown")
|
||||
@WrapForJNI(stubName = "ShutdownFromJava", dispatchTo = "gecko")
|
||||
protected native void shutdownNative();
|
||||
|
||||
@WrapForJNI private static final int DETACHED = 0;
|
||||
|
|
|
@ -151,6 +151,10 @@ DispatcherDelegate.prototype = {
|
|||
this._replies.clear();
|
||||
},
|
||||
|
||||
shutdown() {
|
||||
this._dispatcher.shutdown();
|
||||
},
|
||||
|
||||
receiveMessage(aMsg) {
|
||||
const { uuid, type } = aMsg.data;
|
||||
const reply = this._replies.get(uuid);
|
||||
|
@ -282,4 +286,12 @@ var EventDispatcher = {
|
|||
if (IS_PARENT_PROCESS) {
|
||||
Services.mm.addMessageListener("GeckoView:Messaging", EventDispatcher);
|
||||
Services.ppmm.addMessageListener("GeckoView:Messaging", EventDispatcher);
|
||||
|
||||
function xpcomShutdown() {
|
||||
Services.mm.removeMessageListener("GeckoView:Messaging", EventDispatcher);
|
||||
Services.ppmm.removeMessageListener("GeckoView:Messaging", EventDispatcher);
|
||||
Services.obs.removeObserver(xpcomShutdown, "xpcom-shutdown");
|
||||
}
|
||||
|
||||
Services.obs.addObserver(xpcomShutdown, "xpcom-shutdown");
|
||||
}
|
||||
|
|
|
@ -949,9 +949,13 @@ void EventDispatcher::Attach(java::EventDispatcher::Param aDispatcher,
|
|||
dispatcher->SetAttachedToGecko(java::EventDispatcher::ATTACHED);
|
||||
}
|
||||
|
||||
void EventDispatcher::Shutdown() {
|
||||
NS_IMETHODIMP
|
||||
EventDispatcher::Shutdown() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
mDispatcher = nullptr;
|
||||
mDOMWindow = nullptr;
|
||||
mListenersMap.Clear();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void EventDispatcher::Detach() {
|
||||
|
|
|
@ -65,7 +65,7 @@ class EventDispatcher final
|
|||
|
||||
virtual ~EventDispatcher() {}
|
||||
|
||||
void Shutdown();
|
||||
void ShutdownFromJava() { Shutdown(); }
|
||||
|
||||
struct ListenersList {
|
||||
nsCOMArray<nsIAndroidEventListener> listeners{/* count */ 1};
|
||||
|
|
|
@ -43,6 +43,7 @@ interface nsIAndroidEventDispatcher : nsISupports
|
|||
[implicit_jscontext]
|
||||
void unregisterListener(in nsIAndroidEventListener listener,
|
||||
in jsval events);
|
||||
void shutdown();
|
||||
};
|
||||
|
||||
[scriptable, uuid(60a78a94-6117-432f-9d49-304913a931c5)]
|
||||
|
|
Загрузка…
Ссылка в новой задаче