1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include
"nsISupports.idl"
9 interface nsISimpleEnumerator
;
14 * Service allows a client listener (nsIObserver) to register and unregister for
15 * notifications of specific string referenced topic. Service also provides a
16 * way to notify registered listeners and a way to enumerate registered client
20 [scriptable
, builtinclass
, uuid(D07F5192
-E3D1
-11d2
-8ACD
-00105A1B8860
)]
21 interface nsIObserverService
: nsISupports
27 * Registers a given listener for a notifications regarding the specified
30 * @param anObserve : The interface pointer which will receive notifications.
31 * @param aTopic : The notification topic or subject.
32 * @param ownsWeak : If set to false, the nsIObserverService will hold a
33 * strong reference to |anObserver|. If set to true and
34 * |anObserver| supports the nsIWeakReference interface,
35 * a weak reference will be held. Otherwise an error will be
38 void addObserver
( in nsIObserver anObserver
, in string aTopic
,
39 [optional] in boolean ownsWeak
);
44 * Unregisters a given listener from notifications regarding the specified
47 * @param anObserver : The interface pointer which will stop recieving
49 * @param aTopic : The notification topic or subject.
51 void removeObserver
( in nsIObserver anObserver
, in string aTopic
);
56 * Notifies all registered listeners of the given topic.
57 * Must not be used with shutdown topics (will assert
58 * on the parent process).
60 * @param aSubject : Notification specific interface pointer.
61 * @param aTopic : The notification topic or subject.
62 * @param someData : Notification specific wide string.
64 void notifyObservers
( in nsISupports aSubject
,
66 [optional] in wstring someData
);
71 * Checks to see if there are registered listeners for the given topic.
73 * Implemented in "nsObserverService.cpp".
75 * @param aTopic : The notification topic or subject.
76 * @param aFound : An out parameter; True if there are registered observers,
79 [noscript
, notxpcom
, nostdcall
] boolean hasObservers
(in string aTopic
);
83 * notifyWhenScriptSafe
85 * Notifies all registered listeners of the given topic once it is safe to
88 * Implemented in "nsObserverService.cpp".
90 * @param aSubject : Notification specific interface pointer.
91 * @param aTopic : The notification topic or subject.
92 * @param someData : Notification specific wide string.
94 nsresult NotifyWhenScriptSafe
(nsISupports
* aSubject
,
96 const char16_t
* aData
= nullptr
);
102 * Returns an enumeration of all registered listeners.
104 * @param aTopic : The notification topic or subject.
106 nsISimpleEnumerator enumerateObservers
( in string aTopic
);