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/. */
6 #ifndef nsMemoryImpl_h__
7 #define nsMemoryImpl_h__
9 #include "mozilla/Atomics.h"
11 #include "nsIMemory.h"
12 #include "nsIRunnable.h"
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.
18 class nsMemoryImpl
: public nsIMemory
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_(nsrefcnt
) AddRef(void) { return 1; }
24 NS_IMETHOD_(nsrefcnt
) Release(void) { return 1; }
28 static nsresult
Create(nsISupports
* outer
,
29 const nsIID
& aIID
, void **aResult
);
31 NS_HIDDEN_(nsresult
) FlushMemory(const char16_t
* aReason
, bool aImmediate
);
32 NS_HIDDEN_(nsresult
) RunFlushers(const char16_t
* aReason
);
35 struct FlushEvent
: public nsIRunnable
{
36 NS_DECL_ISUPPORTS_INHERITED
38 const char16_t
* mReason
;
41 static mozilla::Atomic
<int32_t> sIsFlushing
;
42 static FlushEvent sFlushEvent
;
43 static PRIntervalTime sLastFlushTime
;
46 #endif // nsMemoryImpl_h__