diff --git a/uriloader/prefetch/nsPrefetchService.cpp b/uriloader/prefetch/nsPrefetchService.cpp index c1b56c8e6..c1728eef9 100644 --- a/uriloader/prefetch/nsPrefetchService.cpp +++ b/uriloader/prefetch/nsPrefetchService.cpp @@ -14,6 +14,7 @@ #include "nsIHttpChannel.h" #include "nsIURL.h" #include "nsISimpleEnumerator.h" +#include "nsISupportsPriority.h" #include "nsNetUtil.h" #include "nsString.h" #include "nsXPIDLString.h" @@ -134,7 +135,19 @@ nsPrefetchNode::OpenChannel() false); } - return mChannel->AsyncOpen2(this); + // Reduce the priority of prefetch network requests. + nsCOMPtr priorityChannel = do_QueryInterface(mChannel); + if (priorityChannel) { + priorityChannel->AdjustPriority(nsISupportsPriority::PRIORITY_LOWEST); + } + + rv = mChannel->AsyncOpen2(this); + if (NS_WARN_IF(NS_FAILED(rv))) { + // Drop the ref to the channel, because we don't want to end up with + // cycles through it. + mChannel = nullptr; + } + return rv; } nsresult