зеркало из https://github.com/mozilla/gecko-dev.git
Bug 587222 - Script caching in messageManager leaks; r=Olli.Pettay a=blocking-because-550936-is-a-blocker
This commit is contained in:
Родитель
7524900158
Коммит
8ce748968c
|
@ -510,6 +510,7 @@ NS_NewGlobalMessageManager(nsIChromeFrameMessageManager** aResult)
|
|||
|
||||
nsDataHashtable<nsStringHashKey, nsFrameScriptExecutorJSObjectHolder*>*
|
||||
nsFrameScriptExecutor::sCachedScripts = nsnull;
|
||||
nsRefPtr<nsScriptCacheCleaner> nsFrameScriptExecutor::sScriptCacheCleaner;
|
||||
|
||||
void
|
||||
nsFrameScriptExecutor::DidCreateCx()
|
||||
|
@ -519,6 +520,8 @@ nsFrameScriptExecutor::DidCreateCx()
|
|||
sCachedScripts =
|
||||
new nsDataHashtable<nsStringHashKey, nsFrameScriptExecutorJSObjectHolder*>;
|
||||
sCachedScripts->Init();
|
||||
|
||||
sScriptCacheCleaner = new nsScriptCacheCleaner();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -564,6 +567,8 @@ nsFrameScriptExecutor::Shutdown()
|
|||
|
||||
delete sCachedScripts;
|
||||
sCachedScripts = nsnull;
|
||||
|
||||
sScriptCacheCleaner = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -672,3 +677,6 @@ nsFrameScriptExecutor::LoadFrameScriptInternal(const nsAString& aURL)
|
|||
nsContentUtils::ThreadJSContextStack()->Pop(&unused);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsScriptCacheCleaner, nsIObserver);
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#define nsFrameMessageManager_h__
|
||||
|
||||
#include "nsIFrameMessageManager.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCOMArray.h"
|
||||
|
@ -48,6 +49,8 @@
|
|||
#include "nsIPrincipal.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "nsIObserverService.h"
|
||||
|
||||
class nsAXPCNativeCallContext;
|
||||
struct JSContext;
|
||||
|
@ -153,6 +156,8 @@ protected:
|
|||
nsTArray<nsString> mPendingScripts;
|
||||
};
|
||||
|
||||
class nsScriptCacheCleaner;
|
||||
|
||||
struct nsFrameScriptExecutorJSObjectHolder
|
||||
{
|
||||
nsFrameScriptExecutorJSObjectHolder(JSObject* aObject) : mObject(aObject) {}
|
||||
|
@ -173,6 +178,27 @@ protected:
|
|||
JSContext* mCx;
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
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
|
||||
|
|
Загрузка…
Ссылка в новой задаче