Search completed in 1.27 seconds.
22 results for "nsisupportsweakreference":
Your results are loading. Please wait...
nsISupportsWeakReference
pports Last changed in Gecko 1.7 Method overview nsIWeakReference GetWeakReference(); Methods GetWeakReference() Produces an appropriate instance of nsIWeakReference. nsIWeakReference GetWeakReference(); Parameters None. Return value The resulting nsIWeakReference instance. Remarks The XPCOM glue library provides nsSupportsWeakReference, a canonical implementation of nsISupportsWeakReference. This interface was frozen for Gecko 0.9.9. See bug 48726 for details. From Gecko 2.0 interfaces are no longer frozen. See also nsIWeakReference nsSupportsWeakReference ...
nsSupportsWeakReference
To use this class, you must link your component or application against the XPCOM Glue library. Example code // Supporting weak references to a hypothetical implementation // of the nsIFoo interface... ...
...To use this class, you must link your component or application against the XPCOM Glue library. Example code // Supporting weak references to a hypothetical implementation // of the nsIFoo interface... ...
...s, you must link your component or application against the XPCOM Glue library. ...
...brary. Example code // Supporting weak references to a hypothetical implementation // of the nsIFoo interface... ...
Weak reference
in order to report events. The nsObservable doesn't want to keep the observers alive just to prevent a dangling pointer, however. So, instead of holding an owning reference to an nsIObserver, it holds a weak reference. The weak reference doesn't artificially extend the life of the observer, and yet, it can never dangle. The following assumes that any nsIObserver that is passed in also implements nsISupportsWeakReference. You can extrapolate from managing a single observer to managing a list of observers. class nsObservable { public: // ... nsresult AddObserver( nsIObserver* ); nsresult NotifyObservers( nsIMessage* ); // ... private: nsWeakPtr mObserver; // ...or imagine a list of observers here }; // ... nsresult nsObservable::AddObserver( nsIObserver* aObserver...
...it easy to go from the target object to the weak reference; and nsIWeakReference::QueryReferent gives you the same functionality as QueryInterface for getting back. Additionally, nsCOMPtr now supports the new key do_QueryReferent to simplify life even further. How do I make a class support weak references? In JavaScript, just make sure that your QueryInterface method returns your object for the nsISupportsWeakReference interface, and you're set; XPConnect does all the work for you. Just roll in nsSupportsWeakReference, a mix-in class that does all the work, and adjust your QueryInterface accordingly, e.g., //... #include "nsWeakReference.h" class nsFoo : public nsIFoo, ..., public nsSupportsWeakReference { ... }; // ...if you used the table macros to implement |QueryInterface|, add an entry NS_INTERFACE_M...
... work for you. Just roll in nsSupportsWeakReference, a mix-in class that does all the work, and adjust your QueryInterface accordingly, e.g., //... #include "nsWeakReference.h" class nsFoo : public nsIFoo, ..., public nsSupportsWeakReference { ... }; // ...if you used the table macros to implement |QueryInterface|, add an entry NS_INTERFACE_MAP_BEGIN(nsFoo) // ... NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) // ... NS_INTERFACE_MAP_END // ...if you used a |NS_IMPLE_QUERYINTERFACEn| macro, move up to the next higher one and add a term NS_IMPL_QUERYINTERFACEn+1( ...,nsISupportsWeakReference) // ...if you implemented |QueryInterface| by hand, add a clause NS_IMETHODIMP nsFoo::QueryInterface( REFNSIID aIID, void** aInstancePtr ) { // ... else if ( aIID.Equals(nsCOMTypeInfo<nsISupportsW...
..._QUERYINTERFACEn| macro, move up to the next higher one and add a term NS_IMPL_QUERYINTERFACEn+1( ...,nsISupportsWeakReference) // ...if you implemented |QueryInterface| by hand, add a clause NS_IMETHODIMP nsFoo::QueryInterface( REFNSIID aIID, void** aInstancePtr ) { // ... else if ( aIID.Equals(nsCOMTypeInfo<nsISupportsWeakReference>::GetIID()) ) *aInstancePr = NS_STATIC_CAST(nsISupportsWeakReference*, this); // ... } Alternatives This technique is useful, but in situations where you need this, there are two alternatives which you may want to consider: You might hold an owning reference, but arrange to Release it out-of-band; this must be before the destructor, which would otherwise never be called. You might hold a raw pointer (without AddRefing and Releaseing it), and avoid usi...
Progress Listeners - Archive of obsolete content
up a listener for all tabs, selected and not: Listening to events on all tabs. ...
...nction() { gBrowser.removeProgressListener(this); }, processNewURL: function(aURI) { if (aURI.spec == this.oldURL) return; // now we know the url is new... ...
Index
Mozilla › Tech › XPCOM › Index
985 data No summary! 986 toString No summary! 987 nsISupportsVoid Interfaces, Interfaces:Scriptable, XPCOM, XPCOM Interface Reference None. 988 data Documentation is now located at nsISupportsVoid.data(). 989 toString Documentation is now located at nsISupportsVoid.toString(). 990 nsISupportsWeakReference Interfaces, Interfaces:Scriptable, XPCOM, XPCOM API Reference, XPCOM Interface Reference Produces an appropriate instance of nsIWeakReference. 991 getWeakReference This content is now available at nsISupportsWeakReference.getWeakReference(). 992 nsISyncJPAKE Interfaces, Interfaces:Scriptable, NeedsContent Perform the final step of the JPAKE exc...
...sString Class Declaration 1224 nsString external NeedsContent, Reference, Reference(2), strings Class Declaration 1225 nsStringContainer (External) NeedsContent, Reference, Reference(2), strings Class Declaration 1226 nsSupportsWeakReference XPCOM, XPCOM API Reference Inherit from this C++ class to add canonical support for nsISupportsWeakReference. 1227 nsXPIDLCString Class Declaration 1228 nsXPIDLString Class Declaration 1229 XPCOM primitive XPCOM, XPCOM API Reference An XPCOM primitive is an XPCOM object that "boxes" a value of a primitive type. All XPCOM primitives are scriptable, and they all implement an XPCOM interface from the table below. 1230 XPCOM string ...
Component; nsIPrefBranch
anges to foo.bar.baz and foo.bar.bzip. aObserver The object to be notified if the preference changes. The structure of aObserver is any object with an observe function. See nsIObserver and here is a quick snippet: var myObserver = { observe: function(aSubject, aTopic, aData) { //do stuff here } } aHoldWeak true holds a weak reference to aObserver. The object must implement the nsISupportsWeakReference interface or this will fail. false holds a strong reference to aObserver. clearUserPref() Called to clear a user set value from a specific preference. This will, in effect, reset the value to the default value. If no default value exists the preference will cease to exist. Note: This method does nothing if the prefbranch it is called on is a default branch. void clearUserPref( in string aP...
...es which will cause memory leaks. These cycles generally occur because an object both registers itself as an observer (causing the branch to hold a reference to the observer) and holds a reference to the branch object for the purpose of getting/setting preference values. There are 3 approaches which have been implemented in an attempt to avoid these situations: The nsPrefBranch object supports nsISupportsWeakReference. Any consumer may hold a weak reference to it instead of a strong one. The nsPrefBranch object listens for xpcom-shutdown and frees all of the objects currently in its observer list. This ensures that long lived objects (services for example) will be freed correctly. The observer can request to be held as a weak reference when it is registered. This insures that shorter lived objects (say one t...
nsIPrefBranch2
s aDomain The preference on which to listen for changes. This can be the name of an entire branch to observe. For example holding the "root" prefbranch and calling addObserver("foo.bar.", ...) will observe changes to foo.bar.baz and foo.bar.bzip. aObserver The object to be notified if the preference changes. aHoldWeak true holds a weak reference to aObserver. The object must implement the nsISupportsWeakReference interface or this will fail. false holds a strong reference to aObserver. removeObserver() Remove a preference change observer. Note: You must call removeObserver method on the same nsIPrefBranch2 instance on which you called addObserver() method in order to remove aObserver; otherwise, the observer will not be removed. void removeObserver( in string aDomain, in nsIObserver aObse...
...es which will cause memory leaks. These cycles generally occur because an object both registers itself as an observer (causing the branch to hold a reference to the observer) and holds a reference to the branch object for the purpose of getting/setting preference values. There are 3 approaches which have been implemented in an attempt to avoid these situations: The nsPrefBranch object supports nsISupportsWeakReference. Any consumer may hold a weak reference to it instead of a strong one. The nsPrefBranch object listens for xpcom-shutdown and frees all of the objects currently in its observer list. This ensures that long lived objects (services for example) will be freed correctly. The observer can request to be held as a weak reference when it is registered. This insures that shorter lived objects (say one t...
XUL Questions and Answers - Archive of obsolete content
rowser" to a listener object browserObject.addProgressListener( listObj, Components.interfaces.nsIWebProgress.NOTIFY_STATE_WINDOW ); // Remember to define the object, something like this: listObj = new Object(); listObj.wpl = Components.interfaces.nsIWebProgressListener; listObj.QueryInterface = function(aIID) { if (aIID.equals(listObj.wpl) || aIID.equals(Components.interfaces.nsISupportsWeakReference) || aIID.equals(Components.interfaces.nsISupports)) return this; throw Components.results.NS_NOINTERFACE; } listObj.onStateChange = function(aProgress, aRequest, aFlag, aStatus) { if (aFlag & listObj.wpl.STATE_START) { // This fires when the load event is initiated } else { if (aFlag & listObj.wpl.STATE_STOP) { if ( aFlag & listObj.wpl.STATE_IS_WINDOW ) { // ...
XULBrowserWindow - Archive of obsolete content
See the linked interfaces for the definition of the implemented methods. ...
JavaScript Tips
ds expect an object that implements several interfaces thus requiring you to write a QueryInterface method. However, in JavaScript this is quite simple even in the case of a weak reference which in C++ requires a helper class: var weakObserver = { QueryInterface: function QueryInterface(aIID) { if (aIID.equals(Components.interfaces.nsIObserver) || aIID.equals(Components.interfaces.nsISupportsWeakReference) || aIID.equals(Components.interfaces.nsISupports)) return this; throw Components.results.NS_NOINTERFACE; }, observe: function observe(aSubject, aTopic, aState) { } } When declaring XPCOM methods, try to use the same names for method parameters as are used in the interface definition. DOM elements DOM elements are just XPCOM objects with some of the interfaces pr...
XPCOM glue classes
ting. ...
nsINavBookmarksService
"Separator". TYPE_DYNAMIC_CONTAINER 4 This is an index for type "Dynamic Container". Dynamic containers were removed in Gecko 11, but the type index remains to prevent reuse. Methods addObserver() This method adds a bookmark observer. If ownsWeak is false, the bookmark service will keep an owning reference to the observer. If ownsWeak is true, then aObserver must implement nsISupportsWeakReference, and the bookmark service will keep a weak reference to the observer. void addObserver( in nsINavBookmarkObserver observer, in boolean ownsWeak ); Parameters observer The bookmark observer to be added. ownsWeak The owning reference state (boolean). beginUpdateBatch() Obsolete since Gecko 1.9 (Firefox 3) Causes observers to be notified of a beginUpdateBatc...
nsINavHistoryResult
); Parameters aObserver An object that implements the nsINavHistoryResultObserver interface, which will receive notifications of changes on the result. aOwnsWeak If false, the result will keep an owning reference to the observer, which must be removed by calling removeObserver(). If true, the result will keep a weak reference to the observer, which must implement the nsISupportsWeakReference interface. removeObserver() Removes an observer that was added by a previous call to addObserver(). void removeObserver( in nsINavHistoryResultObserver aObserver ); Parameters aObserver The observer to remove. See also nsINavHistoryResultObserver nsINavHistoryContainerResultNode ...
nsINavHistoryService
ryOptions options ); Parameters aQueries The queries object. aQueryCount The count queries. options The options object. Return value Returns the converted query into an equivalent string query. addObserver() This method adds a history observer. If ownsWeak is false, the history service will keep an owning reference to the observer. If ownsWeak is true, then aObserver must implement nsISupportsWeakReference, and the history service will keep a weak reference to the observer. void addObserver( in nsINavHistoryObserver observer, in boolean ownsWeak ); Parameters observer The history observer to be added. ownsWeak The owning reference state (boolean). removeObserver() This method removes a history observer. void removeObserver( in nsINavHistoryObserver observer ); Parameters obs...
nsIObserverService
e nsIObserver for a JavaScript example. void addObserver( in nsIObserver anObserver, in string aTopic, in boolean ownsWeak ); Parameters anObserver The nsIObserver object which will receive notifications. aTopic The notification topic or subject. ownsWeak If set to false, the nsIObserverService will hold a strong reference to anObserver. If set to true and anObserver supports the nsISupportsWeakReference interface, a weak reference will be held. Otherwise an error will be returned. (In most cases, you should use false.) enumerateObservers() Called to enumerate all observers registered for a particular topic. nsISimpleEnumerator enumerateObservers( in string aTopic ); Parameters aTopic The notification topic or subject. Return value Returns an enumeration of all registered listeners...
getWeakReference
...
nsIWeakReference
; Parameters uuid The UUID of the requested interface. ...
nsIWebBrowser
he visible tab. Defaults to true. For optimal performance, set it to false when appropriate. parentURIContentListener nsIURIContentListener URI content listener parent. The embedder may set this property to their own implementation if they intend to override or prevent how certain kinds of content are loaded. Note: If this attribute is set to an object that implements nsISupportsWeakReference, the implementation should get the nsIWeakReference and hold that. Otherwise, the implementation should not refcount this interface; it should assume that a non null value is always valid. In that case, the embedder should explicitly set this value back to null if the parent content listener is destroyed before the browser object. Methods addWebBrowserListener() Registers a listener of the ...
nsIWebProgress
Y_ALL 0x000000ff <= Gecko 1.8.1 0x000001ff > Gecko 1.8.1 This flag enables all notifications. Methods addProgressListener() Registers a listener to receive web progress events. void addProgressListener( in nsIWebProgressListener aListener, in unsigned long aNotifyMask ); Parameters aListener The listener interface to be called when a progress event occurs. This object must also implement nsISupportsWeakReference. aNotifyMask The types of notifications to receive. Exceptions thrown NS_ERROR_INVALID_ARG Indicates that aListener was either null or that it does not support weak references. NS_ERROR_FAILURE Indicates that aListener was already registered. removeProgressListener() Removes a previously registered listener of progress events. void removeProgressListener( in nsIWebProgressListener aListener ...
nsIWebProgressListener
indow. ...
XPCOM Interface Reference
leSheetServicensISupportsnsISupports proxiesnsISupportsArraynsISupportsCStringnsISupportsCharnsISupportsDoublensISupportsFloatnsISupportsIDnsISupportsInterfacePointernsISupportsPRBoolnsISupportsPRInt16nsISupportsPRInt32nsISupportsPRInt64nsISupportsPRTimensISupportsPRUint8nsISupportsPRUint16nsISupportsPRUint32nsISupportsPRUint64nsISupportsPrimitivensISupportsPrioritynsISupportsStringnsISupportsVoidnsISupportsWeakReferencensISyncJPAKEnsISyncMessageSendernsITXTToHTMLConvnsITaggingServicensITaskbarPreviewnsITaskbarPreviewButtonnsITaskbarPreviewControllernsITaskbarProgressnsITaskbarTabPreviewnsITaskbarWindowPreviewnsITelemetrynsITextInputProcessornsITextInputProcessorCallbacknsITextInputProcessorNotificationnsIThreadnsIThreadEventFilternsIThreadInternalnsIThreadManagernsIThreadObservernsIThreadPoolnsIThreadPoolListene...
XPCOM Interface Reference by grouping
har nsISupportsDouble nsISupportsFloat nsISupportsID nsISupportsInterfacePointer nsISupportsPRBool nsISupportsPrimitive nsISupportsPRInt16 nsISupportsPRInt32 nsISupportsPRInt64 nsISupportsPriority nsISupportsPRTime nsISupportsPRUint16 nsISupportsPRUint32 nsISupportsPRUint64 nsISupportsPRUint8 nsISupportsString nsISupportsVoid nsISupportsWeakReference nsIVariant DO NOT USE nsIEnumerator nsIInProcessContentFrameMessageManager nsIScriptableIO nsIXPCScriptable Future nsIXMLHttpRequestUpload Obsolete nsIXmlRpcClient nsIXmlRpcFault Security Auth nsIAuthModule nsIAuthPrompt nsIAuthPromptProvider nsIAuthPromptWrapper nsIAsyncVerif...