Bug 1869043 assert that graph set access is main thread only r=padenot
[gecko.git] / xpcom / ds / nsIObserverService.idl
blob5ca51d5d449a7101906e74e6bf7b17cfd9d76870
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"
8 interface nsIObserver;
9 interface nsISimpleEnumerator;
11 /**
12 * nsIObserverService
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
17 * listeners.
20 [scriptable, builtinclass, uuid(D07F5192-E3D1-11d2-8ACD-00105A1B8860)]
21 interface nsIObserverService : nsISupports
24 /**
25 * AddObserver
27 * Registers a given listener for a notifications regarding the specified
28 * topic.
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
36 * returned.
38 void addObserver( in nsIObserver anObserver, in string aTopic,
39 [optional] in boolean ownsWeak);
41 /**
42 * removeObserver
44 * Unregisters a given listener from notifications regarding the specified
45 * topic.
47 * @param anObserver : The interface pointer which will stop recieving
48 * notifications.
49 * @param aTopic : The notification topic or subject.
51 void removeObserver( in nsIObserver anObserver, in string aTopic );
53 /**
54 * notifyObservers
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,
65 in string aTopic,
66 [optional] in wstring someData );
68 /**
69 * hasObservers
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,
77 * False otherwise.
79 [noscript, notxpcom, nostdcall] boolean hasObservers(in string aTopic);
81 %{C++
82 /**
83 * notifyWhenScriptSafe
85 * Notifies all registered listeners of the given topic once it is safe to
86 * run script.
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,
95 const char* aTopic,
96 const char16_t* aData = nullptr);
99 /**
100 * enumerateObservers
102 * Returns an enumeration of all registered listeners.
104 * @param aTopic : The notification topic or subject.
106 nsISimpleEnumerator enumerateObservers( in string aTopic );