xpcom/base/nsIWeakReference.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/base/nsIWeakReference.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,67 @@
     1.4 +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.5 + *
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#include "nsISupports.idl"
    1.11 +
    1.12 +
    1.13 +/**
    1.14 + * An instance of |nsIWeakReference| is a proxy object that cooperates with
    1.15 + * its referent to give clients a non-owning, non-dangling reference.  Clients
    1.16 + * own the proxy, and should generally manage it with an |nsCOMPtr| (see the
    1.17 + * type |nsWeakPtr| for a |typedef| name that stands out) as they would any
    1.18 + * other XPCOM object.  The |QueryReferent| member function provides a
    1.19 + * (hopefully short-lived) owning reference on demand, through which clients
    1.20 + * can get useful access to the referent, while it still exists.
    1.21 + *
    1.22 + * @version 1.0
    1.23 + * @see nsISupportsWeakReference
    1.24 + * @see nsWeakReference
    1.25 + * @see nsWeakPtr
    1.26 + */
    1.27 +[scriptable, uuid(9188bc85-f92e-11d2-81ef-0060083a0bcf)]
    1.28 +interface nsIWeakReference : nsISupports
    1.29 +  {
    1.30 +    /**
    1.31 +     * |QueryReferent| queries the referent, if it exists, and like |QueryInterface|, produces
    1.32 +     * an owning reference to the desired interface.  It is designed to look and act exactly
    1.33 +     * like (a proxied) |QueryInterface|.  Don't hold on to the produced interface permanently;
    1.34 +     * that would defeat the purpose of using a non-owning |nsIWeakReference| in the first place.
    1.35 +     */
    1.36 +    void QueryReferent( in nsIIDRef uuid, [iid_is(uuid), retval] out nsQIResult result );
    1.37 +  };
    1.38 +
    1.39 +
    1.40 +/**
    1.41 + * |nsISupportsWeakReference| is a factory interface which produces appropriate
    1.42 + * instances of |nsIWeakReference|.  Weak references in this scheme can only be
    1.43 + * produced for objects that implement this interface.
    1.44 + *
    1.45 + * @version 1.0
    1.46 + * @see nsIWeakReference
    1.47 + * @see nsSupportsWeakReference
    1.48 + */
    1.49 +[scriptable, uuid(9188bc86-f92e-11d2-81ef-0060083a0bcf)]
    1.50 +interface nsISupportsWeakReference : nsISupports
    1.51 +  {
    1.52 +    /**
    1.53 +     * |GetWeakReference| produces an appropriate instance of |nsIWeakReference|.
    1.54 +     * As with all good XPCOM `getters', you own the resulting interface and should
    1.55 +     * manage it with an |nsCOMPtr|.
    1.56 +     *
    1.57 +     * @see nsIWeakReference
    1.58 +     * @see nsWeakPtr
    1.59 +     * @see nsCOMPtr
    1.60 +     */
    1.61 +    nsIWeakReference GetWeakReference();
    1.62 +  };
    1.63 +
    1.64 +
    1.65 +%{C++
    1.66 +#ifdef MOZILLA_INTERNAL_API
    1.67 +#include "nsIWeakReferenceUtils.h"
    1.68 +#endif
    1.69 +%}
    1.70 +

mercurial