nsresult rv = NS_OK; nsCOMPtr<nsIURI> aURL; nsCOMPtr<nsIChannel> channel = do_QueryInterface(request); if (!channel) return NS_ERROR_FAILURE;  rv = channel->GetURI(getter_AddRefs(aURL)); if (NS_FAILED(rv)) return rv;  if(nsnull != mPStreamListener) { char* urlString; nsCOMPtr<nsIFile> localFile;  nsCOMPtr<nsICachingChannel> cacheChannel = do_QueryInterface(channel); if (cacheChannel) rv = cacheChannel->GetCacheFile(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv) && localFile) { char* pathAndFilename; rv = localFile->GetPath(&pathAndFilename); if (NS_SUCCEEDED(rv)) { OnFileAvailable(pathAndFilename); nsMemory::Free(pathAndFilename); } }  rv = aURL->GetSpec(&urlString); if (NS_SUCCEEDED(rv)) { mPluginStreamInfo->SetURL(urlString); nsCRT::free(urlString); }   char* aContentType = nsnull; rv = channel->GetContentType(&aContentType); if (NS_FAILED(rv)) return rv;  if (nsnull != aContentType) mPluginStreamInfo->SetContentType(aContentType);  if (mStartBinding) {  mPStreamListener->OnStopBinding((nsIPluginStreamInfo*)mPluginStreamInfo, aStatus); } else {  mPStreamListener->OnStartBinding((nsIPluginStreamInfo*)mPluginStreamInfo); mPStreamListener->OnStopBinding((nsIPluginStreamInfo*)mPluginStreamInfo, aStatus); }  if (aContentType) nsCRT::free(aContentType); }  return rv;
return NS_OK;
NS_IMETHODIMP nsPluginStreamListenerPeer::OnStopRequest(nsIRequest *request,                                                         nsISupports* aContext,                                                        nsresult aStatus){  nsresult rv = NS_OK;  nsCOMPtr<nsIURI> aURL;  nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);  if (!channel)     return NS_ERROR_FAILURE;  rv = channel->GetURI(getter_AddRefs(aURL));  if (NS_FAILED(rv))     return rv;  if(nsnull != mPStreamListener)  {    char* urlString;    nsCOMPtr<nsIFile> localFile;    nsCOMPtr<nsICachingChannel> cacheChannel = do_QueryInterface(channel);    if (cacheChannel)        rv = cacheChannel->GetCacheFile(getter_AddRefs(localFile));    if (NS_SUCCEEDED(rv) && localFile)    {      char* pathAndFilename;      rv = localFile->GetPath(&pathAndFilename);      if (NS_SUCCEEDED(rv))      {        OnFileAvailable(pathAndFilename);        nsMemory::Free(pathAndFilename);      }    }    rv = aURL->GetSpec(&urlString);    if (NS_SUCCEEDED(rv))     {      mPluginStreamInfo->SetURL(urlString);      nsCRT::free(urlString);    }    // Set the content type to ensure we don't pass null to the plugin    char* aContentType = nsnull;    rv = channel->GetContentType(&aContentType);    if (NS_FAILED(rv))       return rv;    if (nsnull != aContentType)      mPluginStreamInfo->SetContentType(aContentType);    if (mStartBinding)    {      // On start binding has been called      mPStreamListener->OnStopBinding((nsIPluginStreamInfo*)mPluginStreamInfo, aStatus);    }    else    {      // OnStartBinding hasn't been called, so complete the action.      mPStreamListener->OnStartBinding((nsIPluginStreamInfo*)mPluginStreamInfo);      mPStreamListener->OnStopBinding((nsIPluginStreamInfo*)mPluginStreamInfo, aStatus);    }    if (aContentType)      nsCRT::free(aContentType);  }  return rv;}