if(mStreamType != nsPluginStreamType_AsFileOnly) {   rv =  mPStreamListener->OnDataAvailable((nsIPluginStreamInfo*)mPluginStreamInfo, aIStream, aLength);   if (NS_FAILED(rv)) request->Cancel(rv); } else {  char* buffer = new char[aLength]; PRUint32 amountRead; rv = aIStream->Read(buffer, aLength, &amountRead); delete [] buffer; }
nsresult rv = aIStream->Read(buffer, aLength, &readlen);  NS_ASSERTION(aLength == readlen, "nsCacheListener->OnDataAvailable: " "readlen != aLength");  PR_Free(buffer);
NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIRequest *request,                                                           nsISupports* aContext,                                                           nsIInputStream *aIStream,                                                           PRUint32 sourceOffset,                                                           PRUint32 aLength){  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(!mPStreamListener)	  return NS_ERROR_FAILURE;  char* urlString;  aURL->GetSpec(&urlString);  mPluginStreamInfo->SetURL(urlString);  nsCRT::free(urlString);  // if the plugin has requested an AsFileOnly stream, then don't   // call OnDataAvailable  if(mStreamType != nsPluginStreamType_AsFileOnly)  {    // It's up to the plugin to read from the stream     //  If it doesn't, OnStopRequest will never be called    rv =  mPStreamListener->OnDataAvailable((nsIPluginStreamInfo*)mPluginStreamInfo, aIStream, aLength);    // if a plugin returns an error, the peer must kill the stream    //   else the stream and PluginStreamListener leak    if (NS_FAILED(rv))      request->Cancel(rv);  }  else  {    // if we don't read from the stream, OnStopRequest will never be called    char* buffer = new char[aLength];    PRUint32 amountRead;    rv = aIStream->Read(buffer, aLength, &amountRead);    delete [] buffer;  }  return rv;}