Bug 1686838 [wpt PR 27194] - [webcodecs] Deprecate VideoFrame.destroy()., a=testonly
[gecko.git] / xpcom / base / nsMemoryImpl.h
blob965c5d88ddfa32be54273a360667c04087363d11
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsMemoryImpl_h__
8 #define nsMemoryImpl_h__
10 #include "mozilla/Atomics.h"
12 #include "nsIMemory.h"
13 #include "nsIRunnable.h"
15 // nsMemoryImpl is a static object. We can do this because it doesn't have
16 // a constructor/destructor or any instance members. Please don't add
17 // instance member variables, only static member variables.
19 class nsMemoryImpl : public nsIMemory {
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) override;
23 NS_IMETHOD_(MozExternalRefCountType) AddRef(void) override { return 1; }
24 NS_IMETHOD_(MozExternalRefCountType) Release(void) override { return 1; }
26 NS_DECL_NSIMEMORY
28 static nsresult Create(nsISupports* aOuter, const nsIID& aIID,
29 void** aResult);
31 nsresult FlushMemory(const char16_t* aReason, bool aImmediate);
32 void RunFlushers(const char16_t* aReason);
34 protected:
35 struct FlushEvent : public nsIRunnable {
36 constexpr FlushEvent() : mReason(nullptr) {}
37 NS_DECL_ISUPPORTS_INHERITED
38 NS_DECL_NSIRUNNABLE
39 const char16_t* mReason;
42 static mozilla::Atomic<bool> sIsFlushing;
43 static FlushEvent sFlushEvent;
44 static PRIntervalTime sLastFlushTime;
47 #endif // nsMemoryImpl_h__