Bug 151920 -- converting nsPluginHostImpl::AddInstanceToActiveList from void to nsresult, r=serge, sr=darin

This commit is contained in:
av%netscape.com 2002-08-12 06:12:29 +00:00
Родитель 900e798ac1
Коммит 43ddec14cc
2 изменённых файлов: 20 добавлений и 30 удалений

Просмотреть файл

@ -3783,49 +3783,39 @@ nsresult nsPluginHostImpl::FindStoppedPluginForURL(nsIURI* aURL,
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
void nsPluginHostImpl::AddInstanceToActiveList(nsCOMPtr<nsIPlugin> aPlugin, nsresult nsPluginHostImpl::AddInstanceToActiveList(nsCOMPtr<nsIPlugin> aPlugin,
nsIPluginInstance* aInstance, nsIPluginInstance* aInstance,
nsIURI* aURL, nsIURI* aURL,
PRBool aDefaultPlugin, PRBool aDefaultPlugin,
nsIPluginInstancePeer* peer) nsIPluginInstancePeer* peer)
{ {
NS_ENSURE_ARG_POINTER(aURL);
nsCAutoString url; nsCAutoString url;
if(!aURL)
return;
(void)aURL->GetSpec(url); (void)aURL->GetSpec(url);
// find corresponding plugin tag // let's find the corresponding plugin tag by matching nsIPlugin pointer
// this is legal for xpcom plugins not to have nsIPlugin implemented // it's legal for XPCOM plugins not to have nsIPlugin implemented but
// this is OK, we don't need the plugin tag for XPCOM plugins. It is going
// to be used later when we decide whether or not we should delay unloading
// NPAPI dll from memory, and XPCOM dlls will stay in memory anyway.
nsPluginTag * pluginTag = nsnull; nsPluginTag * pluginTag = nsnull;
if(aPlugin) if(aPlugin) {
{ for(pluginTag = mPlugins; pluginTag != nsnull; pluginTag = pluginTag->mNext) {
for(pluginTag = mPlugins; pluginTag != nsnull; pluginTag = pluginTag->mNext)
{
if(pluginTag->mEntryPoint == aPlugin) if(pluginTag->mEntryPoint == aPlugin)
break; break;
} }
NS_ASSERTION(pluginTag, "Plugin tag not found"); NS_ASSERTION(pluginTag, "Plugin tag not found");
} }
else
{
// we don't need it for xpcom plugins because the only purpose to have it
// is to be able to postpone unloading library dll in some circumstances
// which we don't do for xpcom plugins. In case we need it in the future
// we can probably use the following
/*
FindPluginEnabledForType(mimetype, pluginTag);
*/
}
nsActivePlugin * plugin = new nsActivePlugin(pluginTag, aInstance, url.get(), aDefaultPlugin, peer); nsActivePlugin * plugin = new nsActivePlugin(pluginTag, aInstance, url.get(), aDefaultPlugin, peer);
if(plugin == nsnull) if(!plugin)
return; return NS_ERROR_OUT_OF_MEMORY;
mActivePluginList.add(plugin); mActivePluginList.add(plugin);
return NS_OK;
} }
@ -4100,8 +4090,8 @@ NS_IMETHODIMP nsPluginHostImpl::TrySetUpPluginInstance(const char *aMimeType,
if (NS_FAILED(result)) // except in some cases not Java, see bug 140931 if (NS_FAILED(result)) // except in some cases not Java, see bug 140931
return result; // our COM pointer will free the peer return result; // our COM pointer will free the peer
// we should addref here // instance and peer will be addreffed here
AddInstanceToActiveList(plugin, instance, aURL, PR_FALSE, pIpeer); result = AddInstanceToActiveList(plugin, instance, aURL, PR_FALSE, pIpeer);
//release what was addreffed in Create(Plugin)Instance //release what was addreffed in Create(Plugin)Instance
NS_RELEASE(instance); NS_RELEASE(instance);
@ -4117,7 +4107,7 @@ NS_IMETHODIMP nsPluginHostImpl::TrySetUpPluginInstance(const char *aMimeType,
PR_LogFlush(); PR_LogFlush();
#endif #endif
return NS_OK; return result;
} }
@ -4196,13 +4186,13 @@ nsresult nsPluginHostImpl::SetUpDefaultPluginInstance(const char *aMimeType, nsI
if (NS_FAILED(result)) // except in some cases not Java, see bug 140931 if (NS_FAILED(result)) // except in some cases not Java, see bug 140931
return result; // our COM pointer will free the peer return result; // our COM pointer will free the peer
// we should addref here // instance and peer will be addreffed here
AddInstanceToActiveList(plugin, instance, aURL, PR_FALSE, pIpeer); result = AddInstanceToActiveList(plugin, instance, aURL, PR_TRUE, pIpeer);
//release what was addreffed in Create(Plugin)Instance //release what was addreffed in Create(Plugin)Instance
NS_RELEASE(instance); NS_RELEASE(instance);
return NS_OK; return result;
} }

Просмотреть файл

@ -406,7 +406,7 @@ private:
nsresult nsresult
SetUpDefaultPluginInstance(const char *aMimeType, nsIURI *aURL, nsIPluginInstanceOwner *aOwner); SetUpDefaultPluginInstance(const char *aMimeType, nsIURI *aURL, nsIPluginInstanceOwner *aOwner);
void nsresult
AddInstanceToActiveList(nsCOMPtr<nsIPlugin> aPlugin, AddInstanceToActiveList(nsCOMPtr<nsIPlugin> aPlugin,
nsIPluginInstance* aInstance, nsIPluginInstance* aInstance,
nsIURI* aURL, PRBool aDefaultPlugin, nsIURI* aURL, PRBool aDefaultPlugin,