OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * DO NOT EDIT. THIS FILE IS GENERATED FROM c:/builds/tinderbox/XR-Mozilla1.8.0
-Release/WINNT_5.2_Depend/mozilla/modules/libpref/public/nsIPrefBranch2.idl |
| 3 */ |
| 4 |
| 5 #ifndef __gen_nsIPrefBranch2_h__ |
| 6 #define __gen_nsIPrefBranch2_h__ |
| 7 |
| 8 |
| 9 #ifndef __gen_nsIPrefBranch_h__ |
| 10 #include "nsIPrefBranch.h" |
| 11 #endif |
| 12 |
| 13 /* For IDL files that don't want to include root IDL files. */ |
| 14 #ifndef NS_NO_VTABLE |
| 15 #define NS_NO_VTABLE |
| 16 #endif |
| 17 class nsIObserver; /* forward declaration */ |
| 18 |
| 19 |
| 20 /* starting interface: nsIPrefBranch2 */ |
| 21 #define NS_IPREFBRANCH2_IID_STR "74567534-eb94-4b1c-8f45-389643bfc555" |
| 22 |
| 23 #define NS_IPREFBRANCH2_IID \ |
| 24 {0x74567534, 0xeb94, 0x4b1c, \ |
| 25 { 0x8f, 0x45, 0x38, 0x96, 0x43, 0xbf, 0xc5, 0x55 }} |
| 26 |
| 27 /** |
| 28 * nsIPrefBranch2 allows clients to observe changes to pref values. |
| 29 * |
| 30 * @status FROZEN |
| 31 * @see nsIPrefBranch |
| 32 */ |
| 33 class NS_NO_VTABLE nsIPrefBranch2 : public nsIPrefBranch { |
| 34 public: |
| 35 |
| 36 NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPREFBRANCH2_IID) |
| 37 |
| 38 /** |
| 39 * Add a preference change observer. On preference changes, the following |
| 40 * arguments will be passed to the nsIObserver.observe() method: |
| 41 * aSubject - The nsIPrefBranch object (this) |
| 42 * aTopic - The string defined by NS_PREFBRANCH_PREFCHANGE_TOPIC_ID |
| 43 * aData - The preference which has changed |
| 44 * |
| 45 * @param aDomain The preference on which to listen for changes. This can |
| 46 * be the name of an entire branch to observe. |
| 47 * e.g. Holding the "root" prefbranch and calling |
| 48 * addObserver("foo.bar.", ...) will observe changes to |
| 49 * foo.bar.baz and foo.bar.bzip |
| 50 * @param aObserver The object to be notified if the preference changes. |
| 51 * @param aHoldWeak true Hold a weak reference to |aObserver|. The object |
| 52 * must implement the nsISupportsWeakReference |
| 53 * interface or this will fail. |
| 54 * false Hold a strong reference to |aObserver|. |
| 55 * |
| 56 * @note |
| 57 * Registering as a preference observer can open an object to potential |
| 58 * cyclical references which will cause memory leaks. These cycles generally |
| 59 * occur because an object both registers itself as an observer (causing the |
| 60 * branch to hold a reference to the observer) and holds a reference to the |
| 61 * branch object for the purpose of getting/setting preference values. There |
| 62 * are 3 approaches which have been implemented in an attempt to avoid these |
| 63 * situations. |
| 64 * 1) The nsPrefBranch object supports nsISupportsWeakReference. Any consumer |
| 65 * may hold a weak reference to it instead of a strong one. |
| 66 * 2) The nsPrefBranch object listens for xpcom-shutdown and frees all of the |
| 67 * objects currently in its observer list. This insures that long lived |
| 68 * objects (services for example) will be freed correctly. |
| 69 * 3) The observer can request to be held as a weak reference when it is |
| 70 * registered. This insures that shorter lived objects (say one tied to an |
| 71 * open window) will not fall into the cyclical reference trap. |
| 72 * |
| 73 * @see nsIObserver |
| 74 * @see removeObserver |
| 75 */ |
| 76 /* void addObserver (in string aDomain, in nsIObserver aObserver, in boolean a
HoldWeak); */ |
| 77 NS_IMETHOD AddObserver(const char *aDomain, nsIObserver *aObserver, PRBool aHo
ldWeak) = 0; |
| 78 |
| 79 /** |
| 80 * Remove a preference change observer. |
| 81 * |
| 82 * @param aDomain The preference which is being observed for changes. |
| 83 * @param aObserver An observer previously registered with addObserver(). |
| 84 * |
| 85 * @see nsIObserver |
| 86 * @see addObserver |
| 87 */ |
| 88 /* void removeObserver (in string aDomain, in nsIObserver aObserver); */ |
| 89 NS_IMETHOD RemoveObserver(const char *aDomain, nsIObserver *aObserver) = 0; |
| 90 |
| 91 }; |
| 92 |
| 93 /* Use this macro when declaring classes that implement this interface. */ |
| 94 #define NS_DECL_NSIPREFBRANCH2 \ |
| 95 NS_IMETHOD AddObserver(const char *aDomain, nsIObserver *aObserver, PRBool aHo
ldWeak); \ |
| 96 NS_IMETHOD RemoveObserver(const char *aDomain, nsIObserver *aObserver); |
| 97 |
| 98 /* Use this macro to declare functions that forward the behavior of this interfa
ce to another object. */ |
| 99 #define NS_FORWARD_NSIPREFBRANCH2(_to) \ |
| 100 NS_IMETHOD AddObserver(const char *aDomain, nsIObserver *aObserver, PRBool aHo
ldWeak) { return _to AddObserver(aDomain, aObserver, aHoldWeak); } \ |
| 101 NS_IMETHOD RemoveObserver(const char *aDomain, nsIObserver *aObserver) { retur
n _to RemoveObserver(aDomain, aObserver); } |
| 102 |
| 103 /* Use this macro to declare functions that forward the behavior of this interfa
ce to another object in a safe way. */ |
| 104 #define NS_FORWARD_SAFE_NSIPREFBRANCH2(_to) \ |
| 105 NS_IMETHOD AddObserver(const char *aDomain, nsIObserver *aObserver, PRBool aHo
ldWeak) { return !_to ? NS_ERROR_NULL_POINTER : _to->AddObserver(aDomain, aObser
ver, aHoldWeak); } \ |
| 106 NS_IMETHOD RemoveObserver(const char *aDomain, nsIObserver *aObserver) { retur
n !_to ? NS_ERROR_NULL_POINTER : _to->RemoveObserver(aDomain, aObserver); } |
| 107 |
| 108 #if 0 |
| 109 /* Use the code below as a template for the implementation class for this interf
ace. */ |
| 110 |
| 111 /* Header file */ |
| 112 class nsPrefBranch2 : public nsIPrefBranch2 |
| 113 { |
| 114 public: |
| 115 NS_DECL_ISUPPORTS |
| 116 NS_DECL_NSIPREFBRANCH2 |
| 117 |
| 118 nsPrefBranch2(); |
| 119 |
| 120 private: |
| 121 ~nsPrefBranch2(); |
| 122 |
| 123 protected: |
| 124 /* additional members */ |
| 125 }; |
| 126 |
| 127 /* Implementation file */ |
| 128 NS_IMPL_ISUPPORTS1(nsPrefBranch2, nsIPrefBranch2) |
| 129 |
| 130 nsPrefBranch2::nsPrefBranch2() |
| 131 { |
| 132 /* member initializers and constructor code */ |
| 133 } |
| 134 |
| 135 nsPrefBranch2::~nsPrefBranch2() |
| 136 { |
| 137 /* destructor code */ |
| 138 } |
| 139 |
| 140 /* void addObserver (in string aDomain, in nsIObserver aObserver, in boolean aHo
ldWeak); */ |
| 141 NS_IMETHODIMP nsPrefBranch2::AddObserver(const char *aDomain, nsIObserver *aObse
rver, PRBool aHoldWeak) |
| 142 { |
| 143 return NS_ERROR_NOT_IMPLEMENTED; |
| 144 } |
| 145 |
| 146 /* void removeObserver (in string aDomain, in nsIObserver aObserver); */ |
| 147 NS_IMETHODIMP nsPrefBranch2::RemoveObserver(const char *aDomain, nsIObserver *aO
bserver) |
| 148 { |
| 149 return NS_ERROR_NOT_IMPLEMENTED; |
| 150 } |
| 151 |
| 152 /* End of implementation class template. */ |
| 153 #endif |
| 154 |
| 155 /** |
| 156 * Notification sent when a preference changes. |
| 157 */ |
| 158 #define NS_PREFBRANCH_PREFCHANGE_TOPIC_ID "nsPref:changed" |
| 159 |
| 160 #endif /* __gen_nsIPrefBranch2_h__ */ |
OLD | NEW |