Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
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
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; }
26 NS_DECL_NSIMEMORY
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);
34 protected:
35 struct FlushEvent : public nsIRunnable {
36 NS_DECL_ISUPPORTS_INHERITED
37 NS_DECL_NSIRUNNABLE
38 const char16_t* mReason;
39 };
41 static mozilla::Atomic<bool> sIsFlushing;
42 static FlushEvent sFlushEvent;
43 static PRIntervalTime sLastFlushTime;
44 };
46 #endif // nsMemoryImpl_h__