Addressing bug #41276, r=sean@beatnik.com
git-svn-id: svn://10.0.0.236/trunk@72264 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -102,6 +102,7 @@ nsActivePlugin::nsActivePlugin(nsIPluginInstance* aInstance, char * url)
|
||||
NS_ADDREF(aInstance);
|
||||
}
|
||||
mStopped = PR_FALSE;
|
||||
mllStopTime = LL_ZERO;
|
||||
}
|
||||
|
||||
nsActivePlugin::~nsActivePlugin()
|
||||
@@ -115,6 +116,15 @@ nsActivePlugin::~nsActivePlugin()
|
||||
PL_strfree(mURL);
|
||||
}
|
||||
|
||||
void nsActivePlugin::setStopped(PRBool stopped)
|
||||
{
|
||||
mStopped = stopped;
|
||||
if(mStopped)
|
||||
mllStopTime = PR_Now();
|
||||
else
|
||||
mllStopTime = LL_ZERO;
|
||||
}
|
||||
|
||||
nsActivePluginList::nsActivePluginList()
|
||||
{
|
||||
first = nsnull;
|
||||
@@ -220,6 +230,24 @@ PRUint32 nsActivePluginList::getStoppedCount()
|
||||
return stoppedCount;
|
||||
}
|
||||
|
||||
nsActivePlugin * nsActivePluginList::findOldestStopped()
|
||||
{
|
||||
nsActivePlugin * res = nsnull;
|
||||
PRInt64 llTime = LL_MAXINT;
|
||||
for(nsActivePlugin * p = first; p != nsnull; p = p->mNext)
|
||||
{
|
||||
if(!p->mStopped)
|
||||
continue;
|
||||
|
||||
if(LL_CMP(p->mllStopTime, <, llTime))
|
||||
{
|
||||
llTime = p->mllStopTime;
|
||||
res = p;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
nsPluginTag::nsPluginTag()
|
||||
{
|
||||
mNext = nsnull;
|
||||
@@ -1856,7 +1884,7 @@ nsresult nsPluginHostImpl::FindStoppedPluginForURL(nsIURI* aURL,
|
||||
aOwner->CreateWidget();
|
||||
instance->SetWindow(window);
|
||||
|
||||
plugin->mStopped = PR_FALSE;
|
||||
plugin->setStopped(PR_FALSE);
|
||||
nsCRT::free(url);
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -2642,7 +2670,15 @@ nsPluginHostImpl::StopPluginInstance(nsIPluginInstance* aInstance)
|
||||
nsActivePlugin * plugin = mActivePluginList.find(aInstance);
|
||||
|
||||
if(plugin != nsnull)
|
||||
plugin->mStopped = PR_TRUE;
|
||||
{
|
||||
if(mActivePluginList.getStoppedCount() >= MAX_NUMBER_OF_STOPPED_PLUGINS)
|
||||
{
|
||||
nsActivePlugin * oldest = mActivePluginList.findOldestStopped();
|
||||
if(oldest != nsnull)
|
||||
mActivePluginList.remove(oldest);
|
||||
}
|
||||
plugin->setStopped(PR_TRUE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -68,12 +68,15 @@ struct nsActivePlugin
|
||||
nsIPluginInstancePeer* mPeer;
|
||||
nsIPluginInstance* mInstance;
|
||||
PRBool mStopped;
|
||||
PRTime mllStopTime;
|
||||
|
||||
nsActivePlugin(nsIPluginInstance* aInstance, char * url);
|
||||
~nsActivePlugin();
|
||||
|
||||
void setStopped(PRBool stopped);
|
||||
};
|
||||
|
||||
#define MAX_NUMBER_OF_STOPPED_PLUGINS 16
|
||||
#define MAX_NUMBER_OF_STOPPED_PLUGINS 10
|
||||
|
||||
class nsActivePluginList
|
||||
{
|
||||
@@ -91,6 +94,7 @@ public:
|
||||
nsActivePlugin * find(nsIPluginInstance* instance);
|
||||
nsActivePlugin * findStopped(char * url);
|
||||
PRUint32 getStoppedCount();
|
||||
nsActivePlugin * findOldestStopped();
|
||||
};
|
||||
|
||||
#define NS_PLUGIN_FLAG_ENABLED 0x0001 //is this plugin enabled?
|
||||
|
||||
@@ -102,6 +102,7 @@ nsActivePlugin::nsActivePlugin(nsIPluginInstance* aInstance, char * url)
|
||||
NS_ADDREF(aInstance);
|
||||
}
|
||||
mStopped = PR_FALSE;
|
||||
mllStopTime = LL_ZERO;
|
||||
}
|
||||
|
||||
nsActivePlugin::~nsActivePlugin()
|
||||
@@ -115,6 +116,15 @@ nsActivePlugin::~nsActivePlugin()
|
||||
PL_strfree(mURL);
|
||||
}
|
||||
|
||||
void nsActivePlugin::setStopped(PRBool stopped)
|
||||
{
|
||||
mStopped = stopped;
|
||||
if(mStopped)
|
||||
mllStopTime = PR_Now();
|
||||
else
|
||||
mllStopTime = LL_ZERO;
|
||||
}
|
||||
|
||||
nsActivePluginList::nsActivePluginList()
|
||||
{
|
||||
first = nsnull;
|
||||
@@ -220,6 +230,24 @@ PRUint32 nsActivePluginList::getStoppedCount()
|
||||
return stoppedCount;
|
||||
}
|
||||
|
||||
nsActivePlugin * nsActivePluginList::findOldestStopped()
|
||||
{
|
||||
nsActivePlugin * res = nsnull;
|
||||
PRInt64 llTime = LL_MAXINT;
|
||||
for(nsActivePlugin * p = first; p != nsnull; p = p->mNext)
|
||||
{
|
||||
if(!p->mStopped)
|
||||
continue;
|
||||
|
||||
if(LL_CMP(p->mllStopTime, <, llTime))
|
||||
{
|
||||
llTime = p->mllStopTime;
|
||||
res = p;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
nsPluginTag::nsPluginTag()
|
||||
{
|
||||
mNext = nsnull;
|
||||
@@ -1856,7 +1884,7 @@ nsresult nsPluginHostImpl::FindStoppedPluginForURL(nsIURI* aURL,
|
||||
aOwner->CreateWidget();
|
||||
instance->SetWindow(window);
|
||||
|
||||
plugin->mStopped = PR_FALSE;
|
||||
plugin->setStopped(PR_FALSE);
|
||||
nsCRT::free(url);
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -2642,7 +2670,15 @@ nsPluginHostImpl::StopPluginInstance(nsIPluginInstance* aInstance)
|
||||
nsActivePlugin * plugin = mActivePluginList.find(aInstance);
|
||||
|
||||
if(plugin != nsnull)
|
||||
plugin->mStopped = PR_TRUE;
|
||||
{
|
||||
if(mActivePluginList.getStoppedCount() >= MAX_NUMBER_OF_STOPPED_PLUGINS)
|
||||
{
|
||||
nsActivePlugin * oldest = mActivePluginList.findOldestStopped();
|
||||
if(oldest != nsnull)
|
||||
mActivePluginList.remove(oldest);
|
||||
}
|
||||
plugin->setStopped(PR_TRUE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -68,12 +68,15 @@ struct nsActivePlugin
|
||||
nsIPluginInstancePeer* mPeer;
|
||||
nsIPluginInstance* mInstance;
|
||||
PRBool mStopped;
|
||||
PRTime mllStopTime;
|
||||
|
||||
nsActivePlugin(nsIPluginInstance* aInstance, char * url);
|
||||
~nsActivePlugin();
|
||||
|
||||
void setStopped(PRBool stopped);
|
||||
};
|
||||
|
||||
#define MAX_NUMBER_OF_STOPPED_PLUGINS 16
|
||||
#define MAX_NUMBER_OF_STOPPED_PLUGINS 10
|
||||
|
||||
class nsActivePluginList
|
||||
{
|
||||
@@ -91,6 +94,7 @@ public:
|
||||
nsActivePlugin * find(nsIPluginInstance* instance);
|
||||
nsActivePlugin * findStopped(char * url);
|
||||
PRUint32 getStoppedCount();
|
||||
nsActivePlugin * findOldestStopped();
|
||||
};
|
||||
|
||||
#define NS_PLUGIN_FLAG_ENABLED 0x0001 //is this plugin enabled?
|
||||
|
||||
Reference in New Issue
Block a user