Bug 1527000 - Stop passing a null or empty nsILoadGroup to ServiceWorker CompareNetwork, r=asuth
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 15 Feb 2019 04:56:12 +0000
changeset 459504 539cfa77c2d24fe84b719e18fb7f78d4714deade
parent 459503 a031c9dd9dd5d0d90ca56bfbe6c6ded1a2fadf44
child 459505 e87e8a4c60f313381a442e855f952ac2ed192832
push id111964
push usercsabou@mozilla.com
push dateFri, 15 Feb 2019 18:54:44 +0000
treeherdermozilla-inbound@db3c4f905082 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1527000
milestone67.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 1527000 - Stop passing a null or empty nsILoadGroup to ServiceWorker CompareNetwork, r=asuth Differential Revision: https://phabricator.services.mozilla.com/D19381
dom/serviceworkers/ServiceWorkerManager.cpp
dom/serviceworkers/ServiceWorkerRegisterJob.cpp
dom/serviceworkers/ServiceWorkerRegisterJob.h
dom/serviceworkers/ServiceWorkerScriptCache.cpp
dom/serviceworkers/ServiceWorkerUpdateJob.cpp
dom/serviceworkers/ServiceWorkerUpdateJob.h
--- a/dom/serviceworkers/ServiceWorkerManager.cpp
+++ b/dom/serviceworkers/ServiceWorkerManager.cpp
@@ -767,19 +767,18 @@ RefPtr<ServiceWorkerRegistrationPromise>
   }
 
   RefPtr<ServiceWorkerJobQueue> queue =
       GetOrCreateJobQueue(scopeKey, aScopeURL);
 
   RefPtr<ServiceWorkerResolveWindowPromiseOnRegisterCallback> cb =
       new ServiceWorkerResolveWindowPromiseOnRegisterCallback();
 
-  nsCOMPtr<nsILoadGroup> loadGroup = do_CreateInstance(NS_LOADGROUP_CONTRACTID);
   RefPtr<ServiceWorkerRegisterJob> job = new ServiceWorkerRegisterJob(
-      principal, aScopeURL, aScriptURL, loadGroup,
+      principal, aScopeURL, aScriptURL,
       static_cast<ServiceWorkerUpdateViaCache>(aUpdateViaCache));
 
   job->AppendResultCallback(cb);
   queue->ScheduleJob(job);
 
   MOZ_ASSERT(NS_IsMainThread());
   Telemetry::Accumulate(Telemetry::SERVICE_WORKER_REGISTRATIONS, 1);
 
@@ -2250,17 +2249,17 @@ void ServiceWorkerManager::SoftUpdateInt
 
   // "If the registration queue for registration is empty, invoke Update
   // algorithm, or its equivalent, with client, registration as its argument."
   // TODO(catalinb): We don't implement the force bypass cache flag.
   // See: https://github.com/slightlyoff/ServiceWorker/issues/759
   RefPtr<ServiceWorkerJobQueue> queue = GetOrCreateJobQueue(scopeKey, aScope);
 
   RefPtr<ServiceWorkerUpdateJob> job = new ServiceWorkerUpdateJob(
-      principal, registration->Scope(), newest->ScriptSpec(), nullptr,
+      principal, registration->Scope(), newest->ScriptSpec(),
       registration->GetUpdateViaCache());
 
   if (aCallback) {
     RefPtr<UpdateJobCallback> cb = new UpdateJobCallback(aCallback);
     job->AppendResultCallback(cb);
   }
 
   queue->ScheduleJob(job);
@@ -2337,17 +2336,17 @@ void ServiceWorkerManager::UpdateInterna
     return;
   }
 
   RefPtr<ServiceWorkerJobQueue> queue = GetOrCreateJobQueue(scopeKey, aScope);
 
   // "Invoke Update algorithm, or its equivalent, with client, registration as
   // its argument."
   RefPtr<ServiceWorkerUpdateJob> job = new ServiceWorkerUpdateJob(
-      aPrincipal, registration->Scope(), newest->ScriptSpec(), nullptr,
+      aPrincipal, registration->Scope(), newest->ScriptSpec(),
       registration->GetUpdateViaCache());
 
   RefPtr<UpdateJobCallback> cb = new UpdateJobCallback(aCallback);
   job->AppendResultCallback(cb);
 
   queue->ScheduleJob(job);
 }
 
