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