Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: gecko-sdk/include/nsIMemory.h

Issue 20346: Version 1.8 of gecko-sdk. Downloaded from here:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/
Patch Set: Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gecko-sdk/include/nsILocalFile.h ('k') | gecko-sdk/include/nsIModule.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 /*
2 * DO NOT EDIT. THIS FILE IS GENERATED FROM c:/builds/tinderbox/XR-Mozilla1.8.0 -Release/WINNT_5.2_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 */
58 class NS_NO_VTABLE nsIMemory : public nsISupports {
59 public:
60
61 NS_DEFINE_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_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_IMETHOD IsLowMemory(PRBool *_retval) = 0;
119
120 };
121
122 /* Use this macro when declaring classes that implement this interface. */
123 #define NS_DECL_NSIMEMORY \
124 NS_IMETHOD_(void *) Alloc(size_t size); \
125 NS_IMETHOD_(void *) Realloc(void * ptr, size_t newSize); \
126 NS_IMETHOD_(void) Free(void * ptr); \
127 NS_IMETHOD HeapMinimize(PRBool immediate); \
128 NS_IMETHOD IsLowMemory(PRBool *_retval);
129
130 /* Use this macro to declare functions that forward the behavior of this interfa ce to another object. */
131 #define NS_FORWARD_NSIMEMORY(_to) \
132 NS_IMETHOD_(void *) Alloc(size_t size) { return _to Alloc(size); } \
133 NS_IMETHOD_(void *) Realloc(void * ptr, size_t newSize) { return _to Realloc(p tr, newSize); } \
134 NS_IMETHOD_(void) Free(void * ptr) { return _to Free(ptr); } \
135 NS_IMETHOD HeapMinimize(PRBool immediate) { return _to HeapMinimize(immediate) ; } \
136 NS_IMETHOD IsLowMemory(PRBool *_retval) { return _to IsLowMemory(_retval); }
137
138 /* Use this macro to declare functions that forward the behavior of this interfa ce to another object in a safe way. */
139 #define NS_FORWARD_SAFE_NSIMEMORY(_to) \
140 NS_IMETHOD_(void *) Alloc(size_t size) { return !_to ? NS_ERROR_NULL_POINTER : _to->Alloc(size); } \
141 NS_IMETHOD_(void *) Realloc(void * ptr, size_t newSize) { return !_to ? NS_ERR OR_NULL_POINTER : _to->Realloc(ptr, newSize); } \
142 NS_IMETHOD_(void) Free(void * ptr) { return !_to ? NS_ERROR_NULL_POINTER : _to ->Free(ptr); } \
143 NS_IMETHOD HeapMinimize(PRBool immediate) { return !_to ? NS_ERROR_NULL_POINTE R : _to->HeapMinimize(immediate); } \
144 NS_IMETHOD IsLowMemory(PRBool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->IsLowMemory(_retval); }
145
146 #if 0
147 /* Use the code below as a template for the implementation class for this interf ace. */
148
149 /* Header file */
150 class nsMemory : public nsIMemory
151 {
152 public:
153 NS_DECL_ISUPPORTS
154 NS_DECL_NSIMEMORY
155
156 nsMemory();
157
158 private:
159 ~nsMemory();
160
161 protected:
162 /* additional members */
163 };
164
165 /* Implementation file */
166 NS_IMPL_ISUPPORTS1(nsMemory, nsIMemory)
167
168 nsMemory::nsMemory()
169 {
170 /* member initializers and constructor code */
171 }
172
173 nsMemory::~nsMemory()
174 {
175 /* destructor code */
176 }
177
178 /* [noscript, notxpcom] voidPtr alloc (in size_t size); */
179 NS_IMETHODIMP_(void *) nsMemory::Alloc(size_t size)
180 {
181 return NS_ERROR_NOT_IMPLEMENTED;
182 }
183
184 /* [noscript, notxpcom] voidPtr realloc (in voidPtr ptr, in size_t newSize); */
185 NS_IMETHODIMP_(void *) nsMemory::Realloc(void * ptr, size_t newSize)
186 {
187 return NS_ERROR_NOT_IMPLEMENTED;
188 }
189
190 /* [noscript, notxpcom] void free (in voidPtr ptr); */
191 NS_IMETHODIMP_(void) nsMemory::Free(void * ptr)
192 {
193 return NS_ERROR_NOT_IMPLEMENTED;
194 }
195
196 /* void heapMinimize (in boolean immediate); */
197 NS_IMETHODIMP nsMemory::HeapMinimize(PRBool immediate)
198 {
199 return NS_ERROR_NOT_IMPLEMENTED;
200 }
201
202 /* boolean isLowMemory (); */
203 NS_IMETHODIMP nsMemory::IsLowMemory(PRBool *_retval)
204 {
205 return NS_ERROR_NOT_IMPLEMENTED;
206 }
207
208 /* End of implementation class template. */
209 #endif
210
211
212 #endif /* __gen_nsIMemory_h__ */
OLDNEW
« no previous file with comments | « gecko-sdk/include/nsILocalFile.h ('k') | gecko-sdk/include/nsIModule.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698