1
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3
* The contents of this file are subject to the Mozilla Public
4
* License Version 1.1 (the "License"); you may not use this file
5
* except in compliance with the License. You may obtain a copy of
6
* the License at http://www.mozilla.org/MPL/
8
* Software distributed under the License is distributed on an "AS
9
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10
* implied. See the License for the specific language governing
11
* rights and limitations under the License.
13
* The Original Code is the Mozilla browser.
15
* The Initial Developer of the Original Code is Netscape
16
* Communications, Inc. Portions created by Netscape are
17
* Copyright (C) 1999, Mozilla. All Rights Reserved.
20
* Scott Collins <scc@mozilla.org>
23
* Pierre Phaneuf <pp@ludusdesign.com>
26
#include "nsISupports.idl"
30
* An instance of |nsIWeakReference| is a proxy object that cooperates with
31
* its referent to give clients a non-owning, non-dangling reference. Clients
32
* own the proxy, and should generally manage it with an |nsCOMPtr| (see the
33
* type |nsWeakPtr| for a |typedef| name that stands out) as they would any
34
* other XPCOM object. The |QueryReferent| member function provides a
35
* (hopefully short-lived) owning reference on demand, through which clients
36
* can get useful access to the referent, while it still exists.
40
* @see nsISupportsWeakReference
41
* @see nsWeakReference
44
[scriptable, uuid(9188bc85-f92e-11d2-81ef-0060083a0bcf)]
45
interface nsIWeakReference : nsISupports
48
* |QueryReferent| queries the referent, if it exists, and like |QueryInterface|, produces
49
* an owning reference to the desired interface. It is designed to look and act exactly
50
* like (a proxied) |QueryInterface|. Don't hold on to the produced interface permanently;
51
* that would defeat the purpose of using a non-owning |nsIWeakReference| in the first place.
53
void QueryReferent( in nsIIDRef uuid, [iid_is(uuid), retval] out nsQIResult result );
58
* |nsISupportsWeakReference| is a factory interface which produces appropriate
59
* instances of |nsIWeakReference|. Weak references in this scheme can only be
60
* produced for objects that implement this interface.
64
* @see nsIWeakReference
65
* @see nsSupportsWeakReference
67
[scriptable, uuid(9188bc86-f92e-11d2-81ef-0060083a0bcf)]
68
interface nsISupportsWeakReference : nsISupports
71
* |GetWeakReference| produces an appropriate instance of |nsIWeakReference|.
72
* As with all good XPCOM `getters', you own the resulting interface and should
73
* manage it with an |nsCOMPtr|.
75
* @see nsIWeakReference
79
nsIWeakReference GetWeakReference();
84
#ifndef MOZILLA_STRICT_API
85
#include "nsIWeakReferenceUtils.h"