2014-05-05 21:30:39 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2000-06-03 11:02:20 +04:00
|
|
|
|
|
|
|
#ifndef nsMemoryImpl_h__
|
|
|
|
#define nsMemoryImpl_h__
|
|
|
|
|
2013-08-22 19:14:42 +04:00
|
|
|
#include "mozilla/Atomics.h"
|
|
|
|
|
2004-11-12 22:26:37 +03:00
|
|
|
#include "nsIMemory.h"
|
2006-05-10 21:30:15 +04:00
|
|
|
#include "nsIRunnable.h"
|
2000-09-20 09:44:19 +04:00
|
|
|
|
2004-11-12 22:26:37 +03:00
|
|
|
// nsMemoryImpl is a static object. We can do this because it doesn't have
|
|
|
|
// a constructor/destructor or any instance members. Please don't add
|
|
|
|
// instance member variables, only static member variables.
|
2000-06-03 11:02:20 +04:00
|
|
|
|
|
|
|
class nsMemoryImpl : public nsIMemory {
|
|
|
|
public:
|
2014-05-05 21:30:39 +04:00
|
|
|
// We don't use the generic macros because we are a special static object
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aResult) override;
|
|
|
|
NS_IMETHOD_(MozExternalRefCountType) AddRef(void) override { return 1; }
|
|
|
|
NS_IMETHOD_(MozExternalRefCountType) Release(void) override { return 1; }
|
2000-06-03 11:02:20 +04:00
|
|
|
|
2014-05-05 21:30:39 +04:00
|
|
|
NS_DECL_NSIMEMORY
|
2000-06-03 11:02:20 +04:00
|
|
|
|
2014-05-13 21:41:38 +04:00
|
|
|
static nsresult Create(nsISupports* aOuter, const nsIID& aIID,
|
|
|
|
void** aResult);
|
2000-06-03 11:02:20 +04:00
|
|
|
|
2014-06-02 16:08:21 +04:00
|
|
|
nsresult FlushMemory(const char16_t* aReason, bool aImmediate);
|
2019-11-27 16:46:12 +03:00
|
|
|
void RunFlushers(const char16_t* aReason);
|
2004-01-15 09:14:18 +03:00
|
|
|
|
2000-06-03 11:02:20 +04:00
|
|
|
protected:
|
2014-05-13 21:41:38 +04:00
|
|
|
struct FlushEvent : public nsIRunnable {
|
2016-07-09 00:39:53 +03:00
|
|
|
constexpr FlushEvent() : mReason(nullptr) {}
|
2014-05-05 21:30:39 +04:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_NSIRUNNABLE
|
|
|
|
const char16_t* mReason;
|
|
|
|
};
|
|
|
|
|
|
|
|
static mozilla::Atomic<bool> sIsFlushing;
|
|
|
|
static FlushEvent sFlushEvent;
|
|
|
|
static PRIntervalTime sLastFlushTime;
|
2000-06-03 11:02:20 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsMemoryImpl_h__
|