PageRenderTime 282ms CodeModel.GetById 131ms app.highlight 54ms RepoModel.GetById 67ms app.codeStats 0ms

/gecko_api/include/nsIPrefBranch2.h

http://firefox-mac-pdf.googlecode.com/
C++ Header | 189 lines | 58 code | 29 blank | 102 comment | 0 complexity | 9911e44a1b07dcc10f2e35dcc3f0d7f2 MD5 | raw file
  1/*
  2 * DO NOT EDIT.  THIS FILE IS GENERATED FROM /builds/tinderbox/XR-Trunk/Darwin_8.8.4_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
 17class 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 */
 33class NS_NO_VTABLE NS_SCRIPTABLE nsIPrefBranch2 : public nsIPrefBranch {
 34 public: 
 35
 36  NS_DECLARE_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 name of the preference which has changed, relative to
 44   *              the |root| of the aSubject branch.
 45   *
 46   * aSubject.get*Pref(aData) will get the new value of the modified
 47   * preference. For example, if your observer is registered with
 48   * addObserver("bar.", ...) on a branch with root "foo.", modifying
 49   * the preference "foo.bar.baz" will trigger the observer, and aData
 50   * parameter will be "bar.baz".
 51   *
 52   * @param aDomain   The preference on which to listen for changes. This can
 53   *                  be the name of an entire branch to observe.
 54   *                  e.g. Holding the "root" prefbranch and calling
 55   *                  addObserver("foo.bar.", ...) will observe changes to
 56   *                  foo.bar.baz and foo.bar.bzip
 57   * @param aObserver The object to be notified if the preference changes.
 58   * @param aHoldWeak true  Hold a weak reference to |aObserver|. The object
 59   *                        must implement the nsISupportsWeakReference
 60   *                        interface or this will fail.
 61   *                  false Hold a strong reference to |aObserver|.
 62   *
 63   * @note
 64   * Registering as a preference observer can open an object to potential
 65   * cyclical references which will cause memory leaks. These cycles generally
 66   * occur because an object both registers itself as an observer (causing the
 67   * branch to hold a reference to the observer) and holds a reference to the
 68   * branch object for the purpose of getting/setting preference values. There
 69   * are 3 approaches which have been implemented in an attempt to avoid these
 70   * situations.
 71   * 1) The nsPrefBranch object supports nsISupportsWeakReference. Any consumer
 72   *    may hold a weak reference to it instead of a strong one.
 73   * 2) The nsPrefBranch object listens for xpcom-shutdown and frees all of the
 74   *    objects currently in its observer list. This ensures that long lived
 75   *    objects (services for example) will be freed correctly.
 76   * 3) The observer can request to be held as a weak reference when it is
 77   *    registered. This insures that shorter lived objects (say one tied to an
 78   *    open window) will not fall into the cyclical reference trap.
 79   *
 80   * @note
 81   * The list of registered observers may be changed during the dispatch of
 82   * nsPref:changed notification. However, the observers are not guaranteed
 83   * to be notified in any particular order, so you can't be sure whether the
 84   * added/removed observer will be called during the notification when it
 85   * is added/removed.
 86   *
 87   * @note
 88   * It is possible to change preferences during the notification.
 89   *
 90   * @note
 91   * It is not safe to change observers during this callback in Gecko 
 92   * releases before 1.9. If you want a safe way to remove a pref observer,
 93   * please use an nsITimer.
 94   *
 95   * @see nsIObserver
 96   * @see removeObserver
 97   */
 98  /* void addObserver (in string aDomain, in nsIObserver aObserver, in boolean aHoldWeak); */
 99  NS_SCRIPTABLE NS_IMETHOD AddObserver(const char *aDomain, nsIObserver *aObserver, PRBool aHoldWeak) = 0;
