1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/base/nsMemoryImpl.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,46 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsMemoryImpl_h__ 1.10 +#define nsMemoryImpl_h__ 1.11 + 1.12 +#include "mozilla/Atomics.h" 1.13 + 1.14 +#include "nsIMemory.h" 1.15 +#include "nsIRunnable.h" 1.16 + 1.17 +// nsMemoryImpl is a static object. We can do this because it doesn't have 1.18 +// a constructor/destructor or any instance members. Please don't add 1.19 +// instance member variables, only static member variables. 1.20 + 1.21 +class nsMemoryImpl : public nsIMemory 1.22 +{ 1.23 +public: 1.24 + // We don't use the generic macros because we are a special static object 1.25 + NS_IMETHOD QueryInterface(REFNSIID aIID, void** aResult); 1.26 + NS_IMETHOD_(MozExternalRefCountType) AddRef(void) { return 1; } 1.27 + NS_IMETHOD_(MozExternalRefCountType) Release(void) { return 1; } 1.28 + 1.29 + NS_DECL_NSIMEMORY 1.30 + 1.31 + static nsresult Create(nsISupports* outer, 1.32 + const nsIID& aIID, void **aResult); 1.33 + 1.34 + NS_HIDDEN_(nsresult) FlushMemory(const char16_t* aReason, bool aImmediate); 1.35 + NS_HIDDEN_(nsresult) RunFlushers(const char16_t* aReason); 1.36 + 1.37 +protected: 1.38 + struct FlushEvent : public nsIRunnable { 1.39 + NS_DECL_ISUPPORTS_INHERITED 1.40 + NS_DECL_NSIRUNNABLE 1.41 + const char16_t* mReason; 1.42 + }; 1.43 + 1.44 + static mozilla::Atomic<bool> sIsFlushing; 1.45 + static FlushEvent sFlushEvent; 1.46 + static PRIntervalTime sLastFlushTime; 1.47 +}; 1.48 + 1.49 +#endif // nsMemoryImpl_h__