Bug 1337672 - Part 2: Reduce the priority of Flash network requests. r?mayhemer r?bsmedberg draft
authorChris Peterson <cpeterson@mozilla.com>
Wed, 18 Jan 2017 00:59:58 -0800
changeset 480448 8c6a57080737a44506339b8c6fbda5f8ea496189
parent 480447 cf0306d33ea0dbe51bfc957eb39ad2e37565c51a
child 544954 4213f209f64a48f190e91cf648d8348ce77cb660
push id44544
push usercpeterson@mozilla.com
push dateWed, 08 Feb 2017 08:10:53 +0000
reviewersmayhemer, bsmedberg
bugs1337672
milestone54.0a1
Bug 1337672 - Part 2: Reduce the priority of Flash network requests. r?mayhemer r?bsmedberg Reduce the priority of network requests to load Flash <object> elements from PRIORITY_NORMAL to PRIORITY_LOW + 2, below images (PRIORITY_LOW and PRIORITY_LOW + 1) but above favicons (PRIORITY_LOWEST). Reduce the priority of NPAPI network requests issued by Flash content from PRIORITY_NORMAL to PRIORITY_LOW + 3, below images and <object> elements but above favicons. We don't want to outgoing requests from early Flash content to delay the initial loading and rendering of other Flash <object> elements on the page. MozReview-Commit-ID: KaJo4bf2a9A
dom/base/nsObjectLoadingContent.cpp
dom/plugins/base/nsPluginHost.cpp
--- a/dom/base/nsObjectLoadingContent.cpp
+++ b/dom/base/nsObjectLoadingContent.cpp
@@ -27,16 +27,17 @@
 #include "nsPluginHost.h"
 #include "nsPluginInstanceOwner.h"
 #include "nsJSNPRuntime.h"
 #include "nsINestedURI.h"
 #include "nsIPresShell.h"
 #include "nsScriptSecurityManager.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIStreamConverterService.h"
+#include "nsISupportsPriority.h"
 #include "nsIURILoader.h"
 #include "nsIURL.h"
 #include "nsIWebNavigation.h"
 #include "nsIWebNavigationInfo.h"
 #include "nsIScriptChannel.h"
 #include "nsIBlocklistService.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 #include "nsIAppShell.h"
@@ -2612,16 +2613,22 @@ nsObjectLoadingContent::OpenChannel()
   }
 
   nsCOMPtr<nsIScriptChannel> scriptChannel = do_QueryInterface(chan);
   if (scriptChannel) {
     // Allow execution against our context if the principals match
     scriptChannel->SetExecutionPolicy(nsIScriptChannel::EXECUTE_NORMAL);
   }
 
+  // Reduce the priority of network requests to load Flash <object> elements.
+  nsCOMPtr<nsISupportsPriority> priorityChannel = do_QueryInterface(chan);
+  if (priorityChannel) {
+    priorityChannel->AdjustPriority(nsISupportsPriority::PRIORITY_LOW + 2);
+  }
+
   // AsyncOpen2 can fail if a file does not exist.
   rv = chan->AsyncOpen2(shim);
   NS_ENSURE_SUCCESS(rv, rv);
   LOG(("OBJLC [%p]: Channel opened", this));
   mChannel = chan;
   return NS_OK;
 }
 
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -57,16 +57,17 @@
 #include "mozilla/plugins/PluginBridge.h"
 #include "mozilla/plugins/PluginTypes.h"
 #include "mozilla/Preferences.h"
 
 #include "nsEnumeratorUtils.h"
 #include "nsXPCOM.h"
 #include "nsXPCOMCID.h"
 #include "nsISupportsPrimitives.h"
+#include "nsISupportsPriority.h"
 
 #include "nsXULAppAPI.h"
 #include "nsIXULRuntime.h"
 
 // for the dialog
 #include "nsIWindowWatcher.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMWindow.h"
@@ -3259,16 +3260,23 @@ nsresult nsPluginHost::NewPluginURLStrea
       uploadChannel->SetUploadStream(aPostStream, EmptyCString(), -1);
     }
 
     if (aHeadersData) {
       rv = AddHeadersToChannel(aHeadersData, aHeadersDataLen, httpChannel);
       NS_ENSURE_SUCCESS(rv,rv);
     }
   }
+
+  // Reduce the priority of network requests issued by Flash content.
+  nsCOMPtr<nsISupportsPriority> priorityChannel = do_QueryInterface(channel);
+  if (priorityChannel) {
+    priorityChannel->AdjustPriority(nsISupportsPriority::PRIORITY_LOW + 3);
+  }
+
   rv = channel->AsyncOpen2(listenerPeer);
   if (NS_SUCCEEDED(rv))
     listenerPeer->TrackRequest(channel);
   return rv;
 }
 
 nsresult
 nsPluginHost::AddHeadersToChannel(const char *aHeadersData,