Bug 1496997 - Remove ServiceWorkerParentInterceptEnabled() and callers r=asuth,dom-workers-and-storage-reviewers,necko-reviewers,dragana

Differential Revision: https://phabricator.services.mozilla.com/D101785
This commit is contained in:
Yaron Tausky
2021-06-08 21:02:55 +00:00
parent 555d9e512d
commit 60cea25b8f
11 changed files with 12 additions and 102 deletions

View File

@@ -523,12 +523,11 @@ already_AddRefed<nsDocShell> nsDocShell::Create(
// Create our ContentListener
ds->mContentListener = new nsDSURIContentListener(ds);
// If parent intercept is not enabled then we must forward to
// the network controller from docshell. We also enable if we're
// in the parent process in order to support non-e10s configurations.
// We enable if we're 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 (XRE_IsParentProcess()) {
ds->mInterceptController = new ServiceWorkerInterceptController();
}

View File

@@ -2643,17 +2643,6 @@ void ContentChild::PreallocInit() {
// for telemetry.
const nsACString& ContentChild::GetRemoteType() const { return mRemoteType; }
mozilla::ipc::IPCResult ContentChild::RecvInitServiceWorkers(
const ServiceWorkerConfiguration& aConfig) {
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
if (!swm) {
// browser shutdown began
return IPC_OK();
}
swm->LoadRegistrations(aConfig.serviceWorkerRegistrations());
return IPC_OK();
}
mozilla::ipc::IPCResult ContentChild::RecvInitBlobURLs(
nsTArray<BlobURLRegistrationData>&& aRegistrations) {
for (uint32_t i = 0; i < aRegistrations.Length(); ++i) {

View File

@@ -396,9 +396,6 @@ class ContentChild final : public PContentChild,
// this for telemetry.
const nsACString& GetRemoteType() const override;
mozilla::ipc::IPCResult RecvInitServiceWorkers(
const ServiceWorkerConfiguration& aConfig);
mozilla::ipc::IPCResult RecvInitBlobURLs(
nsTArray<BlobURLRegistrationData>&& aRegistations);

View File

@@ -3109,26 +3109,6 @@ bool ContentParent::InitInternal(ProcessPriority aInitialPriority) {
}
#endif
if (!ServiceWorkerParentInterceptEnabled()) {
RefPtr<ServiceWorkerRegistrar> swr = ServiceWorkerRegistrar::Get();
MOZ_ASSERT(swr);
nsTArray<ServiceWorkerRegistrationData> registrations;
swr->GetRegistrations(registrations);
// Send down to the content process the permissions for each of the
// registered service worker scopes.
for (auto& registration : registrations) {
auto principalOrErr = PrincipalInfoToPrincipal(registration.principal());
if (principalOrErr.isOk()) {
nsCOMPtr<nsIPrincipal> principal = principalOrErr.unwrap();
TransmitPermissionsForPrincipal(principal);
}
}
Unused << SendInitServiceWorkers(ServiceWorkerConfiguration(registrations));
}
{
nsTArray<BlobURLRegistrationData> registrations;
BlobURLProtocolHandler::ForEachBlobURL(

View File

@@ -53,7 +53,6 @@ include PTabContext;
include ProtocolTypes;
include PBackgroundSharedTypes;
include PContentPermission;
include ServiceWorkerConfiguration;
include GraphicsMessages;
include MemoryReportTypes;
include ClientIPCTypes;
@@ -691,11 +690,6 @@ child:
*/
async RemoteType(nsCString aRemoteType);
/**
* Send ServiceWorkerRegistrationData to child process.
*/
async InitServiceWorkers(ServiceWorkerConfiguration aConfig);
/**
* Send BlobURLRegistrationData to child process.
*/

View File

@@ -1220,7 +1220,7 @@ ServiceWorkerNotificationObserver::Observe(nsISupports* aSubject,
}
if (!strcmp("alertclickcallback", aTopic)) {
if (XRE_IsParentProcess() || !ServiceWorkerParentInterceptEnabled()) {
if (XRE_IsParentProcess()) {
nsCOMPtr<nsIServiceWorkerManager> swm =
mozilla::components::ServiceWorkerManager::Service();
if (NS_WARN_IF(!swm)) {
@@ -1255,7 +1255,7 @@ ServiceWorkerNotificationObserver::Observe(nsISupports* aSubject,
notificationStorage->Delete(origin, mID);
}
if (XRE_IsParentProcess() || !ServiceWorkerParentInterceptEnabled()) {
if (XRE_IsParentProcess()) {
nsCOMPtr<nsIServiceWorkerManager> swm =
mozilla::components::ServiceWorkerManager::Service();
if (NS_WARN_IF(!swm)) {

View File

@@ -94,40 +94,6 @@ nsresult PushNotifier::Dispatch(PushDispatcher& aDispatcher) {
// Always notify XPCOM observers in the parent process.
Unused << NS_WARN_IF(NS_FAILED(aDispatcher.NotifyObservers()));
nsTArray<ContentParent*> contentActors;
ContentParent::GetAll(contentActors);
if (!contentActors.IsEmpty() && !ServiceWorkerParentInterceptEnabled()) {
// At least one content process is active, so e10s must be enabled.
// Broadcast a message to notify observers and service workers.
for (uint32_t i = 0; i < contentActors.Length(); ++i) {
// We need to filter based on process type, only "web" AKA the default
// remote type is acceptable. This should not run when Fission is
// enabled, and we specifically don't want this for
// LARGE_ALLOCATION_REMOTE_TYPE, so don't use IsWebRemoteType().
if (contentActors[i]->GetRemoteType() != DEFAULT_REMOTE_TYPE) {
continue;
}
// Ensure that the content actor has the permissions avaliable for the
// principal the push is being sent for before sending the push message
// down.
Unused << contentActors[i]->TransmitPermissionsForPrincipal(
aDispatcher.GetPrincipal());
if (aDispatcher.SendToChild(contentActors[i])) {
// Only send the push message to the first content process to avoid
// multiple SWs showing the same notification. See bug 1300112.
break;
}
}
return NS_OK;
}
if (BrowserTabsRemoteAutostart() &&
!ServiceWorkerParentInterceptEnabled()) {
// e10s is enabled, but no content processes are active.
return aDispatcher.HandleNoChildProcesses();
}
// e10s is disabled; notify workers in the parent.
return aDispatcher.NotifyWorkers();
}
@@ -266,17 +232,11 @@ bool PushDispatcher::ShouldNotifyWorkers() {
return true;
}
// If parent intercept is enabled, then we only want to notify in the parent
// process. Otherwise, we only want to notify in the child process.
// We only want to notify in the parent process.
bool isContentProcess = XRE_GetProcessType() == GeckoProcessType_Content;
bool parentInterceptEnabled = ServiceWorkerParentInterceptEnabled();
if (parentInterceptEnabled) {
return !isContentProcess;
}
return isContentProcess;
}
nsresult PushDispatcher::DoNotifyObservers(nsISupports* aSubject,
const char* aTopic,
const nsACString& aScope) {

View File

@@ -19,8 +19,6 @@
namespace mozilla {
namespace dom {
bool ServiceWorkerParentInterceptEnabled() { return true; }
bool ServiceWorkerRegistrationDataIsValid(
const ServiceWorkerRegistrationData& aData) {
return !aData.scope().IsEmpty() && !aData.currentWorkerURL().IsEmpty() &&

View File

@@ -42,8 +42,6 @@ typedef std::function<void(bool)> ServiceWorkerBoolCallback;
typedef std::function<void(ErrorResult&&)> ServiceWorkerFailureCallback;
bool ServiceWorkerParentInterceptEnabled();
bool ServiceWorkerRegistrationDataIsValid(
const ServiceWorkerRegistrationData& aData);

View File

@@ -32,7 +32,6 @@
using mozilla::Unused;
using mozilla::dom::ServiceWorkerInterceptController;
using mozilla::dom::ServiceWorkerParentInterceptEnabled;
namespace mozilla {
namespace net {
@@ -44,10 +43,8 @@ ParentChannelListener::ParentChannelListener(
LOG(("ParentChannelListener::ParentChannelListener [this=%p, next=%p]", this,
aListener));
if (ServiceWorkerParentInterceptEnabled()) {
mInterceptController = new ServiceWorkerInterceptController();
}
}
ParentChannelListener::~ParentChannelListener() {
LOG(("ParentChannelListener::~ParentChannelListener %p", this));

View File

@@ -9303,12 +9303,10 @@ nsresult nsHttpChannel::RedirectToInterceptedChannel() {
// Once child-side interception is removed and the internal redirect no
// longer needs to be "hidden", then this header copying code can be
// removed.
if (ServiceWorkerParentInterceptEnabled()) {
nsCOMPtr<nsIHttpHeaderVisitor> visitor =
new CopyNonDefaultHeaderVisitor(intercepted);
rv = VisitNonDefaultRequestHeaders(visitor);
NS_ENSURE_SUCCESS(rv, rv);
}
mRedirectChannel = intercepted;