Bug 1469048 Disable service worker propagation when e10s pref is enabled. r=mrbkap
authorBen Kelly <ben@wanderview.com>
Mon, 09 Jul 2018 16:02:41 -0700
changeset 480817 031986327e4b40f543852f82378dde497128a370
parent 480816 fcf922ceca661836fc6f59d8fd3ef395709dfe75
child 480818 88c4d6e6d52984c78d840cff762309af5b1969ec
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs1469048
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1469048 Disable service worker propagation when e10s pref is enabled. r=mrbkap
dom/ipc/ContentParent.cpp
dom/serviceworkers/ServiceWorkerInfo.cpp
dom/serviceworkers/ServiceWorkerManager.cpp
dom/serviceworkers/ServiceWorkerManagerService.cpp
dom/serviceworkers/ServiceWorkerRegistrationInfo.cpp
dom/serviceworkers/ServiceWorkerUpdaterChild.cpp
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -54,16 +54,17 @@
 #include "mozilla/dom/PositionError.h"
 #include "mozilla/dom/ServiceWorkerRegistrar.h"
 #include "mozilla/dom/power/PowerManagerService.h"
 #include "mozilla/dom/Permissions.h"
 #include "mozilla/dom/PresentationParent.h"
 #include "mozilla/dom/PPresentationParent.h"
 #include "mozilla/dom/PushNotifier.h"
 #include "mozilla/dom/quota/QuotaManagerService.h"
+#include "mozilla/dom/ServiceWorkerUtils.h"
 #include "mozilla/dom/URLClassifierParent.h"
 #include "mozilla/embedding/printingui/PrintingParent.h"
 #include "mozilla/extensions/StreamFilterParent.h"
 #include "mozilla/gfx/gfxVars.h"
 #include "mozilla/gfx/GPUProcessManager.h"
 #include "mozilla/hal_sandbox/PHalParent.h"
 #include "mozilla/ipc/BackgroundChild.h"
 #include "mozilla/ipc/BackgroundParent.h"
@@ -2463,17 +2464,17 @@ ContentParent::InitInternal(ProcessPrior
     }
   }
 #endif
   if (shouldSandbox && !SendSetProcessSandbox(brokerFd)) {
     KillHard("SandboxInitFailed");
   }
 #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.
