зеркало из https://github.com/mozilla/pjs.git
Bug 399107: Add API to force cycle collection. r/sr/a=jst
This commit is contained in:
Родитель
1ac06c40d8
Коммит
999c95b469
|
@ -47,7 +47,7 @@
|
||||||
|
|
||||||
interface nsIDOMElement;
|
interface nsIDOMElement;
|
||||||
|
|
||||||
[scriptable, uuid(25f55fb2-a6f8-4f7f-93c3-3adafd5166bc)]
|
[scriptable, uuid(7a55fc2b-afb3-41c6-9e50-3fee341fa87c)]
|
||||||
interface nsIDOMWindowUtils : nsISupports {
|
interface nsIDOMWindowUtils : nsISupports {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -156,4 +156,13 @@ interface nsIDOMWindowUtils : nsISupports {
|
||||||
* @param aElement the element to focus
|
* @param aElement the element to focus
|
||||||
*/
|
*/
|
||||||
void focus(in nsIDOMElement aElement);
|
void focus(in nsIDOMElement aElement);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Force a garbage collection. This will run the cycle-collector twice to
|
||||||
|
* make sure all garbage is collected.
|
||||||
|
*
|
||||||
|
* Will throw a DOM security error if called without UniversalXPConnect
|
||||||
|
* privileges in non-debug builds. Available to all callers in debug builds.
|
||||||
|
*/
|
||||||
|
void garbageCollect();
|
||||||
};
|
};
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
#include "nsIWidget.h"
|
#include "nsIWidget.h"
|
||||||
#include "nsGUIEvent.h"
|
#include "nsGUIEvent.h"
|
||||||
#include "nsIParser.h"
|
#include "nsIParser.h"
|
||||||
|
#include "nsCycleCollector.h"
|
||||||
|
|
||||||
#ifdef MOZ_ENABLE_GTK2
|
#ifdef MOZ_ENABLE_GTK2
|
||||||
#include <gdk/gdkx.h>
|
#include <gdk/gdkx.h>
|
||||||
|
@ -327,3 +328,21 @@ nsDOMWindowUtils::Focus(nsIDOMElement* aElement)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDOMWindowUtils::GarbageCollect()
|
||||||
|
{
|
||||||
|
// NOTE: Only do this in NON debug builds, as this function can useful
|
||||||
|
// during debugging.
|
||||||
|
#ifndef DEBUG
|
||||||
|
PRBool hasCap = PR_FALSE;
|
||||||
|
if (NS_FAILED(nsContentUtils::GetSecurityManager()->
|
||||||
|
IsCapabilityEnabled("UniversalXPConnect", &hasCap))
|
||||||
|
|| !hasCap)
|
||||||
|
return NS_ERROR_DOM_SECURITY_ERR;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
nsCycleCollector_collect();
|
||||||
|
nsCycleCollector_collect();
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче