From b1cfd7830c0e11cd3f8c4bb31daaa6b0d83a625f Mon Sep 17 00:00:00 2001 From: Cameron Kaiser Date: Fri, 21 Jul 2017 20:39:09 -0700 Subject: [PATCH] #418: M1333106 M1337672 --- uriloader/prefetch/nsPrefetchService.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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