michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsMemoryImpl_h__ michael@0: #define nsMemoryImpl_h__ michael@0: michael@0: #include "mozilla/Atomics.h" michael@0: michael@0: #include "nsIMemory.h" michael@0: #include "nsIRunnable.h" michael@0: michael@0: // nsMemoryImpl is a static object. We can do this because it doesn't have michael@0: // a constructor/destructor or any instance members. Please don't add michael@0: // instance member variables, only static member variables. michael@0: michael@0: class nsMemoryImpl : public nsIMemory michael@0: { michael@0: public: michael@0: // We don't use the generic macros because we are a special static object michael@0: NS_IMETHOD QueryInterface(REFNSIID aIID, void** aResult); michael@0: NS_IMETHOD_(MozExternalRefCountType) AddRef(void) { return 1; } michael@0: NS_IMETHOD_(MozExternalRefCountType) Release(void) { return 1; } michael@0: michael@0: NS_DECL_NSIMEMORY michael@0: michael@0: static nsresult Create(nsISupports* outer, michael@0: const nsIID& aIID, void **aResult); michael@0: michael@0: NS_HIDDEN_(nsresult) FlushMemory(const char16_t* aReason, bool aImmediate); michael@0: NS_HIDDEN_(nsresult) RunFlushers(const char16_t* aReason); michael@0: michael@0: protected: michael@0: struct FlushEvent : public nsIRunnable { michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: NS_DECL_NSIRUNNABLE michael@0: const char16_t* mReason; michael@0: }; michael@0: michael@0: static mozilla::Atomic sIsFlushing; michael@0: static FlushEvent sFlushEvent; michael@0: static PRIntervalTime sLastFlushTime; michael@0: }; michael@0: michael@0: #endif // nsMemoryImpl_h__