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
--- 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,