2014-05-05 10:30:39 -07: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 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsMemoryImpl_h__
|
|
|
|
#define nsMemoryImpl_h__
|
|
|
|
|
2013-08-22 08:14:42 -07:00
|
|
|
#include "mozilla/Atomics.h"
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIMemory.h"
|
|
|
|
#include "nsIRunnable.h"
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
class nsMemoryImpl : public nsIMemory
|
|
|
|
{
|
|
|
|
public:
|
2014-05-05 10:30:39 -07: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 10:41:38 -07:00
|
|
|
NS_IMETHOD_(MozExternalRefCountType) AddRef(void)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
NS_IMETHOD_(MozExternalRefCountType) Release(void)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-05-05 10:30:39 -07:00
|
|
|
NS_DECL_NSIMEMORY
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-05-13 10:41:38 -07:00
|
|
|
static nsresult Create(nsISupports* aOuter,
|
|
|
|
const nsIID& aIID, void** aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-06-02 05:08:21 -07:00
|
|
|
nsresult FlushMemory(const char16_t* aReason, bool aImmediate);
|
|
|
|
nsresult RunFlushers(const char16_t* aReason);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
protected:
|
2014-05-13 10:41:38 -07:00
|
|
|
struct FlushEvent : public nsIRunnable
|
|
|
|
{
|
2014-08-27 11:06:55 -07:00
|
|
|
MOZ_CONSTEXPR FlushEvent() : mReason(nullptr) {}
|
2014-05-05 10:30:39 -07:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_NSIRUNNABLE
|
|
|
|
const char16_t* mReason;
|
|
|
|
};
|
|
|
|
|
|
|
|
static mozilla::Atomic<bool> sIsFlushing;
|
|
|
|
static FlushEvent sFlushEvent;
|
|
|
|
static PRIntervalTime sLastFlushTime;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsMemoryImpl_h__
|