--- a/dom/serviceworkers/ServiceWorkerRegisterJob.cpp
+++ b/dom/serviceworkers/ServiceWorkerRegisterJob.cpp
@@ -9,20 +9,19 @@
 #include "mozilla/dom/WorkerCommon.h"
 #include "ServiceWorkerManager.h"
 
 namespace mozilla {
 namespace dom {
 
 ServiceWorkerRegisterJob::ServiceWorkerRegisterJob(
     nsIPrincipal* aPrincipal, const nsACString& aScope,
-    const nsACString& aScriptSpec, nsILoadGroup* aLoadGroup,
-    ServiceWorkerUpdateViaCache aUpdateViaCache)
+    const nsACString& aScriptSpec, ServiceWorkerUpdateViaCache aUpdateViaCache)
     : ServiceWorkerUpdateJob(Type::Register, aPrincipal, aScope, aScriptSpec,
-                             aLoadGroup, aUpdateViaCache) {}
+                             aUpdateViaCache) {}
 
 void ServiceWorkerRegisterJob::AsyncExecute() {
   MOZ_ASSERT(NS_IsMainThread());
 
   RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
   if (Canceled() || !swm) {
     FailUpdateJob(NS_ERROR_DOM_ABORT_ERR);
     return;
--- a/dom/serviceworkers/ServiceWorkerRegisterJob.h
+++ b/dom/serviceworkers/ServiceWorkerRegisterJob.h
@@ -14,17 +14,16 @@ namespace dom {
 
 // The register job.  This implements the steps in the spec Register algorithm,
 // but then uses ServiceWorkerUpdateJob to implement the Update and Install
 // spec algorithms.
 class ServiceWorkerRegisterJob final : public ServiceWorkerUpdateJob {
  public:
   ServiceWorkerRegisterJob(nsIPrincipal* aPrincipal, const nsACString& aScope,
                            const nsACString& aScriptSpec,
-                           nsILoadGroup* aLoadGroup,
                            ServiceWorkerUpdateViaCache aUpdateViaCache);
 
  private:
   // Implement the Register algorithm steps and then call the parent class
   // Update() to complete the job execution.
   virtual void AsyncExecute() override;
 
   virtual ~ServiceWorkerRegisterJob();
--- a/dom/serviceworkers/ServiceWorkerScriptCache.cpp
+++ b/dom/serviceworkers/ServiceWorkerScriptCache.cpp
@@ -104,17 +104,17 @@ class CompareNetwork final : public nsIS
         mCacheResult(NS_OK),
         mIsMainScript(aIsMainScript),
         mIsFromCache(false) {
     MOZ_ASSERT(aManager);
     MOZ_ASSERT(NS_IsMainThread());
   }
 
   nsresult Initialize(nsIPrincipal* aPrincipal, const nsAString& aURL,
-                      nsILoadGroup* aLoadGroup, Cache* const aCache);
+                      Cache* const aCache);
 
   void Abort();
 
   void NetworkFinish(nsresult aRv);
 
   void CacheFinish(nsresult aRv);
 
   const nsString& URL() const {
@@ -252,17 +252,17 @@ class CompareManager final : public Prom
         mPendingCount(0),
         mOnFailure(OnFailure::DoNothing),
         mAreScriptsEqual(true) {
     MOZ_ASSERT(NS_IsMainThread());
     MOZ_ASSERT(aRegistration);
   }
 
   nsresult Initialize(nsIPrincipal* aPrincipal, const nsAString& aURL,
-                      const nsAString& aCacheName, nsILoadGroup* aLoadGroup);
+                      const nsAString& aCacheName);
 
   void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override;
 
   void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override;
 
   CacheStorage* CacheStorage_() {
     MOZ_ASSERT(NS_IsMainThread());
     MOZ_ASSERT(mCacheStorage);
@@ -325,17 +325,17 @@ class CompareManager final : public Prom
     MOZ_DIAGNOSTIC_ASSERT(mState == WaitingForInitialization ||
                           mState == WaitingForScriptOrComparisonResult);
 
     RefPtr<CompareNetwork> cn =
         new CompareNetwork(this, mRegistration, aIsMainScript);
     mCNList.AppendElement(cn);
     mPendingCount += 1;
 
-    nsresult rv = cn->Initialize(mPrincipal, aURL, mLoadGroup, aCache);
+    nsresult rv = cn->Initialize(mPrincipal, aURL, aCache);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     return NS_OK;
   }
 
   void ManageOldCache(JSContext* aCx, JS::Handle<JS::Value> aValue) {
@@ -581,17 +581,16 @@ class CompareManager final : public Prom
   RefPtr<ServiceWorkerRegistrationInfo> mRegistration;
   RefPtr<CompareCallback> mCallback;
   RefPtr<CacheStorage> mCacheStorage;
 
   nsTArray<RefPtr<CompareNetwork>> mCNList;
 
   nsString mURL;
   RefPtr<nsIPrincipal> mPrincipal;
-  RefPtr<nsILoadGroup> mLoadGroup;
 
   // Used for the old cache where saves the old source scripts.
   RefPtr<Cache> mOldCache;
 
   // Only used if the network script has changed and needs to be cached.
   nsString mNewCacheName;
 
   nsCString mMaxScope;
@@ -611,17 +610,16 @@ class CompareManager final : public Prom
   OnFailure mOnFailure;
   bool mAreScriptsEqual;
 };
 
 NS_IMPL_ISUPPORTS0(CompareManager)
 
 nsresult CompareNetwork::Initialize(nsIPrincipal* aPrincipal,
                                     const nsAString& aURL,
-                                    nsILoadGroup* aLoadGroup,
                                     Cache* const aCache) {
   MOZ_ASSERT(aPrincipal);
   MOZ_ASSERT(NS_IsMainThread());
 
   nsCOMPtr<nsIURI> uri;
   nsresult rv = NS_NewURI(getter_AddRefs(uri), aURL, nullptr, nullptr);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
@@ -1139,29 +1137,27 @@ void CompareCache::ManageValueResult(JSC
       Finish(rv, false);
       return;
     }
   }
 }
 
 nsresult CompareManager::Initialize(nsIPrincipal* aPrincipal,
                                     const nsAString& aURL,
-                                    const nsAString& aCacheName,
-                                    nsILoadGroup* aLoadGroup) {
+                                    const nsAString& aCacheName) {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aPrincipal);
   MOZ_ASSERT(mPendingCount == 0);
   MOZ_DIAGNOSTIC_ASSERT(mState == WaitingForInitialization);
 
   // RAII Cleanup when fails.
   auto guard = MakeScopeExit([&] { Cleanup(); });
 
   mURL = aURL;
   mPrincipal = aPrincipal;
-  mLoadGroup = aLoadGroup;
 
   // Always create a CacheStorage since we want to write the network entry to
   // the cache even if there isn't an existing one.
   AutoJSAPI jsapi;
   jsapi.Init();
   ErrorResult result;
   mCacheStorage = CreateCacheStorage(jsapi.cx(), aPrincipal, result);
   if (NS_WARN_IF(result.Failed())) {
@@ -1329,27 +1325,26 @@ nsresult GenerateCacheName(nsAString& aN
   // NSID_LENGTH counts the null terminator.
   aName.AssignASCII(chars, NSID_LENGTH - 1);
 
   return NS_OK;
 }
 
 nsresult Compare(ServiceWorkerRegistrationInfo* aRegistration,
                  nsIPrincipal* aPrincipal, const nsAString& aCacheName,
-                 const nsAString& aURL, CompareCallback* aCallback,
-                 nsILoadGroup* aLoadGroup) {
+                 const nsAString& aURL, CompareCallback* aCallback) {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aRegistration);
   MOZ_ASSERT(aPrincipal);
   MOZ_ASSERT(!aURL.IsEmpty());
   MOZ_ASSERT(aCallback);
 
   RefPtr<CompareManager> cm = new CompareManager(aRegistration, aCallback);
 
-  nsresult rv = cm->Initialize(aPrincipal, aURL, aCacheName, aLoadGroup);
+  nsresult rv = cm->Initialize(aPrincipal, aURL, aCacheName);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   return NS_OK;
 }
 
 }  // namespace serviceWorkerScriptCache
--- a/dom/serviceworkers/ServiceWorkerUpdateJob.cpp
+++ b/dom/serviceworkers/ServiceWorkerUpdateJob.cpp
@@ -146,36 +146,32 @@ class ServiceWorkerUpdateJob::ContinueIn
     mJob->ContinueAfterInstallEvent(mSuccess);
     mJob = nullptr;
     return NS_OK;
   }
 };
 
 ServiceWorkerUpdateJob::ServiceWorkerUpdateJob(
     nsIPrincipal* aPrincipal, const nsACString& aScope,
-    const nsACString& aScriptSpec, nsILoadGroup* aLoadGroup,
-    ServiceWorkerUpdateViaCache aUpdateViaCache)
+    const nsACString& aScriptSpec, ServiceWorkerUpdateViaCache aUpdateViaCache)
     : ServiceWorkerJob(Type::Update, aPrincipal, aScope, aScriptSpec),
