forked from mirrors/gecko-dev
The goal here is to ensure we can always rely on `AppShutdown::GetShutdownPhase` to be in sync with the "real" application status, mainly this was needed for xpcshell tests to not break if we add assertions on our shutdown state on some global singletons. We keep the existing observer notification topics but force them (on the parent process) to be issued through the new `advanceShutdownPhase` function of the startup service using the `ShutdownPhase` enum. This way we can synchronize `AppShutdown`'s internal status accordingly. Some further notes: # The `MOZ_ASSERT(AppShutdown::IsNoOrLegalShutdownTopic(aTopic));` in `NotifyObservers` helped a lot to identify missing cases. I think we should keep it in order to stay safe. # Introducing the `cenum IDLShutdownPhase` helps to keep the knowledge about the mapping from shutdown phases to observer topics exclusively inside AppShutdown.cpp. Still callers must know what they do in order to choose a proper phase, of course. # However we must be aware that `AppShutdown` this way can be kept in sync with the shutdown notifications only in the parent process and that `GetCurrentShutdownPhase` might not give the correct result in child processes. We might want to file a follow up bug that adds some asserts to avoid improper use of `AppShutdown` functions in child processes (but I do not want to make this patch bigger as needed to solve the blocking dependency for bug 1697972). # The socket process is one example of a child process that "overloads" shutdown topics. I was wondering if it is the right call to use the very same topic names here to request shutdown to the socket process or if it should have its own topics. Those topics triggered the assert and thus I had to disable it for child processes, for now. # This goes together with the more general approach to define process type specific shutdown phases (and hence mappings to topics) as drafted very roughly in bug 1697745. # This patch seemed to trigger a known intermittent more often, thus the change here in `ServiceWorkerManager`. Differential Revision: https://phabricator.services.mozilla.com/D124350
98 lines
3.2 KiB
Text
98 lines
3.2 KiB
Text
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
interface nsIObserver;
|
|
interface nsISimpleEnumerator;
|
|
|
|
/**
|
|
* nsIObserverService
|
|
*
|
|
* Service allows a client listener (nsIObserver) to register and unregister for
|
|
* notifications of specific string referenced topic. Service also provides a
|
|
* way to notify registered listeners and a way to enumerate registered client
|
|
* listeners.
|
|
*/
|
|
|
|
[scriptable, builtinclass, uuid(D07F5192-E3D1-11d2-8ACD-00105A1B8860)]
|
|
interface nsIObserverService : nsISupports
|
|
{
|
|
|
|
/**
|
|
* AddObserver
|
|
*
|
|
* Registers a given listener for a notifications regarding the specified
|
|
* topic.
|
|
*
|
|
* @param anObserve : The interface pointer which will receive notifications.
|
|
* @param aTopic : The notification topic or subject.
|
|
* @param ownsWeak : If set to false, the nsIObserverService will hold a
|
|
* strong reference to |anObserver|. If set to true and
|
|
* |anObserver| supports the nsIWeakReference interface,
|
|
* a weak reference will be held. Otherwise an error will be
|
|
* returned.
|
|
*/
|
|
void addObserver( in nsIObserver anObserver, in string aTopic,
|
|
[optional] in boolean ownsWeak);
|
|
|
|
/**
|
|
* removeObserver
|
|
*
|
|
* Unregisters a given listener from notifications regarding the specified
|
|
* topic.
|
|
*
|
|
* @param anObserver : The interface pointer which will stop recieving
|
|
* notifications.
|
|
* @param aTopic : The notification topic or subject.
|
|
*/
|
|
void removeObserver( in nsIObserver anObserver, in string aTopic );
|
|
|
|
/**
|
|
* notifyObservers
|
|
*
|
|
* Notifies all registered listeners of the given topic.
|
|
* Must not be used with shutdown topics (will assert
|
|
* on the parent process).
|
|
*
|
|
* @param aSubject : Notification specific interface pointer.
|
|
* @param aTopic : The notification topic or subject.
|
|
* @param someData : Notification specific wide string.
|
|
*/
|
|
void notifyObservers( in nsISupports aSubject,
|
|
in string aTopic,
|
|
[optional] in wstring someData );
|
|
|
|
%{C++
|
|
/**
|
|
* notifyWhenScriptSafe
|
|
*
|
|
* Notifies all registered listeners of the given topic once it is safe to
|
|
* run script.
|
|
*
|
|
* Implemented in "nsObserverService.cpp".
|
|
*
|
|
* @param aSubject : Notification specific interface pointer.
|
|
* @param aTopic : The notification topic or subject.
|
|
* @param someData : Notification specific wide string.
|
|
*/
|
|
nsresult NotifyWhenScriptSafe(nsISupports* aSubject,
|
|
const char* aTopic,
|
|
const char16_t* aData = nullptr);
|
|
%}
|
|
|
|
/**
|
|
* enumerateObservers
|
|
*
|
|
* Returns an enumeration of all registered listeners.
|
|
*
|
|
* @param aTopic : The notification topic or subject.
|
|
*/
|
|
nsISimpleEnumerator enumerateObservers( in string aTopic );
|
|
|
|
|
|
};
|
|
|
|
|