2014-05-05 17:30:39 +00: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 11:12:37 +00: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 07:02:20 +00:00
|
|
|
|
|
|
|
#ifndef nsMemoryImpl_h__
|
|
|
|
#define nsMemoryImpl_h__
|
|
|
|
|
2013-08-22 15:14:42 +00:00
|
|
|
#include "mozilla/Atomics.h"
|
|
|
|
|
2004-11-12 19:26:37 +00:00
|
|
|
#include "nsIMemory.h"
|
2006-05-10 17:30:15 +00:00
|
|
|
#include "nsIRunnable.h"
|
2000-09-20 05:44:19 +00:00
|
|
|
|
2004-11-12 19:26:37 +00: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 07:02:20 +00:00
|
|
|
|
|
|
|
class nsMemoryImpl : public nsIMemory
|
|
|
|
{
|
|
|
|
public:
|
2014-05-05 17:30:39 +00:00
|
|
|
// We don't use the generic macros because we are a special static object
|
|
|
|
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aResult);
|
2014-05-13 17:41:38 +00:00
|
|
|
NS_IMETHOD_(MozExternalRefCountType) AddRef(void)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
NS_IMETHOD_(MozExternalRefCountType) Release(void)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2000-06-03 07:02:20 +00:00
|
|
|
|
2014-05-05 17:30:39 +00:00
|
|
|
NS_DECL_NSIMEMORY
|
2000-06-03 07:02:20 +00:00
|
|
|
|
2014-05-13 17:41:38 +00:00
|
|
|
static nsresult Create(nsISupports* aOuter,
|
|
|
|
const nsIID& aIID, void** aResult);
|
2000-06-03 07:02:20 +00:00
|
|
|
|
2014-06-02 12:08:21 +00:00
|
|
|
nsresult FlushMemory(const char16_t* aReason, bool aImmediate);
|
|
|
|
nsresult RunFlushers(const char16_t* aReason);
|
2004-01-15 06:14:18 +00:00
|
|
|
|
2000-06-03 07:02:20 +00:00
|
|
|
protected:
|
2014-05-13 17:41:38 +00:00
|
|
|
struct FlushEvent : public nsIRunnable
|
|
|
|
{
|
2014-08-27 18:06:55 +00:00
|
|
|
MOZ_CONSTEXPR FlushEvent() : mReason(nullptr) {}
|
2014-05-05 17:30:39 +00: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 07:02:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsMemoryImpl_h__
|