-      mLoadGroup(aLoadGroup),
       mUpdateViaCache(aUpdateViaCache),
       mOnFailure(OnFailure::DoNothing) {}
 
 already_AddRefed<ServiceWorkerRegistrationInfo>
 ServiceWorkerUpdateJob::GetRegistration() const {
   MOZ_ASSERT(NS_IsMainThread());
   RefPtr<ServiceWorkerRegistrationInfo> ref = mRegistration;
   return ref.forget();
 }
 
 ServiceWorkerUpdateJob::ServiceWorkerUpdateJob(
     Type aType, nsIPrincipal* aPrincipal, const nsACString& aScope,
-    const nsACString& aScriptSpec, nsILoadGroup* aLoadGroup,
-    ServiceWorkerUpdateViaCache aUpdateViaCache)
+    const nsACString& aScriptSpec, ServiceWorkerUpdateViaCache aUpdateViaCache)
     : ServiceWorkerJob(aType, aPrincipal, aScope, aScriptSpec),
-      mLoadGroup(aLoadGroup),
       mUpdateViaCache(aUpdateViaCache),
       mOnFailure(serviceWorkerScriptCache::OnFailure::DoNothing) {}
 
 ServiceWorkerUpdateJob::~ServiceWorkerUpdateJob() {}
 
 void ServiceWorkerUpdateJob::FailUpdateJob(ErrorResult& aRv) {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aRv.Failed());
