aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla/MozDownload.cpp
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@gnome.org>2004-02-25 07:44:58 +0800
committerMarco Pesenti Gritti <marco@src.gnome.org>2004-02-25 07:44:58 +0800
commit9fb6164dd427630f8e72d69113c48a78dd449bc8 (patch)
treebb8614a2c6a04bbcb05be59c1ed525abc77d9f83 /embed/mozilla/MozDownload.cpp
parentd055989e9fc45f0849de45ec00e02802e6769dc0 (diff)
downloadgsoc2013-epiphany-9fb6164dd427630f8e72d69113c48a78dd449bc8.tar
gsoc2013-epiphany-9fb6164dd427630f8e72d69113c48a78dd449bc8.tar.gz
gsoc2013-epiphany-9fb6164dd427630f8e72d69113c48a78dd449bc8.tar.bz2
gsoc2013-epiphany-9fb6164dd427630f8e72d69113c48a78dd449bc8.tar.lz
gsoc2013-epiphany-9fb6164dd427630f8e72d69113c48a78dd449bc8.tar.xz
gsoc2013-epiphany-9fb6164dd427630f8e72d69113c48a78dd449bc8.tar.zst
gsoc2013-epiphany-9fb6164dd427630f8e72d69113c48a78dd449bc8.zip
Make max size property use long / bytes.
2004-02-25 Marco Pesenti Gritti <marco@gnome.org> * embed/ephy-embed-persist.c: (ephy_embed_persist_set_max_size), (ephy_embed_persist_set_property), (ephy_embed_persist_get_property), (ephy_embed_persist_init), (ephy_embed_persist_class_init): * embed/ephy-embed-persist.h: Make max size property use long / bytes. * embed/ephy-favicon-cache.c: (ephy_favicon_cache_download): Correct to use bytes. * embed/mozilla/EphyHeaderSniffer.cpp: * embed/mozilla/MozDownload.cpp: * embed/mozilla/MozDownload.h: * embed/mozilla/mozilla-embed-persist.cpp: Actually respect the max_size property.
Diffstat (limited to 'embed/mozilla/MozDownload.cpp')
-rw-r--r--embed/mozilla/MozDownload.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/embed/mozilla/MozDownload.cpp b/embed/mozilla/MozDownload.cpp
index 6261b40af..f6a592d6d 100644
--- a/embed/mozilla/MozDownload.cpp
+++ b/embed/mozilla/MozDownload.cpp
@@ -63,7 +63,9 @@
const char* const persistContractID = "@mozilla.org/embedding/browser/nsWebBrowserPersist;1";
MozDownload::MozDownload() :
- mGotFirstStateChange(false), mIsNetworkTransfer(false),
+ mMaxSize(-1),
+ mGotFirstStateChange(false),
+ mIsNetworkTransfer(false),
mStatus(NS_OK),
mEmbedPersist(nsnull),
mDownloadState(EPHY_DOWNLOAD_DOWNLOADING)
@@ -79,9 +81,10 @@ NS_IMPL_ISUPPORTS2(MozDownload, nsIDownload, nsIWebProgressListener)
NS_IMETHODIMP
MozDownload::InitForEmbed (nsIURI *aSource, nsILocalFile *aTarget, const PRUnichar *aDisplayName,
nsIMIMEInfo *aMIMEInfo, PRInt64 startTime, nsIWebBrowserPersist *aPersist,
- MozillaEmbedPersist *aEmbedPersist)
+ MozillaEmbedPersist *aEmbedPersist, PRInt32 aMaxSize)
{
mEmbedPersist = aEmbedPersist;
+ mMaxSize = aMaxSize;
return Init (aSource, aTarget, aDisplayName, aMIMEInfo, startTime, aPersist);
}
@@ -355,6 +358,13 @@ MozDownload::OnProgressChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest
PRInt32 aCurSelfProgress, PRInt32 aMaxSelfProgress,
PRInt32 aCurTotalProgress, PRInt32 aMaxTotalProgress)
{
+ if (mMaxSize >= 0 &&
+ ((aMaxTotalProgress > 0 && mMaxSize > aMaxTotalProgress) ||
+ mMaxSize > aCurTotalProgress))
+ {
+ Cancel ();
+ }
+
if (!mRequest)
mRequest = aRequest;
@@ -449,7 +459,8 @@ MozDownload::Resume()
nsresult InitiateMozillaDownload (nsIDOMDocument *domDocument, nsIURI *sourceURI,
nsILocalFile* inDestFile, const char *contentType,
nsIURI* inOriginalURI, MozillaEmbedPersist *embedPersist,
- nsIInputStream *postData, nsISupports *aCacheKey)
+ nsIInputStream *postData, nsISupports *aCacheKey,
+ PRInt32 aMaxSize)
{
nsresult rv = NS_OK;
@@ -472,7 +483,7 @@ nsresult InitiateMozillaDownload (nsIDOMDocument *domDocument, nsIURI *sourceURI
MozDownload *downloader = new MozDownload ();
/* dlListener attaches to its progress dialog here, which gains ownership */
rv = downloader->InitForEmbed (inOriginalURI, inDestFile, fileDisplayName.get(),
- nsnull, timeNow, webPersist, embedPersist);
+ nsnull, timeNow, webPersist, embedPersist, aMaxSize);
NS_ENSURE_SUCCESS (rv, rv);
PRInt32 flags = nsIWebBrowserPersist::PERSIST_FLAGS_REPLACE_EXISTING_FILES;