Backed out changeset d32be4ed8786 (bug 1407276) for causing bug 1609665 to spike. a=backout
authorRazvan Maries <rmaries@mozilla.com>
Wed, 11 Mar 2020 18:38:18 +0200
changeset 518128 4c982daa151954c59f20a9b9ac805c1768a350c2
parent 518127 5e32bdf73dc213e9944205411baa0d51df681140
child 518212 765faed9e53ecfdf7cfa5ca6fbe637ac20c2de96
push id37205
push userrmaries@mozilla.com
push dateWed, 11 Mar 2020 16:39:42 +0000
treeherdermozilla-central@4c982daa1519 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1407276, 1609665
milestone76.0a1
backs outd32be4ed8786ed555678e484dbffb2581fa017e8
first release with
nightly linux32
4c982daa1519 / 76.0a1 / 20200311163942 / files
nightly linux64
4c982daa1519 / 76.0a1 / 20200311163942 / files
nightly mac
4c982daa1519 / 76.0a1 / 20200311163942 / files
nightly win32
4c982daa1519 / 76.0a1 / 20200311163942 / files
nightly win64
4c982daa1519 / 76.0a1 / 20200311163942 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset d32be4ed8786 (bug 1407276) for causing bug 1609665 to spike. a=backout
dom/serviceworkers/IPCServiceWorkerDescriptor.ipdlh
dom/serviceworkers/ServiceWorkerDescriptor.cpp
dom/serviceworkers/ServiceWorkerDescriptor.h
dom/serviceworkers/ServiceWorkerInfo.h
dom/serviceworkers/ServiceWorkerInterceptController.cpp
dom/serviceworkers/ServiceWorkerManager.cpp
dom/serviceworkers/ServiceWorkerManager.h
--- a/dom/serviceworkers/IPCServiceWorkerDescriptor.ipdlh
+++ b/dom/serviceworkers/IPCServiceWorkerDescriptor.ipdlh
@@ -16,13 +16,12 @@ struct IPCServiceWorkerDescriptor
 {
   uint64_t id;
   uint64_t registrationId;
   uint64_t registrationVersion;
   PrincipalInfo principalInfo;
   nsCString scope;
   nsCString scriptURL;
   ServiceWorkerState state;
-  bool handlesFetch;
 };
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/serviceworkers/ServiceWorkerDescriptor.cpp
+++ b/dom/serviceworkers/ServiceWorkerDescriptor.cpp
@@ -24,27 +24,25 @@ ServiceWorkerDescriptor::ServiceWorkerDe
       PrincipalToPrincipalInfo(aPrincipal, &mData->principalInfo()));
 
   mData->id() = aId;
   mData->registrationId() = aRegistrationId;
   mData->registrationVersion() = aRegistrationVersion;
   mData->scope() = aScope;
   mData->scriptURL() = aScriptURL;
   mData->state() = aState;
