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;
mHaveFiredOnStartRequest = PR_TRUE;     if (mOwner) { nsCOMPtr<nsIPluginTagInfo2> pti2 = do_QueryInterface(mOwner); NS_ENSURE_TRUE(pti2, NS_ERROR_FAILURE); nsPluginTagType tagType; if (NS_FAILED(pti2->GetTagType(&tagType))) return NS_ERROR_FAILURE; }  nsCOMPtr<nsIChannel> channel = do_QueryInterface(request); NS_ENSURE_TRUE(channel, NS_ERROR_FAILURE);    nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel)); if (httpChannel) { PRUint32 responseCode = 0; rv = httpChannel->GetResponseStatus(&responseCode); if (NS_FAILED(rv) || responseCode > 206) {     mRequestFailed = PR_TRUE; return NS_ERROR_FAILURE; }     nsCOMPtr<nsIInterfaceRequestor> callbacks; channel->GetNotificationCallbacks(getter_AddRefs(callbacks)); if (callbacks) mWeakPtrChannelCallbacks = getter_AddRefs(NS_GetWeakReference(callbacks));  nsCOMPtr<nsILoadGroup> loadGroup; channel->GetLoadGroup(getter_AddRefs(loadGroup)); if (loadGroup) mWeakPtrChannelLoadGroup = getter_AddRefs(NS_GetWeakReference(loadGroup)); }  PRInt32 length; rv = channel->GetContentLength(&length);    if (NS_FAILED(rv) || length == -1) {  nsCOMPtr<nsIFileChannel> fileChannel = do_QueryInterface(channel); if (fileChannel) {  mRequestFailed = PR_TRUE; return NS_ERROR_FAILURE; } mPluginStreamInfo->SetLength(PRUint32(0)); } else { mPluginStreamInfo->SetLength(length); }  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) mInstance->SetWindow(window); } }
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;}