--- a/dom/serviceworkers/ServiceWorkerInfo.cpp
+++ b/dom/serviceworkers/ServiceWorkerInfo.cpp
@@ -163,16 +163,18 @@ ServiceWorkerInfo::ServiceWorkerInfo(nsI
   , mCreationTimeStamp(TimeStamp::Now())
   , mInstalledTime(0)
   , mActivatedTime(0)
   , mRedundantTime(0)
   , mServiceWorkerPrivate(new ServiceWorkerPrivate(this))
   , mSkipWaitingFlag(false)
   , mHandlesFetch(Unknown)
 {
+  MOZ_ASSERT_IF(ServiceWorkerParentInterceptEnabled(),
+                XRE_GetProcessType() == GeckoProcessType_Default);
   MOZ_ASSERT(mPrincipal);
   // cache origin attributes so we can use them off main thread
   mOriginAttributes = mPrincipal->OriginAttributesRef();
   MOZ_ASSERT(!mDescriptor.ScriptURL().IsEmpty());
   MOZ_ASSERT(!mCacheName.IsEmpty());
 
   // Scripts of a service worker should always be loaded bypass service workers.
   // Otherwise, we might not be able to update a service worker correctly, if
--- a/dom/serviceworkers/ServiceWorkerManager.cpp
+++ b/dom/serviceworkers/ServiceWorkerManager.cpp
@@ -2313,16 +2313,21 @@ ServiceWorkerManager::SoftUpdate(const O
                                  const nsACString& aScope)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (mShuttingDown) {
     return;
   }
 
+  if (ServiceWorkerParentInterceptEnabled()) {
+    SoftUpdateInternal(aOriginAttributes, aScope, nullptr);
+    return;
+  }
+
   RefPtr<GenericPromise::Private> promise =
     new GenericPromise::Private(__func__);
 
   RefPtr<CancelableRunnable> successRunnable =
     new SoftUpdateRunnable(aOriginAttributes, aScope, true, promise);
 
   RefPtr<CancelableRunnable> failureRunnable =
     new ResolvePromiseRunnable(promise);
@@ -2374,17 +2379,16 @@ public:
 } // anonymous namespace
 
 void
 ServiceWorkerManager::SoftUpdateInternal(const OriginAttributes& aOriginAttributes,
                                          const nsACString& aScope,
                                          ServiceWorkerUpdateFinishCallback* aCallback)
 {
   MOZ_ASSERT(NS_IsMainThread());
-  MOZ_ASSERT(aCallback);
 
   if (mShuttingDown) {
     return;
   }
 
   nsCOMPtr<nsIURI> scopeURI;
   nsresult rv = NS_NewURI(getter_AddRefs(scopeURI), aScope);
   if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -2434,29 +2438,36 @@ ServiceWorkerManager::SoftUpdateInternal
   RefPtr<ServiceWorkerJobQueue> queue = GetOrCreateJobQueue(scopeKey,
                                                             aScope);
 
   RefPtr<ServiceWorkerUpdateJob> job =
     new ServiceWorkerUpdateJob(principal, registration->Scope(),
                                newest->ScriptSpec(), nullptr,
                                registration->GetUpdateViaCache());
 
-  RefPtr<UpdateJobCallback> cb = new UpdateJobCallback(aCallback);
-  job->AppendResultCallback(cb);
+  if (aCallback) {
+    RefPtr<UpdateJobCallback> cb = new UpdateJobCallback(aCallback);
+    job->AppendResultCallback(cb);
+  }
 
   queue->ScheduleJob(job);
 }
 
 void
 ServiceWorkerManager::Update(nsIPrincipal* aPrincipal,
                              const nsACString& aScope,
                              ServiceWorkerUpdateFinishCallback* aCallback)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
+  if (ServiceWorkerParentInterceptEnabled()) {
+    UpdateInternal(aPrincipal, aScope, aCallback);
+    return;
+  }
+
   RefPtr<GenericPromise::Private> promise =
     new GenericPromise::Private(__func__);
 
   RefPtr<CancelableRunnable> successRunnable =
     new UpdateRunnable(aPrincipal, aScope, aCallback,
                        UpdateRunnable::eSuccess, promise);
 
   RefPtr<CancelableRunnable> failureRunnable =
--- a/dom/serviceworkers/ServiceWorkerManagerService.cpp
+++ b/dom/serviceworkers/ServiceWorkerManagerService.cpp
@@ -86,16 +86,20 @@ ServiceWorkerManagerService::UnregisterA
 
 void
 ServiceWorkerManagerService::PropagateRegistration(
                                            uint64_t aParentID,
                                            ServiceWorkerRegistrationData& aData)
 {
   AssertIsOnBackgroundThread();
 
+  if (ServiceWorkerParentInterceptEnabled()) {
+    return;
+  }
+
   DebugOnly<bool> parentFound = false;
   for (auto iter = mAgents.Iter(); !iter.Done(); iter.Next()) {
     RefPtr<ServiceWorkerManagerParent> parent = iter.Get()->GetKey();
     MOZ_ASSERT(parent);
 
     if (parent->ID() != aParentID) {
       Unused << parent->SendNotifyRegister(aData);
 #ifdef DEBUG
@@ -128,16 +132,20 @@ ServiceWorkerManagerService::PropagateRe
 void
 ServiceWorkerManagerService::PropagateSoftUpdate(
                                       uint64_t aParentID,
                                       const OriginAttributes& aOriginAttributes,
                                       const nsAString& aScope)
 {
   AssertIsOnBackgroundThread();
 
+  if (ServiceWorkerParentInterceptEnabled()) {
+    return;
+  }
+
   DebugOnly<bool> parentFound = false;
   for (auto iter = mAgents.Iter(); !iter.Done(); iter.Next()) {
     RefPtr<ServiceWorkerManagerParent> parent = iter.Get()->GetKey();
     MOZ_ASSERT(parent);
 
     nsString scope(aScope);
     Unused << parent->SendNotifySoftUpdate(aOriginAttributes,
                                            scope);
@@ -157,16 +165,20 @@ ServiceWorkerManagerService::PropagateSo
 void
 ServiceWorkerManagerService::PropagateUnregister(
                                             uint64_t aParentID,
                                             const PrincipalInfo& aPrincipalInfo,
                                             const nsAString& aScope)
 {
   AssertIsOnBackgroundThread();
 
+  if (ServiceWorkerParentInterceptEnabled()) {
+    return;
+  }
+
   RefPtr<dom::ServiceWorkerRegistrar> service =
     dom::ServiceWorkerRegistrar::Get();
   MOZ_ASSERT(service);
 
   // It's possible that we don't have any ServiceWorkerManager managing this
   // scope but we still need to unregister it from the ServiceWorkerRegistrar.
   service->UnregisterServiceWorker(aPrincipalInfo,
                                    NS_ConvertUTF16toUTF8(aScope));
@@ -192,16 +204,20 @@ ServiceWorkerManagerService::PropagateUn
 }
 
 void
 ServiceWorkerManagerService::PropagateRemove(uint64_t aParentID,
                                              const nsACString& aHost)
 {
   AssertIsOnBackgroundThread();
 
+  if (ServiceWorkerParentInterceptEnabled()) {
+    return;
+  }
+
   DebugOnly<bool> parentFound = false;
   for (auto iter = mAgents.Iter(); !iter.Done(); iter.Next()) {
     RefPtr<ServiceWorkerManagerParent> parent = iter.Get()->GetKey();
     MOZ_ASSERT(parent);
 
     if (parent->ID() != aParentID) {
       nsCString host(aHost);
       Unused << parent->SendNotifyRemove(host);
@@ -217,16 +233,20 @@ ServiceWorkerManagerService::PropagateRe
 #endif
 }
 
 void
 ServiceWorkerManagerService::PropagateRemoveAll(uint64_t aParentID)
 {
   AssertIsOnBackgroundThread();
 
+  if (ServiceWorkerParentInterceptEnabled()) {
+    return;
+  }
+
   RefPtr<dom::ServiceWorkerRegistrar> service =
     dom::ServiceWorkerRegistrar::Get();
   MOZ_ASSERT(service);
 
   service->RemoveAll();
 
   DebugOnly<bool> parentFound = false;
   for (auto iter = mAgents.Iter(); !iter.Done(); iter.Next()) {
@@ -250,16 +270,18 @@ ServiceWorkerManagerService::PropagateRe
 void
 ServiceWorkerManagerService::ProcessUpdaterActor(ServiceWorkerUpdaterParent* aActor,
                                                  const OriginAttributes& aOriginAttributes,
                                                  const nsACString& aScope,
                                                  uint64_t aParentId)
 {
   AssertIsOnBackgroundThread();
 
+  MOZ_DIAGNOSTIC_ASSERT(!ServiceWorkerParentInterceptEnabled());
+
   nsAutoCString suffix;
   aOriginAttributes.CreateSuffix(suffix);
 
   nsCString scope(aScope);
   scope.Append(suffix);
 
   for (uint32_t i = 0; i < mPendingUpdaterActors.Length(); ++i) {
     // We already have an actor doing this update on another process.
--- a/dom/serviceworkers/ServiceWorkerRegistrationInfo.cpp
+++ b/dom/serviceworkers/ServiceWorkerRegistrationInfo.cpp
@@ -103,17 +103,20 @@ ServiceWorkerRegistrationInfo::ServiceWo
   , mControlledClientsCounter(0)
   , mDelayMultiplier(0)
   , mUpdateState(NoUpdate)
   , mCreationTime(PR_Now())
   , mCreationTimeStamp(TimeStamp::Now())
   , mLastUpdateTime(0)
   , mPendingUninstall(false)
   , mCorrupt(false)
-{}
+{
+  MOZ_ASSERT_IF(ServiceWorkerParentInterceptEnabled(),
+                XRE_GetProcessType() == GeckoProcessType_Default);
+}
 
 ServiceWorkerRegistrationInfo::~ServiceWorkerRegistrationInfo()
 {
   MOZ_DIAGNOSTIC_ASSERT(!IsControllingClients());
 }
 
 void
 ServiceWorkerRegistrationInfo::AddInstance(ServiceWorkerRegistrationListener* aInstance,
--- a/dom/serviceworkers/ServiceWorkerUpdaterChild.cpp
+++ b/dom/serviceworkers/ServiceWorkerUpdaterChild.cpp
@@ -14,16 +14,18 @@ ServiceWorkerUpdaterChild::ServiceWorker
                                                      CancelableRunnable* aSuccessRunnable,
                                                      CancelableRunnable* aFailureRunnable)
   : mSuccessRunnable(aSuccessRunnable)
   , mFailureRunnable(aFailureRunnable)
 {
   // TODO: remove the main thread restriction after fixing bug 1364821.
   MOZ_ASSERT(NS_IsMainThread());
 
+  MOZ_DIAGNOSTIC_ASSERT(!ServiceWorkerParentInterceptEnabled());
+
   MOZ_ASSERT(aPromise);
   MOZ_ASSERT(aSuccessRunnable);
   MOZ_ASSERT(aFailureRunnable);
 
   aPromise->Then(GetMainThreadSerialEventTarget(), __func__,
     [this]() {
       mPromiseHolder.Complete();
       Unused << Send__delete__(this);