mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 587222 - Script caching in messageManager leaks; r=Olli.Pettay a=blocking-because-550936-is-a-blocker
This commit is contained in:
parent
cc6b8b5e56
commit
cf8363b4a5
@ -510,6 +510,7 @@ NS_NewGlobalMessageManager(nsIChromeFrameMessageManager** aResult)
|
|||||||
|
|
||||||
nsDataHashtable<nsStringHashKey, nsFrameScriptExecutorJSObjectHolder*>*
|
nsDataHashtable<nsStringHashKey, nsFrameScriptExecutorJSObjectHolder*>*
|
||||||
nsFrameScriptExecutor::sCachedScripts = nsnull;
|
nsFrameScriptExecutor::sCachedScripts = nsnull;
|
||||||
|
nsRefPtr<nsScriptCacheCleaner> nsFrameScriptExecutor::sScriptCacheCleaner;
|
||||||
|
|
||||||
void
|
void
|
||||||
nsFrameScriptExecutor::DidCreateCx()
|
nsFrameScriptExecutor::DidCreateCx()
|
||||||
@ -519,6 +520,8 @@ nsFrameScriptExecutor::DidCreateCx()
|
|||||||
sCachedScripts =
|
sCachedScripts =
|
||||||
new nsDataHashtable<nsStringHashKey, nsFrameScriptExecutorJSObjectHolder*>;
|
new nsDataHashtable<nsStringHashKey, nsFrameScriptExecutorJSObjectHolder*>;
|
||||||
sCachedScripts->Init();
|
sCachedScripts->Init();
|
||||||
|
|
||||||
|
sScriptCacheCleaner = new nsScriptCacheCleaner();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -564,6 +567,8 @@ nsFrameScriptExecutor::Shutdown()
|
|||||||
|
|
||||||
delete sCachedScripts;
|
delete sCachedScripts;
|
||||||
sCachedScripts = nsnull;
|
sCachedScripts = nsnull;
|
||||||
|
|
||||||
|
sScriptCacheCleaner = nsnull;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -672,3 +677,6 @@ nsFrameScriptExecutor::LoadFrameScriptInternal(const nsAString& aURL)
|
|||||||
nsContentUtils::ThreadJSContextStack()->Pop(&unused);
|
nsContentUtils::ThreadJSContextStack()->Pop(&unused);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMPL_ISUPPORTS1(nsScriptCacheCleaner, nsIObserver);
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#define nsFrameMessageManager_h__
|
#define nsFrameMessageManager_h__
|
||||||
|
|
||||||
#include "nsIFrameMessageManager.h"
|
#include "nsIFrameMessageManager.h"
|
||||||
|
#include "nsIObserver.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsAutoPtr.h"
|
#include "nsAutoPtr.h"
|
||||||
#include "nsCOMArray.h"
|
#include "nsCOMArray.h"
|
||||||
@ -48,6 +49,8 @@
|
|||||||
#include "nsIPrincipal.h"
|
#include "nsIPrincipal.h"
|
||||||
#include "nsIXPConnect.h"
|
#include "nsIXPConnect.h"
|
||||||
#include "nsDataHashtable.h"
|
#include "nsDataHashtable.h"
|
||||||
|
#include "mozilla/Services.h"
|
||||||
|
#include "nsIObserverService.h"
|
||||||
|
|
||||||
class nsAXPCNativeCallContext;
|
class nsAXPCNativeCallContext;
|
||||||
struct JSContext;
|
struct JSContext;
|
||||||
@ -153,6 +156,8 @@ protected:
|
|||||||
nsTArray<nsString> mPendingScripts;
|
nsTArray<nsString> mPendingScripts;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class nsScriptCacheCleaner;
|
||||||
|
|
||||||
struct nsFrameScriptExecutorJSObjectHolder
|
struct nsFrameScriptExecutorJSObjectHolder
|
||||||
{
|
{
|
||||||
nsFrameScriptExecutorJSObjectHolder(JSObject* aObject) : mObject(aObject) {}
|
nsFrameScriptExecutorJSObjectHolder(JSObject* aObject) : mObject(aObject) {}
|
||||||
@ -173,6 +178,27 @@ protected:
|
|||||||
JSContext* mCx;
|
JSContext* mCx;
|
||||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||||
static nsDataHashtable<nsStringHashKey, nsFrameScriptExecutorJSObjectHolder*>* sCachedScripts;
|
static nsDataHashtable<nsStringHashKey, nsFrameScriptExecutorJSObjectHolder*>* sCachedScripts;
|
||||||
|
static nsRefPtr<nsScriptCacheCleaner> sScriptCacheCleaner;
|
||||||
|
};
|
||||||
|
|
||||||
|
class nsScriptCacheCleaner : public nsIObserver
|
||||||
|
{
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
|
nsScriptCacheCleaner()
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService();
|
||||||
|
if (obsSvc)
|
||||||
|
obsSvc->AddObserver(this, "xpcom-shutdown", PR_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP Observe(nsISupports *aSubject,
|
||||||
|
const char *aTopic,
|
||||||
|
const PRUnichar *aData)
|
||||||
|
{
|
||||||
|
nsFrameScriptExecutor::Shutdown();
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user