100
101  /**
102   * Remove a preference change observer.
103   *
104   * @param aDomain   The preference which is being observed for changes.
105   * @param aObserver An observer previously registered with addObserver().
106   *
107   * @note
108   * Note that you must call removeObserver() on the same nsIPrefBranch2
109   * instance on which you called addObserver() in order to remove aObserver;
110   * otherwise, the observer will not be removed.
111   *
112   * @see nsIObserver
113   * @see addObserver
114   */
115  /* void removeObserver (in string aDomain, in nsIObserver aObserver); */
116  NS_SCRIPTABLE NS_IMETHOD RemoveObserver(const char *aDomain, nsIObserver *aObserver) = 0;
117
118};
119
120  NS_DEFINE_STATIC_IID_ACCESSOR(nsIPrefBranch2, NS_IPREFBRANCH2_IID)
121
122/* Use this macro when declaring classes that implement this interface. */
123#define NS_DECL_NSIPREFBRANCH2 \
124  NS_SCRIPTABLE NS_IMETHOD AddObserver(const char *aDomain, nsIObserver *aObserver, PRBool aHoldWeak); \
125  NS_SCRIPTABLE NS_IMETHOD RemoveObserver(const char *aDomain, nsIObserver *aObserver); 
126
127/* Use this macro to declare functions that forward the behavior of this interface to another object. */
128#define NS_FORWARD_NSIPREFBRANCH2(_to) \
129  NS_SCRIPTABLE NS_IMETHOD AddObserver(const char *aDomain, nsIObserver *aObserver, PRBool aHoldWeak) { return _to AddObserver(aDomain, aObserver, aHoldWeak); } \
130  NS_SCRIPTABLE NS_IMETHOD RemoveObserver(const char *aDomain, nsIObserver *aObserver) { return _to RemoveObserver(aDomain, aObserver); } 
131
132/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
133#define NS_FORWARD_SAFE_NSIPREFBRANCH2(_to) \
134  NS_SCRIPTABLE NS_IMETHOD AddObserver(const char *aDomain, nsIObserver *aObserver, PRBool aHoldWeak) { return !_to ? NS_ERROR_NULL_POINTER : _to->AddObserver(aDomain, aObserver, aHoldWeak); } \
135  NS_SCRIPTABLE NS_IMETHOD RemoveObserver(const char *aDomain, nsIObserver *aObserver) { return !_to ? NS_ERROR_NULL_POINTER : _to->RemoveObserver(aDomain, aObserver); } 
136
137#if 0
138/* Use the code below as a template for the implementation class for this interface. */
139
140/* Header file */
141class nsPrefBranch2 : public nsIPrefBranch2
142{
143public:
144  NS_DECL_ISUPPORTS
145  NS_DECL_NSIPREFBRANCH2
146
147  nsPrefBranch2();
148
149private:
150  ~nsPrefBranch2();
151
152protected:
153  /* additional members */
154};
155
156/* Implementation file */
157NS_IMPL_ISUPPORTS1(nsPrefBranch2, nsIPrefBranch2)
158
159nsPrefBranch2::nsPrefBranch2()
160{
161  /* member initializers and constructor code */
162}
163
164nsPrefBranch2::~nsPrefBranch2()
165{
166  /* destructor code */
167}
168
169/* void addObserver (in string aDomain, in nsIObserver aObserver, in boolean aHoldWeak); */
170NS_IMETHODIMP nsPrefBranch2::AddObserver(const char *aDomain, nsIObserver *aObserver, PRBool aHoldWeak)
171{
172    return NS_ERROR_NOT_IMPLEMENTED;
173}
174
175/* void removeObserver (in string aDomain, in nsIObserver aObserver); */
176NS_IMETHODIMP nsPrefBranch2::RemoveObserver(const char *aDomain, nsIObserver *aObserver)
177{
178    return NS_ERROR_NOT_IMPLEMENTED;
179}
180
181/* End of implementation class template. */
182#endif
183
184/**
185 * Notification sent when a preference changes.
186 */
187#define NS_PREFBRANCH_PREFCHANGE_TOPIC_ID "nsPref:changed"
188
189#endif /* __gen_nsIPrefBranch2_h__ */