PageRenderTime 71ms CodeModel.GetById 40ms app.highlight 4ms RepoModel.GetById 16ms app.codeStats 0ms

/gecko_api/include/nsIMemory.h

http://firefox-mac-pdf.googlecode.com/
C++ Header | 214 lines | 80 code | 34 blank | 100 comment | 0 complexity | f9cdc521fb3c71f31be53a27ed221b73 MD5 | raw file
  1/*
  2 * DO NOT EDIT.  THIS FILE IS GENERATED FROM /builds/tinderbox/XR-Trunk/Darwin_8.8.4_Depend/mozilla/xpcom/base/nsIMemory.idl
  3 */
  4
  5#ifndef __gen_nsIMemory_h__
  6#define __gen_nsIMemory_h__
  7
  8
  9#ifndef __gen_nsISupports_h__
 10#include "nsISupports.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
 18/* starting interface:    nsIMemory */
 19#define NS_IMEMORY_IID_STR "59e7e77a-38e4-11d4-8cf5-0060b0fc14a3"
 20
 21#define NS_IMEMORY_IID \
 22  {0x59e7e77a, 0x38e4, 0x11d4, \
 23    { 0x8c, 0xf5, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3 }}
 24
 25/**
 26 *
 27 * nsIMemory: interface to allocate and deallocate memory. Also provides
 28 * for notifications in low-memory situations.
 29 *
 30 * The frozen exported symbols NS_Alloc, NS_Realloc, and NS_Free
 31 * provide a more efficient way to access XPCOM memory allocation. Using
 32 * those symbols is preferred to using the methods on this interface.
 33 *
 34 * A client that wishes to be notified of low memory situations (for
 35 * example, because the client maintains a large memory cache that
 36 * could be released when memory is tight) should register with the
 37 * observer service (see nsIObserverService) using the topic 
 38 * "memory-pressure". There are three specific types of notications 
 39 * that can occur.  These types will be passed as the |aData| 
 40 * parameter of the of the "memory-pressure" notification: 
 41 * 
 42 * "low-memory"
 43 * This will be passed as the extra data when the pressure 
 44 * observer is being asked to flush for low-memory conditions.
 45 *
 46 * "heap-minimize"
 47 * This will be passed as the extra data when the pressure 
 48 * observer is being asked to flush because of a heap minimize 
 49 * call.
 50 *
 51 * "alloc-failure"
 52 * This will be passed as the extra data when the pressure 
 53 * observer has been asked to flush because a malloc() or 
 54 * realloc() has failed.
 55 *
 56 * @status FROZEN
 57 */
 58class NS_NO_VTABLE NS_SCRIPTABLE nsIMemory : public nsISupports {
 59 public: 
 60
 61  NS_DECLARE_STATIC_IID_ACCESSOR(NS_IMEMORY_IID)
 62
 63  /**
 64     * Allocates a block of memory of a particular size. If the memory 
 65     * cannot be allocated (because of an out-of-memory condition), null
 66     * is returned.
 67     *
 68     * @param size - the size of the block to allocate
 69     * @result the block of memory
 70     */
 71  /* [noscript, notxpcom] voidPtr alloc (in size_t size); */
 72  NS_IMETHOD_(void *) Alloc(size_t size) = 0;
 73
 74  /**
 75     * Reallocates a block of memory to a new size.
 76     *
 77     * @param ptr - the block of memory to reallocate
 78     * @param size - the new size
 79     * @result the reallocated block of memory
 80     *
 81     * If ptr is null, this function behaves like malloc.
 82     * If s is the size of the block to which ptr points, the first
 83     * min(s, size) bytes of ptr's block are copied to the new block.
 84     * If the allocation succeeds, ptr is freed and a pointer to the 
 85     * new block returned.  If the allocation fails, ptr is not freed
 86     * and null is returned. The returned value may be the same as ptr.
 87     */
 88  /* [noscript, notxpcom] voidPtr realloc (in voidPtr ptr, in size_t newSize); */
 89  NS_IMETHOD_(void *) Realloc(void * ptr, size_t newSize) = 0;
 90
 91  /**
 92     * Frees a block of memory. Null is a permissible value, in which case
 93     * nothing happens. 
 94     *
 95     * @param ptr - the block of memory to free
 96     */
 97  /* [noscript, notxpcom] void free (in voidPtr ptr); */
 98  NS_IMETHOD_(void) Free(void * ptr) = 0;
 99
100  /**
101     * Attempts to shrink the heap.
102     * @param immediate - if true, heap minimization will occur
103     *   immediately if the call was made on the main thread. If
104     *   false, the flush will be scheduled to happen when the app is
105     *   idle.
106     * @return NS_ERROR_FAILURE if 'immediate' is set an the call
107     *   was not on the application's main thread.
108     */
109  /* void heapMinimize (in boolean immediate); */
110  NS_SCRIPTABLE NS_IMETHOD HeapMinimize(PRBool immediate) = 0;
111
112  /**
113     * This predicate can be used to determine if we're in a low-memory
114     * situation (what constitutes low-memory is platform dependent). This
115     * can be used to trigger the memory pressure observers.
116     */
117  /* boolean isLowMemory (); */
118  NS_SCRIPTABLE NS_IMETHOD IsLowMemory(PRBool *_retval) = 0;
119
120};
121
122  NS_DEFINE_STATIC_IID_ACCESSOR(nsIMemory, NS_IMEMORY_IID)
123
124/* Use this macro when declaring classes that implement this interface. */
125#define NS_DECL_NSIMEMORY \
126  NS_IMETHOD_(void *) Alloc(size_t size); \
127  NS_IMETHOD_(void *) Realloc(void * ptr, size_t newSize); \
128  NS_IMETHOD_(void) Free(void * ptr); \
129  NS_SCRIPTABLE NS_IMETHOD HeapMinimize(PRBool immediate); \
130  NS_SCRIPTABLE NS_IMETHOD IsLowMemory(PRBool *_retval); 
131
132/* Use this macro to declare functions that forward the behavior of this interface to another object. */
133#define NS_FORWARD_NSIMEMORY(_to) \
134  NS_IMETHOD_(void *) Alloc(size_t size) { return _to Alloc(size); } \
135  NS_IMETHOD_(void *) Realloc(void * ptr, size_t newSize) { return _to Realloc(ptr, newSize); } \
136  NS_IMETHOD_(void) Free(void * ptr) { return _to Free(ptr); } \
137  NS_SCRIPTABLE NS_IMETHOD HeapMinimize(PRBool immediate) { return _to HeapMinimize(immediate); } \
138  NS_SCRIPTABLE NS_IMETHOD IsLowMemory(PRBool *_retval) { return _to IsLowMemory(_retval); } 
139
140/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
141#define NS_FORWARD_SAFE_NSIMEMORY(_to) \
142  NS_IMETHOD_(void *) Alloc(size_t size) { return !_to ? NS_ERROR_NULL_POINTER : _to->Alloc(size); } \
143  NS_IMETHOD_(void *) Realloc(void * ptr, size_t newSize) { return !_to ? NS_ERROR_NULL_POINTER : _to->Realloc(ptr, newSize); } \
144  NS_IMETHOD_(void) Free(void * ptr) { return !_to ? NS_ERROR_NULL_POINTER : _to->Free(ptr); } \
145  NS_SCRIPTABLE NS_IMETHOD HeapMinimize(PRBool immediate) { return !_to ? NS_ERROR_NULL_POINTER : _to->HeapMinimize(immediate); } \
146  NS_SCRIPTABLE NS_IMETHOD IsLowMemory(PRBool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->IsLowMemory(_retval); } 
147
148#if 0
149/* Use the code below as a template for the implementation class for this interface. */
150
151/* Header file */
152class nsMemory : public nsIMemory
153{
154public:
155  NS_DECL_ISUPPORTS
156  NS_DECL_NSIMEMORY
157
158  nsMemory();
159
160private:
161  ~nsMemory();
162
163protected:
164  /* additional members */
165};
166
167/* Implementation file */
168NS_IMPL_ISUPPORTS1(nsMemory, nsIMemory)
169
170nsMemory::nsMemory()
171{
172  /* member initializers and constructor code */
173}
174
175nsMemory::~nsMemory()
176{
177  /* destructor code */
178}
179
180/* [noscript, notxpcom] voidPtr alloc (in size_t size); */
181NS_IMETHODIMP_(void *) nsMemory::Alloc(size_t size)
182{
183    return NS_ERROR_NOT_IMPLEMENTED;
184}
185
186/* [noscript, notxpcom] voidPtr realloc (in voidPtr ptr, in size_t newSize); */
187NS_IMETHODIMP_(void *) nsMemory::Realloc(void * ptr, size_t newSize)
188{
189    return NS_ERROR_NOT_IMPLEMENTED;
190}
191
192/* [noscript, notxpcom] void free (in voidPtr ptr); */
193NS_IMETHODIMP_(void) nsMemory::Free(void * ptr)
194{
195    return NS_ERROR_NOT_IMPLEMENTED;
196}
197
198/* void heapMinimize (in boolean immediate); */
199NS_IMETHODIMP nsMemory::HeapMinimize(PRBool immediate)
200{
201    return NS_ERROR_NOT_IMPLEMENTED;
202}
203
204/* boolean isLowMemory (); */
205NS_IMETHODIMP nsMemory::IsLowMemory(PRBool *_retval)
206{
207    return NS_ERROR_NOT_IMPLEMENTED;
208}
209
210/* End of implementation class template. */
211#endif
212
213
214#endif /* __gen_nsIMemory_h__ */