-  // Set HandlesFetch as true in default
-  mData->handlesFetch() = true;
 }
 
 ServiceWorkerDescriptor::ServiceWorkerDescriptor(
     uint64_t aId, uint64_t aRegistrationId, uint64_t aRegistrationVersion,
     const mozilla::ipc::PrincipalInfo& aPrincipalInfo, const nsACString& aScope,
     const nsACString& aScriptURL, ServiceWorkerState aState)
     : mData(MakeUnique<IPCServiceWorkerDescriptor>(
           aId, aRegistrationId, aRegistrationVersion, aPrincipalInfo,
-          nsCString(aScriptURL), nsCString(aScope), aState, true)) {}
+          nsCString(aScriptURL), nsCString(aScope), aState)) {}
 
 ServiceWorkerDescriptor::ServiceWorkerDescriptor(
     const IPCServiceWorkerDescriptor& aDescriptor)
     : mData(MakeUnique<IPCServiceWorkerDescriptor>(aDescriptor)) {}
 
 ServiceWorkerDescriptor::ServiceWorkerDescriptor(
     const ServiceWorkerDescriptor& aRight) {
   operator=(aRight);
@@ -115,24 +113,16 @@ void ServiceWorkerDescriptor::SetState(S
   mData->state() = aState;
 }
 
 void ServiceWorkerDescriptor::SetRegistrationVersion(uint64_t aVersion) {
   MOZ_DIAGNOSTIC_ASSERT(aVersion > mData->registrationVersion());
   mData->registrationVersion() = aVersion;
 }
 
-bool ServiceWorkerDescriptor::HandlesFetch() const {
-  return mData->handlesFetch();
-}
-
-void ServiceWorkerDescriptor::SetHandlesFetch(bool aHandlesFetch) {
-  mData->handlesFetch() = aHandlesFetch;
-}
-
 bool ServiceWorkerDescriptor::Matches(
     const ServiceWorkerDescriptor& aDescriptor) const {
   return Id() == aDescriptor.Id() && Scope() == aDescriptor.Scope() &&
          ScriptURL() == aDescriptor.ScriptURL() &&
          PrincipalInfo() == aDescriptor.PrincipalInfo();
 }
 
 const IPCServiceWorkerDescriptor& ServiceWorkerDescriptor::ToIPC() const {
--- a/dom/serviceworkers/ServiceWorkerDescriptor.h
+++ b/dom/serviceworkers/ServiceWorkerDescriptor.h
@@ -77,20 +77,16 @@ class ServiceWorkerDescriptor final {
   const nsCString& ScriptURL() const;
 
   ServiceWorkerState State() const;
 
   void SetState(ServiceWorkerState aState);
 
   void SetRegistrationVersion(uint64_t aVersion);
 
-  bool HandlesFetch() const;
-
-  void SetHandlesFetch(bool aHandlesFetch);
-
   // Try to determine if two workers match each other.  This is less strict
   // than an operator==() call since it ignores mutable values like State().
   bool Matches(const ServiceWorkerDescriptor& aDescriptor) const;
 
   // Expose the underlying IPC type so that it can be passed via IPC.
   const IPCServiceWorkerDescriptor& ToIPC() const;
 };
 
--- a/dom/serviceworkers/ServiceWorkerInfo.h
+++ b/dom/serviceworkers/ServiceWorkerInfo.h
@@ -121,17 +121,16 @@ class ServiceWorkerInfo final : public n
     MOZ_ASSERT(NS_IsMainThread());
     mDescriptor.SetState(aState);
   }
 
   void SetHandlesFetch(bool aHandlesFetch) {
     MOZ_ASSERT(NS_IsMainThread());
     MOZ_DIAGNOSTIC_ASSERT(mHandlesFetch == Unknown);
     mHandlesFetch = aHandlesFetch ? Enabled : Disabled;
-    mDescriptor.SetHandlesFetch(aHandlesFetch);
   }
 
   void SetRegistrationVersion(uint64_t aVersion);
 
   bool HandlesFetch() const {
     MOZ_ASSERT(NS_IsMainThread());
     MOZ_DIAGNOSTIC_ASSERT(mHandlesFetch != Unknown);
     return mHandlesFetch != Disabled;
--- a/dom/serviceworkers/ServiceWorkerInterceptController.cpp
+++ b/dom/serviceworkers/ServiceWorkerInterceptController.cpp
@@ -20,57 +20,33 @@ NS_IMPL_ISUPPORTS(ServiceWorkerIntercept
 
 NS_IMETHODIMP
 ServiceWorkerInterceptController::ShouldPrepareForIntercept(
     nsIURI* aURI, nsIChannel* aChannel, bool* aShouldIntercept) {
   *aShouldIntercept = false;
 
   nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
 
-  RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
-
   // For subresource requests we base our decision solely on the client's
   // controller value.  Any settings that would have blocked service worker
   // access should have been set before the initial navigation created the
   // window.
   if (!nsContentUtils::IsNonSubresourceRequest(aChannel)) {
     const Maybe<ServiceWorkerDescriptor>& controller =
         loadInfo->GetController();
-    // For child intercept, only checking the loadInfo controller existence.
-    if (!ServiceWorkerParentInterceptEnabled()) {
-      *aShouldIntercept = controller.isSome();
-      return NS_OK;
-    }
-
-    // If the controller doesn't handle fetch events, return false
-    if (controller.isSome()) {
-      *aShouldIntercept = controller.ref().HandlesFetch();
-
-      // The service worker has no fetch event handler, try to schedule a
-      // soft-update through ServiceWorkerRegistrationInfo.
-      // Get ServiceWorkerRegistrationInfo by the ServiceWorkerInfo's principal
-      // and scope
-      if (!*aShouldIntercept && swm) {
-        RefPtr<ServiceWorkerRegistrationInfo> registration =
-            swm->GetRegistration(controller.ref().GetPrincipal().get(),
-                                 controller.ref().Scope());
-        MOZ_ASSERT(registration);
-        registration->MaybeScheduleTimeCheckAndUpdate();
-      }
-    } else {
-      *aShouldIntercept = false;
-    }
+    *aShouldIntercept = controller.isSome();
     return NS_OK;
   }
 
   nsCOMPtr<nsIPrincipal> principal = BasePrincipal::CreateContentPrincipal(
       aURI, loadInfo->GetOriginAttributes());
 
   // First check with the ServiceWorkerManager for a matching service worker.
-  if (!swm || !swm->IsAvailable(principal, aURI, aChannel)) {
+  RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
+  if (!swm || !swm->IsAvailable(principal, aURI)) {
     return NS_OK;
   }
 
   // Then check to see if we are allowed to control the window.
   // It is important to check for the availability of the service worker first
   // to avoid showing warnings about the use of third-party cookies in the UI
   // unnecessarily when no service worker is being accessed.
   if (StorageAllowedForChannel(aChannel) != StorageAccess::eAllow) {
--- a/dom/serviceworkers/ServiceWorkerManager.cpp
+++ b/dom/serviceworkers/ServiceWorkerManager.cpp
@@ -2308,69 +2308,23 @@ void ServiceWorkerManager::DispatchFetch
     MOZ_ALWAYS_SUCCEEDS(permissionsRunnable->Run());
     return;
   }
   // Otherwise, ensure the upload stream can be cloned directly.  This may
   // require some async copying, so provide a callback.
   aRv = uploadChannel->EnsureUploadStreamIsCloneable(permissionsRunnable);
 }
 
-bool ServiceWorkerManager::IsAvailable(nsIPrincipal* aPrincipal, nsIURI* aURI,
-                                       nsIChannel* aChannel) {
+bool ServiceWorkerManager::IsAvailable(nsIPrincipal* aPrincipal, nsIURI* aURI) {
   MOZ_ASSERT(aPrincipal);
   MOZ_ASSERT(aURI);
-  MOZ_ASSERT(aChannel);
 
   RefPtr<ServiceWorkerRegistrationInfo> registration =
       GetServiceWorkerRegistrationInfo(aPrincipal, aURI);
-
-  // For child interception, just check the availability.
-  if (!ServiceWorkerParentInterceptEnabled()) {
-    return registration && registration->GetActive();
-  }
-
-  if (!registration || !registration->GetActive()) {
-    return false;
-  }
-
-  // Checking if the matched service worker handles fetch events or not.
-  // If it does, directly return true and handle the client controlling logic
-  // in DispatchFetchEvent(). otherwise, do followings then return false.
-  // 1. Set the matched service worker as the controller of LoadInfo and
-  //    correspoinding ClinetInfo
-  // 2. Maybe schedule a soft update
-  if (!registration->GetActive()->HandlesFetch()) {
-    // Checkin if the channel is not storage allowed first.
-    if (StorageAllowedForChannel(aChannel) != StorageAccess::eAllow) {
-      return false;
-    }
-
-    // ServiceWorkerInterceptController::ShouldPrepareForIntercept() handles the
-    // subresource cases. Must be non-subresource case here.
-    MOZ_ASSERT(nsContentUtils::IsNonSubresourceRequest(aChannel));
-
-    nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
-
-    Maybe<ClientInfo> clientInfo = loadInfo->GetReservedClientInfo();
-    if (clientInfo.isNothing()) {
-      clientInfo = loadInfo->GetInitialClientInfo();
-    }
-
-    if (clientInfo.isSome()) {
-      StartControllingClient(clientInfo.ref(), registration);
-    }
-    loadInfo->SetController(registration->GetActive()->Descriptor());
-
-    // https://w3c.github.io/ServiceWorker/#on-fetch-request-algorithm 17.1
-    // try schedule a soft-update for non-subresource case.
-    registration->MaybeScheduleTimeCheckAndUpdate();
-    return false;
-  }
-  // Found a matching service worker which handles fetch events, return true.
-  return true;
+  return registration && registration->GetActive();
 }
 
 nsresult ServiceWorkerManager::GetClientRegistration(
     const ClientInfo& aClientInfo,
     ServiceWorkerRegistrationInfo** aRegistrationInfo) {
   ControlledClientData* data = mControlledClients.Get(aClientInfo.Id());
   if (!data || !data->mRegistrationInfo) {
     return NS_ERROR_NOT_AVAILABLE;
--- a/dom/serviceworkers/ServiceWorkerManager.h
+++ b/dom/serviceworkers/ServiceWorkerManager.h
@@ -111,24 +111,17 @@ class ServiceWorkerManager final : publi
   friend class ServiceWorkerUpdateJob;
   friend class UpdateTimerCallback;
 
  public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSISERVICEWORKERMANAGER
   NS_DECL_NSIOBSERVER
 
-  // Return true if the given principal and URI matches a registered service
-  // worker which handles fetch event.
-  // If there is a matched service worker but doesn't handle fetch events, this
-  // method will try to set the matched service worker as the controller of the
-  // passed in channel. Then also schedule a soft-update job for the service
-  // worker.
-  bool IsAvailable(nsIPrincipal* aPrincipal, nsIURI* aURI,
-                   nsIChannel* aChannel);
+  bool IsAvailable(nsIPrincipal* aPrincipal, nsIURI* aURI);
 
   // Return true if the given content process could potentially be executing
   // service worker code with the given principal.  At the current time, this
   // just means that we have any registration for the origin, regardless of
   // scope.  This is a very weak guarantee but is the best we can do when push
   // notifications can currently spin up a service worker in content processes
   // without our involvement in the parent process.
   //