Bug 1241531 - Part 2: Move Cancel() to ServiceWorkerJob base class. r=ehsan
authorBen Kelly <ben@wanderview.com>
Thu, 21 Jan 2016 08:49:00 -0500
changeset 281160 62452453a63600b7cb86ab72b2d4540ee4462907
parent 281159 cca3ee01a8623c5f5d82ffd14a71f8efa70ae732
child 281161 9979b9c3314a045f7b010c8d39f60a19d3b4469e
push id70679
push userryanvm@gmail.com
push dateFri, 22 Jan 2016 03:33:45 +0000
treeherdermozilla-inbound@ae7300dbece6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1241531
milestone46.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 1241531 - Part 2: Move Cancel() to ServiceWorkerJob base class. r=ehsan
dom/workers/ServiceWorkerManager.cpp
--- a/dom/workers/ServiceWorkerManager.cpp
+++ b/dom/workers/ServiceWorkerManager.cpp
@@ -163,33 +163,42 @@ public:
     RegisterJob,
     UpdateJob,
     InstallJob,
     UnregisterJob
   };
 
   virtual void Start() = 0;
 
+  void
+  Cancel()
+  {
+    mQueue = nullptr;
+    mCanceled = true;
+  }
+
   bool
   IsRegisterOrInstallJob() const
   {
     return mJobType == RegisterJob || mJobType == UpdateJob ||
       mJobType == InstallJob;
   }
 
 protected:
   // The queue keeps the jobs alive, so they can hold a rawptr back to the
   // queue.
   ServiceWorkerJobQueue* mQueue;
 
   Type mJobType;
+  bool mCanceled;
 
   explicit ServiceWorkerJob(ServiceWorkerJobQueue* aQueue, Type aJobType)
     : mQueue(aQueue)
     , mJobType(aJobType)
+    , mCanceled(false)
   {}
 
   virtual ~ServiceWorkerJob()
   {}
 
   void
   Done(nsresult aStatus);
 };
@@ -947,37 +956,28 @@ public:
                        ServiceWorkerUpdateFinishCallback* aCallback,
                        ServiceWorkerInfo* aServiceWorkerInfo)
     : ServiceWorkerJob(aQueue, aJobType)
     , mPrincipal(aPrincipal)
     , mScope(aScope)
     , mScriptSpec(aScriptSpec)
     , mCallback(aCallback)
     , mUpdateAndInstallInfo(aServiceWorkerInfo)
-    , mCanceled(false)
   {
     AssertIsOnMainThread();
     MOZ_ASSERT(aPrincipal);
   }
 
-  void
-  Cancel()
-  {
-    mQueue = nullptr;
-    mCanceled = true;
-  }
-
 protected:
   nsCOMPtr<nsIPrincipal> mPrincipal;
   const nsCString mScope;
   const nsCString mScriptSpec;
   RefPtr<ServiceWorkerUpdateFinishCallback> mCallback;
   RefPtr<ServiceWorkerRegistrationInfo> mRegistration;
   RefPtr<ServiceWorkerInfo> mUpdateAndInstallInfo;
-  bool mCanceled;
 
   ~ServiceWorkerJobBase()
   { }
 
   // Ensure that mRegistration is set for the job.  Also, if mRegistration was
   // already set, ensure that a new registration object has not replaced it in
   // the ServiceWorkerManager.  This can happen when jobs race such that the
   // registration is cleared and recreated while an update job is executing.