nsPluginStreamListenerPeer *pslp = NS_REINTERPRET_CAST(nsPluginStreamListenerPeer*, finalStreamListener.get()); rv = pslp->ServeStreamAsFile(request, ctxt);
nsCAutoString aContentType; rv = channel->GetContentType(aContentType); if (NS_FAILED(rv)) return rv;  nsCOMPtr<nsIURI> aURL; rv = channel->GetURI(getter_AddRefs(aURL)); if (NS_FAILED(rv)) return rv;  nsCAutoString urlSpec; aURL->GetSpec(urlSpec); mPluginStreamInfo->SetURL(urlSpec.get());  if (!aContentType.IsEmpty()) mPluginStreamInfo->SetContentType(aContentType.get());  #ifdef PLUGIN_LOGGING PR_LOG(nsPluginLogging::gPluginLog, PLUGIN_LOG_NOISY, ("nsPluginStreamListenerPeer::OnStartRequest this=%p request=%p mime=%s, url=%s\n", this, request, aContentType.get(), urlSpec.get()));  PR_LogFlush(); #endif  nsPluginWindow    *window = nsnull;         if ((nsnull == mInstance) && (nsnull != mOwner) && (!aContentType.IsEmpty())) { mOwner->GetInstance(mInstance); mOwner->GetWindow(window);  if ((nsnull == mInstance) && (nsnull != mHost) && (nsnull != window)) {  nsPluginMode mode; mOwner->GetMode(&mode); if (mode == nsPluginMode_Embedded) rv = mHost->InstantiateEmbededPlugin(aContentType.get(), aURL, mOwner); else rv = mHost->SetUpPluginInstance(aContentType.get(), aURL, mOwner);  if (NS_OK == rv) {  mOwner->GetInstance(mInstance);  if (nsnull != mInstance) { mInstance->Start(); mOwner->CreateWidget();    if (window->window) { nsCOMPtr<nsIPluginInstance> inst = mInstance; ((nsPluginNativeWindow*)window)->CallSetWindow(inst); } } } } }     rv = SetUpStreamListener(request, aURL); if (NS_FAILED(rv)) return rv;
nsPluginByteRangeStreamListener::OnStartRequest(nsIRequest *request, nsISupports *ctxt){  nsresult rv;  nsCOMPtr<nsIStreamListener> finalStreamListener = do_QueryReferent(mWeakPtrPluginStreamListenerPeer);  if (!finalStreamListener)     return NS_ERROR_FAILURE;  nsCOMPtr<nsIStreamConverterService> serv = do_GetService(kStreamConverterServiceCID, &rv);  if (NS_SUCCEEDED(rv)) {    rv = serv->AsyncConvertData(MULTIPART_BYTERANGES,                                "*/*",                                finalStreamListener,                                nsnull,                                getter_AddRefs(mStreamConverter));    if (NS_SUCCEEDED(rv)) {      rv = mStreamConverter->OnStartRequest(request, ctxt);      if (NS_SUCCEEDED(rv))        return rv;    }  }  mStreamConverter = 0;  nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(request));  if (!httpChannel) {    return NS_ERROR_FAILURE;  }  PRUint32 responseCode = 0;  rv = httpChannel->GetResponseStatus(&responseCode);  if (NS_FAILED(rv) || responseCode != 200) {    return NS_ERROR_FAILURE;  }  // if server cannot continue with byte range (206 status) and sending us whole object (200 status)  // reset this seekable stream & try serve it to plugin instance as a file  mStreamConverter = finalStreamListener;  mRemoveMagicNumber = PR_TRUE;  //get nsPluginStreamListenerPeer* ptr from finalStreamListener  nsPluginStreamListenerPeer *pslp = NS_REINTERPRET_CAST(nsPluginStreamListenerPeer*,                                                         finalStreamListener.get());  rv = pslp->ServeStreamAsFile(request, ctxt);  return rv;}