- add a new nsIWebProgressListener2 interface, inheriting from
  nsIWebProgressListener, providing a 64-bit onProgressChange method
- make nsITransfer inherit from that interface, and remove an unused
  progressListener attribute
- make webbrowserpersist support listeners that implement
  nsIWebProgressListener2, and give them 64-bit progress values
- make nsIHelperAppLauncher's listener setWebProgressListener function take an
  nsIWebProgressListener2 interface

And fix up all implementations according to that.
This commit is contained in:
cbiesinger%web.de 2005-04-05 23:24:23 +00:00
Родитель 517b250fd9
Коммит 6c453d00e6
25 изменённых файлов: 362 добавлений и 192 удалений

Просмотреть файл

@ -62,7 +62,9 @@ nsDownloadListener::~nsDownloadListener()
{
}
NS_IMPL_ISUPPORTS_INHERITED3(nsDownloadListener, CHDownloader, nsIDownload, nsITransfer, nsIWebProgressListener)
NS_IMPL_ISUPPORTS_INHERITED4(nsDownloadListener, CHDownloader, nsIDownload,
nsITransfer, nsIWebProgressListener,
nsIWebProgressListener2)
#pragma mark -
@ -179,21 +181,6 @@ nsDownloadListener::GetMIMEInfo(nsIMIMEInfo * *aMIMEInfo)
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsIWebProgressListener listener; */
NS_IMETHODIMP
nsDownloadListener::GetListener(nsIWebProgressListener * *aListener)
{
NS_ENSURE_ARG_POINTER(aListener);
NS_IF_ADDREF(*aListener = (nsIWebProgressListener *)this);
return NS_OK;
}
NS_IMETHODIMP
nsDownloadListener::SetListener(nsIWebProgressListener * aListener)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsIObserver observer; */
NS_IMETHODIMP
nsDownloadListener::GetObserver(nsIObserver * *aObserver)
@ -232,6 +219,22 @@ nsDownloadListener::OnProgressChange(nsIWebProgress *aWebProgress,
return NS_OK;
}
/* void onProgressChange64 (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long long aCurSelfProgress, in long long aMaxSelfProgress, in long long aCurTotalProgress, in long long aMaxTotalProgress); */
NS_IMETHODIMP
nsDownloadListener::OnProgressChange64(nsIWebProgress *aWebProgress,
nsIRequest *aRequest,
PRInt64 aCurSelfProgress,
PRInt64 aMaxSelfProgress,
PRInt64 aCurTotalProgress,
PRInt64 aMaxTotalProgress)
{
// XXX truncates 64-bit to 32-bit
return OnProgressChange(aProgress, aRequest,
PRInt32(curSelfProgress), PRInt32(maxSelfProgress),
PRInt32(curTotalProgress), PRInt32(maxTotalProgress));
}
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location); */
NS_IMETHODIMP
nsDownloadListener::OnLocationChange(nsIWebProgress *aWebProgress,

Просмотреть файл

@ -58,7 +58,9 @@ nsDownloadListener::~nsDownloadListener()
{
}
NS_IMPL_ISUPPORTS_INHERITED2(nsDownloadListener, CHDownloader, nsIDownload, nsIWebProgressListener)
NS_IMPL_ISUPPORTS_INHERITED4(nsDownloadListener, CHDownloader, nsIDownload,
nsITransfer, nsIWebProgressListener,
nsIWebProgressListener2)
#pragma mark -
@ -208,6 +210,23 @@ nsDownloadListener::OnProgressChange(nsIWebProgress *aWebProgress,
return NS_OK;
}
/* void onProgressChange64 (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long long aCurSelfProgress, in long long aMaxSelfProgress, in long long aCurTotalProgress, in long long aMaxTotalProgress); */
NS_IMETHODIMP
nsDownloadListener::OnProgressChange64(nsIWebProgress *aWebProgress,
nsIRequest *aRequest,
PRInt64 aCurSelfProgress,
PRInt64 aMaxSelfProgress,
PRInt64 aCurTotalProgress,
PRInt64 aMaxTotalProgress)
{
// XXX truncates 64-bit to 32-bit
return OnProgressChange(aProgress, aRequest,
PRInt32(curSelfProgress), PRInt32(maxSelfProgress),
PRInt32(curTotalProgress), PRInt32(maxTotalProgress));
}
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location); */
NS_IMETHODIMP
nsDownloadListener::OnLocationChange(nsIWebProgress *aWebProgress,

Просмотреть файл

@ -124,7 +124,7 @@ void EmbedDownload::ReportDownload( int type, int current, int total, char *mess
/* nsIWebProgressListener interface */
NS_IMPL_ISUPPORTS1(EmbedDownload, nsIWebProgressListener)
NS_IMPL_ISUPPORTS2(EmbedDownload, nsIWebProgressListener, nsIWebProgressListener2)
NS_IMETHODIMP EmbedDownload::OnProgressChange(nsIWebProgress *aProgress, nsIRequest *aRequest, PRInt32 curSelfProgress, PRInt32 maxSelfProgress, PRInt32 curTotalProgress, PRInt32 maxTotalProgress) {
@ -136,6 +136,13 @@ NS_IMETHODIMP EmbedDownload::OnProgressChange(nsIWebProgress *aProgress, nsIRequ
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));
}
NS_IMETHODIMP EmbedDownload::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags, nsresult aStatus) {
if( aStateFlags & STATE_STOP ) {
ReportDownload( Pt_WEB_DOWNLOAD_DONE, 0, 0, "" );

Просмотреть файл

@ -45,7 +45,7 @@
#include "PtMozilla.h"
/* download related */
class EmbedDownload : public nsIWebProgressListener
class EmbedDownload : public nsIWebProgressListener2
{
public:
@ -60,6 +60,7 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_NSIWEBPROGRESSLISTENER2
private:
PtMozillaWidget_t *mMozillaWidget;

Просмотреть файл

@ -70,7 +70,8 @@ CDownload::~CDownload()
{
}
NS_IMPL_ISUPPORTS2(CDownload, nsIDownload, nsIWebProgressListener)
NS_IMPL_ISUPPORTS4(CDownload, nsIDownload, nsITransfer,
nsIWebProgressListener, nsIWebProgressListener2)
#pragma mark -
#pragma mark [CDownload::nsIDownload]
@ -150,19 +151,6 @@ NS_IMETHODIMP CDownload::GetMIMEInfo(nsIMIMEInfo * *aMIMEInfo)
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsIWebProgressListener listener; */
NS_IMETHODIMP CDownload::GetListener(nsIWebProgressListener * *aListener)
{
NS_ENSURE_ARG_POINTER(aListener);
NS_IF_ADDREF(*aListener = (nsIWebProgressListener *)this);
return NS_OK;
}
NS_IMETHODIMP CDownload::SetListener(nsIWebProgressListener * aListener)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsIObserver observer; */
NS_IMETHODIMP CDownload::GetObserver(nsIObserver * *aObserver)
{
@ -227,6 +215,16 @@ NS_IMETHODIMP CDownload::OnProgressChange(nsIWebProgress *aWebProgress, nsIReque
return NS_OK;
}
/* void onProgressChange64 (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long long aCurSelfProgress, in long long aMaxSelfProgress, in long long aCurTotalProgress, in long long aMaxTotalProgress); */
NS_IMETHODIMP CDownload::OnProgressChange64(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRInt64 aCurSelfProgress, PRInt64 aMaxSelfProgress, PRInt64 aCurTotalProgress, PRInt64 aMaxTotalProgress)
{
// XXX truncates 64-bit to 32-bit
return OnProgressChange(aProgress, aRequest,
PRInt32(curSelfProgress), PRInt32(maxSelfProgress),
PRInt32(curTotalProgress), PRInt32(maxTotalProgress));
}
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location); */
NS_IMETHODIMP CDownload::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location)
{

Просмотреть файл

@ -233,6 +233,14 @@ nsHelperAppDialog.prototype = {
aMaxTotalProgress ) {
},
onProgressChange64: function( aWebProgress,
aRequest,
aCurSelfProgress,
aMaxSelfProgress,
aCurTotalProgress,
aMaxTotalProgress ) {
},
onStateChange: function( aWebProgress, aRequest, aStateFlags, aStatus ) {
},

Просмотреть файл

@ -213,6 +213,16 @@ nsProgressDialog.prototype = {
aMaxSelfProgress,
aCurTotalProgress,
aMaxTotalProgress ) {
return onProgressChange64(aWebProgress, aRequest, aCurSelfProgress,
aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress);
},
onProgressChange64: function( aWebProgress,
aRequest,
aCurSelfProgress,
aMaxSelfProgress,
aCurTotalProgress,
aMaxTotalProgress ) {
var overallProgress = aCurTotalProgress;
// Get current time.
@ -360,6 +370,7 @@ nsProgressDialog.prototype = {
iid.equals(Components.interfaces.nsIDownload) ||
iid.equals(Components.interfaces.nsITransfer) ||
iid.equals(Components.interfaces.nsIWebProgressListener) ||
iid.equals(Components.interfaces.nsIWebProgressListener2) ||
iid.equals(Components.interfaces.nsIObserver) ||
iid.equals(Components.interfaces.nsIInterfaceRequestor) ||
iid.equals(Components.interfaces.nsISupports))

Просмотреть файл

@ -370,6 +370,7 @@ NS_IMETHODIMP nsWebBrowserPersist::SetProgressListener(
nsIWebProgressListener * aProgressListener)
{
mProgressListener = aProgressListener;
mProgressListener2 = do_QueryInterface(aProgressListener);
return NS_OK;
}
@ -924,7 +925,7 @@ NS_IMETHODIMP nsWebBrowserPersist::OnDataAvailable(
//*****************************************************************************
/* void onProgress (in nsIRequest request, in nsISupports ctxt,
in unsigned long aProgress, in unsigned long aProgressMax); */
in unsigned long long aProgress, in unsigned long long aProgressMax); */
NS_IMETHODIMP nsWebBrowserPersist::OnProgress(
nsIRequest *request, nsISupports *ctxt, PRUint64 aProgress,
PRUint64 aProgressMax)
@ -955,9 +956,17 @@ NS_IMETHODIMP nsWebBrowserPersist::OnProgress(
// Notify listener of total progress
CalcTotalProgress();
// XXX this truncates 64-bit to 32bit
mProgressListener->OnProgressChange(nsnull, request, nsUint64(aProgress),
nsUint64(aProgressMax), mTotalCurrentProgress, mTotalMaxProgress);
if (mProgressListener2)
{
mProgressListener2->OnProgressChange64(nsnull, request, aProgress,
aProgressMax, mTotalCurrentProgress, mTotalMaxProgress);
}
else
{
// have to truncate 64-bit to 32bit
mProgressListener->OnProgressChange(nsnull, request, nsUint64(aProgress),
nsUint64(aProgressMax), mTotalCurrentProgress, mTotalMaxProgress);
}
return NS_OK;

Просмотреть файл

@ -54,7 +54,7 @@
#include "nsITransport.h"
#include "nsIProgressEventSink.h"
#include "nsILocalFile.h"
#include "nsIWebProgressListener.h"
#include "nsIWebProgressListener2.h"
#include "nsHashtable.h"
#include "nsVoidArray.h"
@ -197,6 +197,12 @@ private:
nsCOMPtr<nsIMIMEService> mMIMEService;
nsCOMPtr<nsIURI> mURI;
nsCOMPtr<nsIWebProgressListener> mProgressListener;
/**
* Progress listener for 64-bit values; this is the same object as
* mProgressListener, but is a member to avoid having to qi it for each
* progress notification.
*/
nsCOMPtr<nsIWebProgressListener2> mProgressListener2;
nsHashtable mOutputMap;
nsHashtable mUploadList;
nsHashtable mURIMap;

Просмотреть файл

@ -52,7 +52,7 @@ interface nsIURI;
interface nsIDownload;
interface nsIDOMDocument;
[scriptable, uuid(09cddbea-1dd2-11b2-aa15-c41ffea19d79)]
[scriptable, uuid(8b193f0a-cf0c-4b5f-b4e3-a388df6f07b2)]
interface nsIDownloadProgressListener : nsISupports {
/**
@ -70,10 +70,10 @@ interface nsIDownloadProgressListener : nsISupports {
void onProgressChange(in nsIWebProgress aWebProgress,
in nsIRequest aRequest,
in long aCurSelfProgress,
in long aMaxSelfProgress,
in long aCurTotalProgress,
in long aMaxTotalProgress,
in long long aCurSelfProgress,
in long long aMaxSelfProgress,
in long long aCurTotalProgress,
in long long aMaxTotalProgress,
in nsIDownload aDownload);
void onStatusChange(in nsIWebProgress aWebProgress,
@ -92,4 +92,4 @@ interface nsIDownloadProgressListener : nsISupports {
in unsigned long aState,
in nsIDownload aDownload);
};
};

Просмотреть файл

@ -1230,9 +1230,9 @@ nsDownloadManager::Observe(nsISupports* aSubject, const char* aTopic, const PRUn
PRInt32 currDownloadCount = 0;
if (nsCRT::strcmp(aTopic, "oncancel") == 0) {
nsCOMPtr<nsIProgressDialog> dialog = do_QueryInterface(aSubject);
nsCOMPtr<nsIDownload> dl = do_QueryInterface(aSubject);
nsCOMPtr<nsIURI> target;
dialog->GetTarget(getter_AddRefs(target));
dl->GetTarget(getter_AddRefs(target));
nsAutoString path;
rv = GetFilePathFromURI(target, path);
@ -1809,7 +1809,8 @@ nsDownloadsDataSource::FlushTo(const char* aURI)
///////////////////////////////////////////////////////////////////////////////
// nsDownload
NS_IMPL_ISUPPORTS3(nsDownload, nsIDownload, nsITransfer, nsIWebProgressListener)
NS_IMPL_ISUPPORTS4(nsDownload, nsIDownload, nsITransfer, nsIWebProgressListener,
nsIWebProgressListener2)
nsDownload::nsDownload():mDownloadState(nsIDownloadManager::DOWNLOAD_NOTSTARTED),
mPercentComplete(0),
@ -1952,17 +1953,16 @@ nsDownload::SetMIMEInfo(nsIMIMEInfo *aMIMEInfo)
}
///////////////////////////////////////////////////////////////////////////////
// nsIWebProgressListener
// nsIWebProgressListener2
NS_IMETHODIMP
nsDownload::OnProgressChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest,
PRInt32 aCurSelfProgress,
PRInt32 aMaxSelfProgress,
PRInt32 aCurTotalProgress,
PRInt32 aMaxTotalProgress)
nsDownload::OnProgressChange64(nsIWebProgress *aWebProgress,
nsIRequest *aRequest,
PRInt64 aCurSelfProgress,
PRInt64 aMaxSelfProgress,
PRInt64 aCurTotalProgress,
PRInt64 aMaxTotalProgress)
{
if (!mRequest)
mRequest = aRequest; // used for pause/resume
@ -2002,6 +2002,23 @@ nsDownload::OnProgressChange(nsIWebProgress *aWebProgress,
}
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// nsIWebProgressListener
NS_IMETHODIMP
nsDownload::OnProgressChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest,
PRInt32 aCurSelfProgress,
PRInt32 aMaxSelfProgress,
PRInt32 aCurTotalProgress,
PRInt32 aMaxTotalProgress)
{
return OnProgressChange64(aWebProgress, aRequest,
aCurSelfProgress, aMaxSelfProgress,
aCurTotalProgress, aMaxTotalProgress);
}
NS_IMETHODIMP
@ -2237,19 +2254,6 @@ nsDownload::GetSize(PRUint64* aSize)
return NS_OK;
}
NS_IMETHODIMP
nsDownload::SetListener(nsIWebProgressListener* aListener)
{
return NS_OK;
}
NS_IMETHODIMP
nsDownload::GetListener(nsIWebProgressListener** aListener)
{
*aListener = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsDownload::SetObserver(nsIObserver* aObserver)
{

Просмотреть файл

@ -51,6 +51,7 @@
#include "nsIDOMEventListener.h"
#include "nsIRDFContainerUtils.h"
#include "nsIWebProgressListener.h"
#include "nsIWebProgressListener2.h"
#include "nsIXPIProgressDialog.h"
#include "nsIURI.h"
#include "nsIWebBrowserPersist.h"
@ -198,6 +199,7 @@ class nsDownload : public nsIDownload
{
public:
NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_NSIWEBPROGRESSLISTENER2
NS_DECL_NSITRANSFER
NS_DECL_NSIDOWNLOAD
NS_DECL_ISUPPORTS

Просмотреть файл

@ -54,7 +54,7 @@ class nsDownloadProxy : public nsIDownload
public:
nsDownloadProxy() { }
virtual ~nsDownloadProxy() { };
virtual ~nsDownloadProxy() { }
NS_DECL_ISUPPORTS
@ -66,7 +66,8 @@ public:
nsIWebBrowserPersist* aPersist) {
nsresult rv;
nsCOMPtr<nsIDownloadManager> dm = do_GetService("@mozilla.org/download-manager;1", &rv);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
rv = dm->AddDownload(nsIDownloadManager::DOWNLOAD_TYPE_DOWNLOAD, aSource, aTarget,
aDisplayName, nsnull, aMIMEInfo, aStartTime, aPersist,
@ -141,16 +142,6 @@ public:
return mInner->GetSize(aSize);
}
NS_IMETHODIMP GetListener(nsIWebProgressListener** aListener)
{
return mInner->GetListener(aListener);
}
NS_IMETHODIMP SetListener(nsIWebProgressListener* aListener)
{
return mInner->SetListener(aListener);
}
NS_IMETHODIMP GetObserver(nsIObserver** aObserver)
{
return mInner->GetObserver(aObserver);
@ -209,11 +200,33 @@ public:
{
nsCOMPtr<nsIWebProgressListener> listener = do_QueryInterface(mInner);
if (listener)
return listener->OnProgressChange(aWebProgress, aRequest, aCurSelfProgress,
aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress);
return listener->OnProgressChange(aWebProgress, aRequest,
aCurSelfProgress,
aMaxSelfProgress,
aCurTotalProgress,
aMaxTotalProgress);
return NS_OK;
}
NS_IMETHODIMP OnProgressChange64(nsIWebProgress *aWebProgress,
nsIRequest *aRequest,
PRInt64 aCurSelfProgress,
PRInt64 aMaxSelfProgress,
PRInt64 aCurTotalProgress,
PRInt64 aMaxTotalProgress)
{
nsCOMPtr<nsIWebProgressListener2> listener = do_QueryInterface(mInner);
if (listener)
return listener->OnProgressChange64(aWebProgress, aRequest,
aCurSelfProgress,
aMaxSelfProgress,
aCurTotalProgress,
aMaxTotalProgress);
return NS_OK;
}
NS_IMETHODIMP OnSecurityChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, PRUint32 aState)
{
@ -227,6 +240,7 @@ private:
nsCOMPtr<nsIDownload> mInner;
};
NS_IMPL_ISUPPORTS3(nsDownloadProxy, nsIDownload, nsITransfer, nsIWebProgressListener)
NS_IMPL_ISUPPORTS4(nsDownloadProxy, nsIDownload, nsITransfer,
nsIWebProgressListener, nsIWebProgressListener2)
#endif

Просмотреть файл

@ -343,6 +343,16 @@ nsUnknownContentTypeDialog.prototype = {
aMaxTotalProgress ) {
},
onProgressChange64: function( aWebProgress,
aRequest,
aCurSelfProgress,
aMaxSelfProgress,
aCurTotalProgress,
aMaxTotalProgress ) {
},
onStateChange: function( aWebProgress, aRequest, aStateFlags, aStatus ) {
},

Просмотреть файл

@ -1,4 +1,4 @@
#
# vim:set noet:
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
@ -88,6 +88,7 @@ XPIDLSRCS = \
nsIDownload.idl \
nsITransfer.idl \
nsIDocumentLoader.idl \
nsIWebProgressListener2.idl \
$(NULL)
EXPORTS = \

Просмотреть файл

@ -36,15 +36,15 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsIWebProgressListener.idl"
#include "nsIWebProgressListener2.idl"
interface nsIURI;
interface nsIObserver;
interface nsIWebBrowserPersist;
interface nsIMIMEInfo;
[scriptable, uuid(e57c27f8-2a4e-4d80-bf80-1ffd634c734e)]
interface nsITransfer : nsIWebProgressListener {
[scriptable, uuid(4af66079-938d-4093-9cc4-561dac709c7b)]
interface nsITransfer : nsIWebProgressListener2 {
/**
* Initializes the transfer with certain properties. This function must
@ -75,12 +75,6 @@ interface nsITransfer : nsIWebProgressListener {
in long long startTime,
in nsIWebBrowserPersist aPersist);
/**
* Optional; transferring information is passed to this listener and used to
* update client UI.
*/
attribute nsIWebProgressListener listener;
/**
* If set, receives notifications of events like cancel ("oncancel").
* Must be set if no persist object is specified (see above).

Просмотреть файл

@ -264,6 +264,10 @@ interface nsIWebProgressListener : nsISupports
*
* NOTE: If any progress value is unknown, or if its value would exceed the
* maximum value of type long, then its value is replaced with -1.
*
* NOTE: If the object also implements nsIWebProgressListener2 and the caller
* knows about that interface, this function will not be called. Instead,
* nsIWebProgressListener2::onProgressChange64 will be called.
*/
void onProgressChange(in nsIWebProgress aWebProgress,
in nsIRequest aRequest,

Просмотреть файл

@ -0,0 +1,79 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is nsIWebProgressListener2 interface.
*
* The Initial Developer of the Original Code is
* Christian Biesinger <cbiesinger@web.de>.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIWebProgressListener.idl"
/**
* This interface is an extension to nsIWebProgressListener to support 64-bit
* progress values.
*/
[scriptable, uuid(3f24610d-1e1f-4151-9d2e-239884742324)]
interface nsIWebProgressListener2 : nsIWebProgressListener {
/**
* Notification that the progress has changed for one of the requests
* associated with aWebProgress. Progress totals are reset to zero when all
* requests in aWebProgress complete (corresponding to onStateChange being
* called with aStateFlags including the STATE_STOP and STATE_IS_WINDOW
* flags).
*
* This function is identical to nsIWebProgressListener::onProgressChange,
* except that this function supports 64-bit values.
*
* @param aWebProgress
* The nsIWebProgress instance that fired the notification.
* @param aRequest
* The nsIRequest that has new progress.
* @param aCurSelfProgress
* The current progress for aRequest.
* @param aMaxSelfProgress
* The maximum progress for aRequest.
* @param aCurTotalProgress
* The current progress for all requests associated with aWebProgress.
* @param aMaxTotalProgress
* The total progress for all requests associated with aWebProgress.
*
* NOTE: If any progress value is unknown, then its value is replaced with -1.
*
* @see nsIWebProgressListener2::onProgressChange64
*/
void onProgressChange64(in nsIWebProgress aWebProgress,
in nsIRequest aRequest,
in long long aCurSelfProgress,
in long long aMaxSelfProgress,
in long long aCurTotalProgress,
in long long aMaxTotalProgress);
};

Просмотреть файл

@ -77,6 +77,7 @@
#include "nsNetUtil.h"
#include "nsIIOService.h"
#include "nsNetCID.h"
#include "nsChannelProperties.h"
#include "nsMimeTypes.h"
// used for header disposition information.
@ -84,6 +85,7 @@
#include "nsIEncodedChannel.h"
#include "nsIMultiPartChannel.h"
#include "nsIObserverService.h" // so we can be a profile change observer
#include "nsIPropertyBag2.h" // for the 64-bit content length
#if defined(XP_MAC) || defined (XP_MACOSX)
#include "nsILocalFileMac.h"
@ -1361,8 +1363,8 @@ nsExternalAppHandler::nsExternalAppHandler(nsIMIMEInfo * aMIMEInfo,
, mStopRequestIssued(PR_FALSE)
, mProgressListenerInitialized(PR_FALSE)
, mReason(aReason)
, mProgress(0)
, mContentLength(-1)
, mProgress(0)
, mRequest(nsnull)
{
@ -1398,7 +1400,7 @@ NS_IMETHODIMP nsExternalAppHandler::Observe(nsISupports *aSubject, const char *a
}
NS_IMETHODIMP nsExternalAppHandler::SetWebProgressListener(nsIWebProgressListener * aWebProgressListener)
NS_IMETHODIMP nsExternalAppHandler::SetWebProgressListener(nsIWebProgressListener2 * aWebProgressListener)
{
// this call back means we've succesfully brought up the
// progress window so set the appropriate flag, even though
@ -1607,20 +1609,33 @@ nsresult nsExternalAppHandler::SetUpTempFile(nsIChannel * aChannel)
NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISupports * aCtxt)
{
NS_ENSURE_ARG_POINTER(request);
NS_PRECONDITION(request, "OnStartRequest without request?");
mRequest = request;
nsCOMPtr<nsIChannel> aChannel = do_QueryInterface(request);
// Get content length and URI.
// Get content length
nsresult rv;
nsCOMPtr<nsIPropertyBag2> props(do_QueryInterface(request, &rv));
if (props) {
rv = props->GetPropertyAsInt64(NS_CHANNEL_PROP_CONTENT_LENGTH,
&mContentLength.mValue);
}
// If that failed, ask the channel
if (NS_FAILED(rv) && aChannel) {
PRInt32 len;
aChannel->GetContentLength(&len);
mContentLength = len;
}
// Now get the URI
if (aChannel)
{
aChannel->GetContentLength(&mContentLength);
aChannel->GetURI(getter_AddRefs(mSourceUrl));
}
nsresult rv = SetUpTempFile(aChannel);
rv = SetUpTempFile(aChannel);
if (NS_FAILED(rv)) {
mCanceled = PR_TRUE;
request->Cancel(rv);
@ -1940,19 +1955,10 @@ NS_IMETHODIMP nsExternalAppHandler::OnDataAvailable(nsIRequest *request, nsISupp
}
if (NS_SUCCEEDED(rv))
{
// Set content length if we haven't already got it.
if (mContentLength == -1)
{
nsCOMPtr<nsIChannel> aChannel(do_QueryInterface(request));
if (aChannel)
{
aChannel->GetContentLength(&mContentLength);
}
}
// Send progress notification.
if (mWebProgressListener)
{
mWebProgressListener->OnProgressChange(nsnull, request, mProgress, mContentLength, mProgress, mContentLength);
mWebProgressListener->OnProgressChange64(nsnull, request, mProgress, mContentLength, mProgress, mContentLength);
}
}
else
@ -2055,7 +2061,7 @@ nsresult nsExternalAppHandler::ExecuteDesiredAction()
{
if (!mCanceled)
{
mWebProgressListener->OnProgressChange(nsnull, nsnull, mContentLength, mContentLength, mContentLength, mContentLength);
mWebProgressListener->OnProgressChange64(nsnull, nsnull, mContentLength, mContentLength, mContentLength, mContentLength);
}
mWebProgressListener->OnStateChange(nsnull, nsnull, nsIWebProgressListener::STATE_STOP, NS_OK);
}
@ -2067,7 +2073,7 @@ nsresult nsExternalAppHandler::ExecuteDesiredAction()
NS_IMETHODIMP nsExternalAppHandler::GetMIMEInfo(nsIMIMEInfo ** aMIMEInfo)
{
*aMIMEInfo = mMimeInfo;
NS_IF_ADDREF(*aMIMEInfo);
NS_ADDREF(*aMIMEInfo);
return NS_OK;
}

Просмотреть файл

@ -46,9 +46,11 @@
#include "prlog.h"
#include "prtime.h"
#include "nsInt64.h"
#include "nsIExternalHelperAppService.h"
#include "nsIExternalProtocolService.h"
#include "nsIWebProgressListener.h"
#include "nsIWebProgressListener2.h"
#include "nsIHelperAppLauncherDialog.h"
#include "nsIMIMEInfo.h"
@ -385,8 +387,8 @@ protected:
PRUint32 mReason;
PRTime mTimeDownloadStarted;
PRInt32 mContentLength;
PRInt32 mProgress; /**< Number of bytes received (for sending progress notifications). */
nsInt64 mContentLength;
nsInt64 mProgress; /**< Number of bytes received (for sending progress notifications). */
/**
* When we are told to save the temp file to disk (in a more permament
@ -469,7 +471,7 @@ protected:
*/
void SendStatusChange(ErrorType type, nsresult aStatus, nsIRequest *aRequest, const nsAFlatString &path);
nsCOMPtr<nsIWebProgressListener> mWebProgressListener;
nsCOMPtr<nsIWebProgressListener2> mWebProgressListener;
nsCOMPtr<nsIChannel> mOriginalChannel; /**< in the case of a redirect, this will be the pre-redirect channel. */
nsCOMPtr<nsIHelperAppLauncherDialog> mDialog;

Просмотреть файл

@ -44,7 +44,7 @@ interface nsIRequest;
interface nsIStreamListener;
interface nsIFile;
interface nsIMIMEInfo;
interface nsIWebProgressListener;
interface nsIWebProgressListener2;
interface nsIInterfaceRequestor;
/**
@ -98,7 +98,7 @@ interface nsPIExternalAppLauncher : nsISupports
* A helper app launcher is a small object created to handle the launching
* of an external application.
*/
[scriptable, uuid(15437993-9732-4aaf-977b-69a16b6334ff)]
[scriptable, uuid(955baa49-7f87-469a-b5f3-e611c083d202)]
interface nsIHelperAppLauncher : nsISupports
{
/**
@ -144,7 +144,7 @@ interface nsIHelperAppLauncher : nsISupports
* This reference will be released when the download is finished (after the
* listener receives the STATE_STOP notification).
*/
void setWebProgressListener(in nsIWebProgressListener aWebProgressListener);
void setWebProgressListener(in nsIWebProgressListener2 aWebProgressListener);
/**
* when the stand alone progress window actually closes, it calls this method

Просмотреть файл

@ -52,7 +52,7 @@ interface nsIURI;
interface nsIDownload;
interface nsIDOMDocument;
[scriptable, uuid(09cddbea-1dd2-11b2-aa15-c41ffea19d79)]
[scriptable, uuid(c7e22278-53a7-49d9-999f-0e7861738b50)]
interface nsIDownloadProgressListener : nsISupports {
/**
@ -70,10 +70,10 @@ interface nsIDownloadProgressListener : nsISupports {
void onProgressChange(in nsIWebProgress aWebProgress,
in nsIRequest aRequest,
in long aCurSelfProgress,
in long aMaxSelfProgress,
in long aCurTotalProgress,
in long aMaxTotalProgress,
in long long aCurSelfProgress,
in long long aMaxSelfProgress,
in long long aCurTotalProgress,
in long long aMaxTotalProgress,
in nsIDownload aDownload);
void onStatusChange(in nsIWebProgress aWebProgress,
@ -92,4 +92,4 @@ interface nsIDownloadProgressListener : nsISupports {
in unsigned long aState,
in nsIDownload aDownload);
};
};

Просмотреть файл

@ -805,7 +805,7 @@ nsDownloadManager::OpenProgressDialogFor(nsIDownload* aDownload, nsIDOMWindow* a
dialog->SetObserver(internalDownload);
// now set the listener so we forward notifications to the dialog
nsCOMPtr<nsIWebProgressListener> listener = do_QueryInterface(dialog);
nsCOMPtr<nsIWebProgressListener2> listener = do_QueryInterface(dialog);
internalDownload->SetDialogListener(listener);
internalDownload->SetDialog(dialog);
@ -922,7 +922,8 @@ nsDownloadManager::Observe(nsISupports* aSubject, const char* aTopic, const PRUn
///////////////////////////////////////////////////////////////////////////////
// nsDownload
NS_IMPL_ISUPPORTS4(nsDownload, nsIDownload, nsITransfer, nsIWebProgressListener, nsIObserver)
NS_IMPL_ISUPPORTS5(nsDownload, nsIDownload, nsITransfer, nsIWebProgressListener,
nsIWebProgressListener2, nsIObserver)
nsDownload::nsDownload(nsDownloadManager* aManager,
nsIURI* aTarget,
@ -1019,19 +1020,17 @@ nsDownload::Observe(nsISupports* aSubject, const char* aTopic, const PRUnichar*
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// nsIWebProgressListener
// nsIWebProgressListener2
NS_IMETHODIMP
nsDownload::OnProgressChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest,
PRInt32 aCurSelfProgress,
PRInt32 aMaxSelfProgress,
PRInt32 aCurTotalProgress,
PRInt32 aMaxTotalProgress)
nsDownload::OnProgressChange64(nsIWebProgress *aWebProgress,
nsIRequest *aRequest,
PRInt64 aCurSelfProgress,
PRInt64 aMaxSelfProgress,
PRInt64 aCurTotalProgress,
PRInt64 aMaxTotalProgress)
{
if (!mRequest)
mRequest = aRequest; // used for pause/resume
@ -1058,38 +1057,47 @@ nsDownload::OnProgressChange(nsIWebProgress *aWebProgress,
else
mPercentComplete = -1;
mCurrBytes = (PRInt32)((PRFloat64)aCurTotalProgress / 1024.0 + .5);
mMaxBytes = (PRInt32)((PRFloat64)aMaxTotalProgress / 1024 + .5);
if (mListener) {
mListener->OnProgressChange(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress,
aCurTotalProgress, aMaxTotalProgress);
}
mCurrBytes = ((PRFloat64)aCurTotalProgress / 1024.0 + .5);
mMaxBytes = ((PRFloat64)aMaxTotalProgress / 1024 + .5);
if (mDownloadManager->MustUpdateUI()) {
nsCOMPtr<nsIDownloadProgressListener> internalListener;
mDownloadManager->GetInternalListener(getter_AddRefs(internalListener));
if (internalListener) {
internalListener->OnProgressChange(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress,
aCurTotalProgress, aMaxTotalProgress, this);
aCurTotalProgress, aMaxTotalProgress, this);
}
}
if (mDialogListener) {
mDialogListener->OnProgressChange(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress,
aCurTotalProgress, aMaxTotalProgress);
mDialogListener->OnProgressChange64(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress,
aCurTotalProgress, aMaxTotalProgress);
}
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// nsIWebProgressListener
NS_IMETHODIMP
nsDownload::OnProgressChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest,
PRInt32 aCurSelfProgress,
PRInt32 aMaxSelfProgress,
PRInt32 aCurTotalProgress,
PRInt32 aMaxTotalProgress)
{
return OnProgressChange64(aWebProgress, aRequest,
aCurSelfProgress, aMaxSelfProgress,
aCurTotalProgress, aMaxTotalProgress);
}
NS_IMETHODIMP
nsDownload::OnLocationChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, nsIURI *aLocation)
{
if (mListener)
mListener->OnLocationChange(aWebProgress, aRequest, aLocation);
if (mDownloadManager->MustUpdateUI()) {
nsCOMPtr<nsIDownloadProgressListener> internalListener;
mDownloadManager->GetInternalListener(getter_AddRefs(internalListener));
@ -1116,9 +1124,6 @@ nsDownload::OnStatusChange(nsIWebProgress *aWebProgress,
mDownloadManager->DownloadEnded(path, aMessage);
}
if (mListener)
mListener->OnStatusChange(aWebProgress, aRequest, aStatus, aMessage);
if (mDownloadManager->MustUpdateUI()) {
nsCOMPtr<nsIDownloadProgressListener> internalListener;
mDownloadManager->GetInternalListener(getter_AddRefs(internalListener));
@ -1206,9 +1211,6 @@ nsDownload::OnStateChange(nsIWebProgress* aWebProgress,
// access to out member vars!
nsRefPtr<nsDownload> kungFuDeathGrip(this);
if (mListener)
mListener->OnStateChange(aWebProgress, aRequest, aStateFlags, aStatus);
// We need to update mDownloadState before updating the dialog, because
// that will close and call CancelDownload if it was the last open window.
nsresult rv = NS_OK;
@ -1287,9 +1289,6 @@ NS_IMETHODIMP
nsDownload::OnSecurityChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, PRUint32 aState)
{
if (mListener)
mListener->OnSecurityChange(aWebProgress, aRequest, aState);
if (mDownloadManager->MustUpdateUI()) {
nsCOMPtr<nsIDownloadProgressListener> internalListener;
mDownloadManager->GetInternalListener(getter_AddRefs(internalListener));
@ -1377,21 +1376,6 @@ nsDownload::GetSize(PRUint64* aSize)
return NS_OK;
}
NS_IMETHODIMP
nsDownload::SetListener(nsIWebProgressListener* aListener)
{
mListener = aListener;
return NS_OK;
}
NS_IMETHODIMP
nsDownload::GetListener(nsIWebProgressListener** aListener)
{
*aListener = mListener;
NS_IF_ADDREF(*aListener);
return NS_OK;
}
NS_IMETHODIMP
nsDownload::SetObserver(nsIObserver* aObserver)
{

Просмотреть файл

@ -108,6 +108,7 @@ class nsDownload : public nsIDownload,
{
public:
NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_NSIWEBPROGRESSLISTENER2
NS_DECL_NSITRANSFER
NS_DECL_NSIDOWNLOAD
NS_DECL_NSIOBSERVER
@ -121,7 +122,7 @@ public:
nsresult Resume();
void DisplayDownloadFinishedAlert();
void SetDialogListener(nsIWebProgressListener* aInternalListener) {
void SetDialogListener(nsIWebProgressListener2* aInternalListener) {
mDialogListener = aInternalListener;
}
void SetDialog(nsIProgressDialog* aDialog) {
@ -165,8 +166,7 @@ private:
nsCOMPtr<nsIURI> mTarget;
nsCOMPtr<nsIURI> mSource;
nsCOMPtr<nsIWebProgressListener> mListener;
nsCOMPtr<nsIWebProgressListener> mDialogListener;
nsCOMPtr<nsIWebProgressListener2> mDialogListener;
nsCOMPtr<nsIWebBrowserPersist> mPersist;
nsCOMPtr<nsIRequest> mRequest;
nsCOMPtr<nsIProgressDialog> mDialog;

Просмотреть файл

@ -138,20 +138,6 @@ public:
return mInner->GetSize(aSize);
}
NS_IMETHODIMP GetListener(nsIWebProgressListener** aListener)
{
if (!mInner)
return NS_ERROR_NOT_INITIALIZED;
return mInner->GetListener(aListener);
}
NS_IMETHODIMP SetListener(nsIWebProgressListener* aListener)
{
if (!mInner)
return NS_ERROR_NOT_INITIALIZED;
return mInner->SetListener(aListener);
}
NS_IMETHODIMP GetObserver(nsIObserver** aObserver)
{
if (!mInner)
@ -218,11 +204,32 @@ public:
{
nsCOMPtr<nsIWebProgressListener> listener = do_QueryInterface(mInner);
if (listener)
return listener->OnProgressChange(aWebProgress, aRequest, aCurSelfProgress,
aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress);
return listener->OnProgressChange(aWebProgress, aRequest,
aCurSelfProgress,
aMaxSelfProgress,
aCurTotalProgress,
aMaxTotalProgress);
return NS_OK;
}
NS_IMETHODIMP OnProgressChange64(nsIWebProgress *aWebProgress,
nsIRequest *aRequest,
PRInt64 aCurSelfProgress,
PRInt64 aMaxSelfProgress,
PRInt64 aCurTotalProgress,
PRInt64 aMaxTotalProgress)
{
if (!mInner)
return NS_ERROR_NOT_INITIALIZED;
return mInner->OnProgressChange64(aWebProgress, aRequest,
aCurSelfProgress,
aMaxSelfProgress,
aCurTotalProgress,
aMaxTotalProgress);
}
NS_IMETHODIMP OnSecurityChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, PRUint32 aState)
{
@ -236,6 +243,7 @@ private:
nsCOMPtr<nsIDownload> mInner;
};
NS_IMPL_ISUPPORTS3(nsDownloadProxy, nsIDownload, nsITransfer, nsIWebProgressListener)
NS_IMPL_ISUPPORTS4(nsDownloadProxy, nsIDownload, nsITransfer,
nsIWebProgressListener, nsIWebProgressListener2)
#endif