@@ -295,17 +291,17 @@ void ServiceWorkerUpdateJob::Update() {
   if (workerInfo && workerInfo->ScriptSpec().Equals(mScriptSpec)) {
     cacheName = workerInfo->CacheName();
   }
 
   RefPtr<CompareCallback> callback = new CompareCallback(this);
 
   nsresult rv = serviceWorkerScriptCache::Compare(
       mRegistration, mPrincipal, cacheName, NS_ConvertUTF8toUTF16(mScriptSpec),
-      callback, mLoadGroup);
+      callback);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     FailUpdateJob(rv);
     return;
   }
 }
 
 ServiceWorkerUpdateViaCache ServiceWorkerUpdateJob::GetUpdateViaCache() const {
   return mUpdateViaCache;
--- a/dom/serviceworkers/ServiceWorkerUpdateJob.h
+++ b/dom/serviceworkers/ServiceWorkerUpdateJob.h
@@ -25,27 +25,25 @@ class ServiceWorkerRegistrationInfo;
 // as a different job type.  This is necessary because the register job
 // performs largely the same operations as the update job, but has a few
 // different starting steps.
 class ServiceWorkerUpdateJob : public ServiceWorkerJob {
  public:
   // Construct an update job to be used only for updates.
   ServiceWorkerUpdateJob(nsIPrincipal* aPrincipal, const nsACString& aScope,
                          const nsACString& aScriptSpec,
-                         nsILoadGroup* aLoadGroup,
                          ServiceWorkerUpdateViaCache aUpdateViaCache);
 
   already_AddRefed<ServiceWorkerRegistrationInfo> GetRegistration() const;
 
  protected:
   // Construct an update job that is overriden as another job type.
   ServiceWorkerUpdateJob(Type aType, nsIPrincipal* aPrincipal,
                          const nsACString& aScope,
                          const nsACString& aScriptSpec,
-                         nsILoadGroup* aLoadGroup,
                          ServiceWorkerUpdateViaCache aUpdateViaCache);
 
   virtual ~ServiceWorkerUpdateJob();
 
   // FailUpdateJob() must be called if an update job needs Finish() with
   // an error.
   void FailUpdateJob(ErrorResult& aRv);
 
@@ -85,17 +83,16 @@ class ServiceWorkerUpdateJob : public Se
 
   // Utility method corresponding to the spec Install algorithm.
   void Install();
 
   // Utility method called after the install event is handled.
   void ContinueAfterInstallEvent(bool aInstallEventSuccess);
 
   RefPtr<ServiceWorkerRegistrationInfo> mRegistration;
-  nsCOMPtr<nsILoadGroup> mLoadGroup;
   ServiceWorkerUpdateViaCache mUpdateViaCache;
   serviceWorkerScriptCache::OnFailure mOnFailure;
 };
 
 }  // namespace dom
 }  // namespace mozilla
 
 #endif  // mozilla_dom_serviceworkerupdatejob_h