Bug 1508595 - Only set an intercept controller when needed. r=asuth
We only need to expose an intercept controller in SharedWorkers if we're on the non-parent-intercept version of ServiceWorkers or if e10s is off. nsDocShell already does this dance and we have to mirror it. Differential Revision: https://phabricator.services.mozilla.com/D12490
This commit is contained in:
@@ -480,6 +480,8 @@ nsDocShell::Create(BrowsingContext* aBrowsingContext)
|
|||||||
// If parent intercept is not enabled then we must forward to
|
// If parent intercept is not enabled then we must forward to
|
||||||
// the network controller from docshell. We also enable if we're
|
// the network controller from docshell. We also enable if we're
|
||||||
// in the parent process in order to support non-e10s configurations.
|
// in the parent process in order to support non-e10s configurations.
|
||||||
|
// Note: This check is duplicated in SharedWorkerInterfaceRequestor's
|
||||||
|
// constructor.
|
||||||
if (!ServiceWorkerParentInterceptEnabled() || XRE_IsParentProcess()) {
|
if (!ServiceWorkerParentInterceptEnabled() || XRE_IsParentProcess()) {
|
||||||
ds->mInterceptController = new ServiceWorkerInterceptController();
|
ds->mInterceptController = new ServiceWorkerInterceptController();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "mozilla/dom/MessagePort.h"
|
#include "mozilla/dom/MessagePort.h"
|
||||||
#include "mozilla/dom/RemoteWorkerTypes.h"
|
#include "mozilla/dom/RemoteWorkerTypes.h"
|
||||||
#include "mozilla/dom/ServiceWorkerInterceptController.h"
|
#include "mozilla/dom/ServiceWorkerInterceptController.h"
|
||||||
|
#include "mozilla/dom/ServiceWorkerUtils.h"
|
||||||
#include "mozilla/dom/workerinternals/ScriptLoader.h"
|
#include "mozilla/dom/workerinternals/ScriptLoader.h"
|
||||||
#include "mozilla/dom/WorkerError.h"
|
#include "mozilla/dom/WorkerError.h"
|
||||||
#include "mozilla/dom/WorkerPrivate.h"
|
#include "mozilla/dom/WorkerPrivate.h"
|
||||||
@@ -87,15 +88,19 @@ public:
|
|||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
SharedWorkerInterfaceRequestor()
|
SharedWorkerInterfaceRequestor()
|
||||||
: mSWController(new ServiceWorkerInterceptController())
|
{
|
||||||
{}
|
// This check must match the code nsDocShell::Create.
|
||||||
|
if (!ServiceWorkerParentInterceptEnabled() || XRE_IsParentProcess()) {
|
||||||
|
mSWController = new ServiceWorkerInterceptController();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHOD
|
NS_IMETHOD
|
||||||
GetInterface(const nsIID& aIID, void** aSink) override
|
GetInterface(const nsIID& aIID, void** aSink) override
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
if (aIID.Equals(NS_GET_IID(nsINetworkInterceptController))) {
|
if (mSWController && aIID.Equals(NS_GET_IID(nsINetworkInterceptController))) {
|
||||||
// If asked for the network intercept controller, ask the outer requestor,
|
// If asked for the network intercept controller, ask the outer requestor,
|
||||||
// which could be the docshell.
|
// which could be the docshell.
|
||||||
RefPtr<ServiceWorkerInterceptController> swController = mSWController;
|
RefPtr<ServiceWorkerInterceptController> swController = mSWController;
|
||||||
|
|||||||
Reference in New Issue
Block a user