2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
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:
|
|
|
|
// We don't use the generic macros because we are a special static object
|
|
|
|
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aResult);
|
|
|
|
NS_IMETHOD_(nsrefcnt) AddRef(void) { return 1; }
|
|
|
|
NS_IMETHOD_(nsrefcnt) Release(void) { return 1; }
|
|
|
|
|
|
|
|
NS_DECL_NSIMEMORY
|
|
|
|
|
2010-06-10 11:11:11 -07:00
|
|
|
static nsresult Create(nsISupports* outer,
|
|
|
|
const nsIID& aIID, void **aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-01-04 07:02:17 -08:00
|
|
|
NS_HIDDEN_(nsresult) FlushMemory(const char16_t* aReason, bool aImmediate);
|
|
|
|
NS_HIDDEN_(nsresult) RunFlushers(const char16_t* aReason);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
protected:
|
|
|
|
struct FlushEvent : public nsIRunnable {
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_NSIRUNNABLE
|
2014-01-04 07:02:17 -08:00
|
|
|
const char16_t* mReason;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2014-02-06 22:05:24 -08:00
|
|
|
static mozilla::Atomic<bool> sIsFlushing;
|
2007-03-22 10:30:00 -07:00
|
|
|
static FlushEvent sFlushEvent;
|
2009-09-14 20:11:30 -07:00
|
|
|
static PRIntervalTime sLastFlushTime;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsMemoryImpl_h__
|