|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef nsMemoryImpl_h__ |
|
7 #define nsMemoryImpl_h__ |
|
8 |
|
9 #include "mozilla/Atomics.h" |
|
10 |
|
11 #include "nsIMemory.h" |
|
12 #include "nsIRunnable.h" |
|
13 |
|
14 // nsMemoryImpl is a static object. We can do this because it doesn't have |
|
15 // a constructor/destructor or any instance members. Please don't add |
|
16 // instance member variables, only static member variables. |
|
17 |
|
18 class nsMemoryImpl : public nsIMemory |
|
19 { |
|
20 public: |
|
21 // We don't use the generic macros because we are a special static object |
|
22 NS_IMETHOD QueryInterface(REFNSIID aIID, void** aResult); |
|
23 NS_IMETHOD_(MozExternalRefCountType) AddRef(void) { return 1; } |
|
24 NS_IMETHOD_(MozExternalRefCountType) Release(void) { return 1; } |
|
25 |
|
26 NS_DECL_NSIMEMORY |
|
27 |
|
28 static nsresult Create(nsISupports* outer, |
|
29 const nsIID& aIID, void **aResult); |
|
30 |
|
31 NS_HIDDEN_(nsresult) FlushMemory(const char16_t* aReason, bool aImmediate); |
|
32 NS_HIDDEN_(nsresult) RunFlushers(const char16_t* aReason); |
|
33 |
|
34 protected: |
|
35 struct FlushEvent : public nsIRunnable { |
|
36 NS_DECL_ISUPPORTS_INHERITED |
|
37 NS_DECL_NSIRUNNABLE |
|
38 const char16_t* mReason; |
|
39 }; |
|
40 |
|
41 static mozilla::Atomic<bool> sIsFlushing; |
|
42 static FlushEvent sFlushEvent; |
|
43 static PRIntervalTime sLastFlushTime; |
|
44 }; |
|
45 |
|
46 #endif // nsMemoryImpl_h__ |