NS_IMETHODIMP nsMsgProgress::OnProgress(nsIRequest *request, nsISupports* ctxt, PRUint64 aProgress, PRUint64 aProgressMax) { // XXX: What should the nsIWebProgress be? // XXX: This truncates 64-bit to 32-bit return OnProgressChange(nsnull, request, nsUint64(aProgress), nsUint64(aProgressMax), nsUint64(aProgress) /* current total progress */, nsUint64(aProgressMax) /* max total progress */); }
NS_IMETHODIMP WebBrowserChrome::OnStateChange(nsIWebProgress* progress, nsIRequest* request, uint32_t progressStateFlags, nsresult status) { NS_ENSURE_TRUE(mListener, NS_ERROR_FAILURE); nsCOMPtr<nsIDOMWindow> docWin = do_GetInterface(mWebBrowser); nsCOMPtr<nsIDOMWindow> progWin; progress->GetDOMWindow(getter_AddRefs(progWin)); if (progWin != docWin) { return NS_OK; } nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(mWebBrowser); nsCOMPtr<nsIDOMWindowUtils> utils = do_GetInterface(window); if (!utils) { NS_WARNING("window Utils are null"); return NS_OK; } uint64_t currentInnerWindowID = 0; utils->GetCurrentInnerWindowID(¤tInnerWindowID); if (progressStateFlags & nsIWebProgressListener::STATE_START) { if (progressStateFlags & nsIWebProgressListener::STATE_IS_NETWORK) { // Reset filter members mTotalRequests = mFinishedRequests = 0; } if (progressStateFlags & nsIWebProgressListener::STATE_IS_REQUEST) // Filter optimization: If we have more than one request, show progress //based on requests completing, not on percent loaded of each request { ++mTotalRequests; } } else if (progressStateFlags & nsIWebProgressListener::STATE_STOP) { if (progressStateFlags & nsIWebProgressListener::STATE_IS_REQUEST) { // Filter optimization: Request has completed, so send a "progress change" // Note: aRequest is null ++mFinishedRequests; OnProgressChange(progress, nullptr, 0, 0, mFinishedRequests, mTotalRequests); } } if (progressStateFlags & nsIWebProgressListener::STATE_START && progressStateFlags & nsIWebProgressListener::STATE_IS_DOCUMENT) { mListener->OnLoadStarted(mLastLocation.get()); } if (progressStateFlags & nsIWebProgressListener::STATE_STOP && progressStateFlags & nsIWebProgressListener::STATE_IS_DOCUMENT) { mListener->OnLoadFinished(); } if (progressStateFlags & nsIWebProgressListener::STATE_REDIRECTING) { mListener->OnLoadRedirect(); } return NS_OK; }
//----------------------------------------------------------------------------- // nsBrowserStatusFilter::nsIWebProgressListener2 //----------------------------------------------------------------------------- NS_IMETHODIMP nsBrowserStatusFilter::OnProgressChange64(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRInt64 aCurSelfProgress, PRInt64 aMaxSelfProgress, PRInt64 aCurTotalProgress, PRInt64 aMaxTotalProgress) { // XXX truncates 64-bit to 32-bit return OnProgressChange(aWebProgress, aRequest, (PRInt32)aCurSelfProgress, (PRInt32)aMaxSelfProgress, (PRInt32)aCurTotalProgress, (PRInt32)aMaxTotalProgress); }
NS_IMETHODIMP nsBrowserStatusFilter::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags, nsresult aStatus) { if (!mListener) return NS_OK; if (aStateFlags & STATE_START) { if (aStateFlags & STATE_IS_NETWORK) { ResetMembers(); } if (aStateFlags & STATE_IS_REQUEST) { ++mTotalRequests; // if the total requests exceeds 1, then we'll base our progress // notifications on the percentage of completed requests. // otherwise, progress for the single request will be reported. mUseRealProgressFlag = (mTotalRequests == 1); } } else if (aStateFlags & STATE_STOP) { if (aStateFlags & STATE_IS_REQUEST) { ++mFinishedRequests; // Note: Do not return from here. This is necessary so that the // STATE_STOP can still be relayed to the listener if needed // (bug 209330) if (!mUseRealProgressFlag && mTotalRequests) OnProgressChange(nsnull, nsnull, 0, 0, mFinishedRequests, mTotalRequests); } } else if (aStateFlags & STATE_TRANSFERRING) { if (aStateFlags & STATE_IS_REQUEST) { if (!mUseRealProgressFlag && mTotalRequests) return OnProgressChange(nsnull, nsnull, 0, 0, mFinishedRequests, mTotalRequests); } // no need to forward this state change return NS_OK; } else { // no need to forward this state change return NS_OK; } // If we're here, we have either STATE_START or STATE_STOP. The // listener only cares about these in certain conditions. PRBool isLoadingDocument = PR_FALSE; if ((aStateFlags & nsIWebProgressListener::STATE_IS_NETWORK || (aStateFlags & nsIWebProgressListener::STATE_IS_REQUEST && mFinishedRequests == mTotalRequests && (aWebProgress->GetIsLoadingDocument(&isLoadingDocument), !isLoadingDocument)))) { if (mTimer && (aStateFlags & nsIWebProgressListener::STATE_STOP)) { mTimer->Cancel(); ProcessTimeout(); } return mListener->OnStateChange(aWebProgress, aRequest, aStateFlags, aStatus); } return NS_OK; }
NS_IMETHODIMP EmbedDownload::OnProgressChange64(nsIWebProgress *aProgress, nsIRequest *aRequest, PRInt64 curSelfProgress, PRInt64 maxSelfProgress, PRInt64 curTotalProgress, PRInt64 maxTotalProgress) { // XXX truncates 64-bit to 32-bit return OnProgressChange(aProgress, aRequest, PRInt32(curSelfProgress), PRInt32(maxSelfProgress), PRInt32(curTotalProgress), PRInt32(maxTotalProgress)); }