Landing fix for bug 342810. Fixing leak of nsRunnable (huge leak on some flash sites). Patch by jmathies@mozilla.com, r+sr=jst@mozilla.com

git-svn-id: svn://10.0.0.236/trunk@228121 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jst%mozilla.org
2007-06-15 16:23:45 +00:00
parent 637e3a29f7
commit 00b2c57d72
2 changed files with 48 additions and 40 deletions

View File

@@ -73,10 +73,10 @@ public:
void Init(const PluginWindowWeakRef &ref, HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2);
void Clear();
HWND GetWnd() { return mWnd; };
ULONG GetMsg() { return mMsg; };
ULONG GetMsg() { return mMsg; };
MPARAM GetWParam() { return mWParam; };
MPARAM GetLParam() { return mLParam; };
PRBool InUse() { return (mWnd!=NULL || mMsg!=0); };
PRBool InUse() { return (mWnd!=NULL); };
NS_DECL_NSIRUNNABLE
@@ -86,7 +86,6 @@ protected:
ULONG mMsg;
MPARAM mWParam;
MPARAM mLParam;
PRBool mIsAlloced;
};
PluginWindowEvent::PluginWindowEvent()
@@ -97,16 +96,13 @@ PluginWindowEvent::PluginWindowEvent()
void PluginWindowEvent::Clear()
{
mWnd = NULL;
mMsg = 0;
mWParam = 0;
mLParam = 0;
}
void PluginWindowEvent::Init(const PluginWindowWeakRef &ref, HWND aWnd,
ULONG aMsg, MPARAM mp1, MPARAM mp2)
{
NS_ASSERTION(aWnd!=NULL && aMsg!=0, "invalid plugin event value");
NS_ASSERTION(mWnd==NULL && mMsg==0 && mWParam==0 && mLParam==0,"event already in use");
NS_ASSERTION(aWnd != NULL, "invalid plugin event value");
NS_ASSERTION(mWnd == NULL, "event already in use");
mPluginWindowRef = ref;
mWnd = aWnd;
mMsg = aMsg;
@@ -139,8 +135,10 @@ private:
public:
// locals
PFNWP GetWindowProc();
already_AddRefed<nsIRunnable> GetPluginWindowEvent(HWND aWnd, ULONG aMsg,
MPARAM mp1, MPARAM mp2);
PluginWindowEvent* GetPluginWindowEvent(HWND aWnd,
ULONG aMsg,
MPARAM mp1,
MPARAM mp2);
private:
PFNWP mPluginWinProc;
@@ -272,7 +270,7 @@ NS_IMETHODIMP PluginWindowEvent::Run()
return NS_OK;
}
already_AddRefed<nsIRunnable>
PluginWindowEvent*
nsPluginNativeWindowOS2::GetPluginWindowEvent(HWND aWnd, ULONG aMsg, MPARAM aMp1, MPARAM aMp2)
{
if (!mWeakRef) {
@@ -282,24 +280,29 @@ nsPluginNativeWindowOS2::GetPluginWindowEvent(HWND aWnd, ULONG aMsg, MPARAM aMp1
}
PluginWindowEvent *event;
if (!mCachedPluginWindowEvent || mCachedPluginWindowEvent->InUse()) {
// We have the ability to alloc if needed in case in the future some plugin
// should post multiple PostMessages. However, this could lead to many
// alloc's per second which could become a performance issue. If/when this
// is asserting then this needs to be studied. See bug 169247
NS_ASSERTION(1, "possible plugin performance issue");
// We have the ability to alloc if needed in case in the future some plugin
// should post multiple PostMessages. However, this could lead to many
// alloc's per second which could become a performance issue. See bug 169247.
if (!mCachedPluginWindowEvent)
{
event = new PluginWindowEvent();
if (!event)
return nsnull;
if (!event) return nsnull;
mCachedPluginWindowEvent = event;
}
else {
else if (mCachedPluginWindowEvent->InUse())
{
event = new PluginWindowEvent();
if (!event) return nsnull;
}
else
{
event = mCachedPluginWindowEvent;
}
NS_ADDREF(event);
event->Init(mWeakRef, aWnd, aMsg, aMp1, aMp2);
return event;
};
}
nsresult nsPluginNativeWindowOS2::CallSetWindow(nsCOMPtr<nsIPluginInstance> &aPluginInstance)
{