michael@0: /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: michael@0: /** michael@0: * An instance of |nsIWeakReference| is a proxy object that cooperates with michael@0: * its referent to give clients a non-owning, non-dangling reference. Clients michael@0: * own the proxy, and should generally manage it with an |nsCOMPtr| (see the michael@0: * type |nsWeakPtr| for a |typedef| name that stands out) as they would any michael@0: * other XPCOM object. The |QueryReferent| member function provides a michael@0: * (hopefully short-lived) owning reference on demand, through which clients michael@0: * can get useful access to the referent, while it still exists. michael@0: * michael@0: * @version 1.0 michael@0: * @see nsISupportsWeakReference michael@0: * @see nsWeakReference michael@0: * @see nsWeakPtr michael@0: */ michael@0: [scriptable, uuid(9188bc85-f92e-11d2-81ef-0060083a0bcf)] michael@0: interface nsIWeakReference : nsISupports michael@0: { michael@0: /** michael@0: * |QueryReferent| queries the referent, if it exists, and like |QueryInterface|, produces michael@0: * an owning reference to the desired interface. It is designed to look and act exactly michael@0: * like (a proxied) |QueryInterface|. Don't hold on to the produced interface permanently; michael@0: * that would defeat the purpose of using a non-owning |nsIWeakReference| in the first place. michael@0: */ michael@0: void QueryReferent( in nsIIDRef uuid, [iid_is(uuid), retval] out nsQIResult result ); michael@0: }; michael@0: michael@0: michael@0: /** michael@0: * |nsISupportsWeakReference| is a factory interface which produces appropriate michael@0: * instances of |nsIWeakReference|. Weak references in this scheme can only be michael@0: * produced for objects that implement this interface. michael@0: * michael@0: * @version 1.0 michael@0: * @see nsIWeakReference michael@0: * @see nsSupportsWeakReference michael@0: */ michael@0: [scriptable, uuid(9188bc86-f92e-11d2-81ef-0060083a0bcf)] michael@0: interface nsISupportsWeakReference : nsISupports michael@0: { michael@0: /** michael@0: * |GetWeakReference| produces an appropriate instance of |nsIWeakReference|. michael@0: * As with all good XPCOM `getters', you own the resulting interface and should michael@0: * manage it with an |nsCOMPtr|. michael@0: * michael@0: * @see nsIWeakReference michael@0: * @see nsWeakPtr michael@0: * @see nsCOMPtr michael@0: */ michael@0: nsIWeakReference GetWeakReference(); michael@0: }; michael@0: michael@0: michael@0: %{C++ michael@0: #ifdef MOZILLA_INTERNAL_API michael@0: #include "nsIWeakReferenceUtils.h" michael@0: #endif michael@0: %} michael@0: