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(NS_LITERAL_STRING(MULTIPART_BYTERANGES).get(), NS_LITERAL_STRING("*/*").get(), 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; }    mStreamConverter = finalStreamListener; mRemoveMagicNumber = PR_TRUE;   nsPluginStreamListenerPeer *pslp = NS_REINTERPRET_CAST(nsPluginStreamListenerPeer*, *(NS_REINTERPRET_CAST(void**, &finalStreamListener))); rv = pslp->ServeStreamAsFile(request, ctxt); return rv;
return NS_OK;
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(NS_LITERAL_STRING(MULTIPART_BYTERANGES).get(),                                NS_LITERAL_STRING("*/*").get(),                                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*,                                     *(NS_REINTERPRET_CAST(void**, &finalStreamListener)));  rv = pslp->ServeStreamAsFile(request, ctxt);  return rv;}