mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1348062 - Mark channels used for downloads as throttable, r=nick+paolo
MozReview-Commit-ID: 9cg4PwrXtNa --HG-- extra : rebase_source : 2ff2d771a6ccb2a3e11c2d65e0a64ebbaa443206
This commit is contained in:
parent
589e3693ed
commit
203c640be7
@ -6397,6 +6397,18 @@ nsHttpChannel::ForceIntercepted(uint64_t aInterceptionID)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHttpChannel::SetChannelIsForDownload(bool aChannelIsForDownload)
|
||||
{
|
||||
if (aChannelIsForDownload) {
|
||||
AddClassFlags(nsIClassOfService::Throttleable);
|
||||
} else {
|
||||
ClearClassFlags(nsIClassOfService::Throttleable);
|
||||
}
|
||||
|
||||
return HttpBaseChannel::SetChannelIsForDownload(aChannelIsForDownload);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsHttpChannel::nsISupportsPriority
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -157,6 +157,7 @@ public:
|
||||
// nsIHttpChannelInternal
|
||||
NS_IMETHOD SetupFallbackChannel(const char *aFallbackKey) override;
|
||||
NS_IMETHOD ForceIntercepted(uint64_t aInterceptionID) override;
|
||||
NS_IMETHOD SetChannelIsForDownload(bool aChannelIsForDownload) override;
|
||||
// nsISupportsPriority
|
||||
NS_IMETHOD SetPriority(int32_t value) override;
|
||||
// nsIClassOfService
|
||||
|
@ -1976,6 +1976,12 @@ this.DownloadCopySaver.prototype = {
|
||||
channel.referrer = NetUtil.newURI(download.source.referrer);
|
||||
}
|
||||
|
||||
// This makes the channel be corretly throttled during page loads
|
||||
// and also prevents its caching.
|
||||
if (channel instanceof Ci.nsIHttpChannelInternal) {
|
||||
channel.channelIsForDownload = true;
|
||||
}
|
||||
|
||||
// If we have data that we can use to resume the download from where
|
||||
// it stopped, try to use it.
|
||||
let resumeAttempted = false;
|
||||
|
@ -1677,7 +1677,8 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISuppo
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Inform channel it is open on behalf of a download to prevent caching.
|
||||
// Inform channel it is open on behalf of a download to throttle it during
|
||||
// page loads and prevent its caching.
|
||||
nsCOMPtr<nsIHttpChannelInternal> httpInternal = do_QueryInterface(aChannel);
|
||||
if (httpInternal) {
|
||||
rv = httpInternal->SetChannelIsForDownload(true);
|
||||
|
Loading…
Reference in New Issue
Block a user