Bug 1439099 P3 Remove ServiceWorker::MatchesDescriptor() in favor of Descriptor().Matches(). r=asuth
authorBen Kelly <ben@wanderview.com>
Mon, 19 Feb 2018 12:06:19 -0800
changeset 404416 a2ebde19d2781370ea487c93ce9a7a0c7d6b263f
parent 404415 3c0e2869bb10216d07548322aa94f5585b35df4b
child 404417 1874ac39b41cbeaee0dd9b2442aacfd7c3731735
push id100001
push userbkelly@mozilla.com
push dateMon, 19 Feb 2018 20:06:28 +0000
treeherdermozilla-inbound@a2ebde19d278 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1439099
milestone60.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 1439099 P3 Remove ServiceWorker::MatchesDescriptor() in favor of Descriptor().Matches(). r=asuth
dom/base/nsGlobalWindowInner.cpp
dom/serviceworkers/ServiceWorker.cpp
dom/serviceworkers/ServiceWorker.h
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -6389,17 +6389,17 @@ nsGlobalWindowInner::GetController() con
 }
 
 RefPtr<ServiceWorker>
 nsGlobalWindowInner::GetOrCreateServiceWorker(const ServiceWorkerDescriptor& aDescriptor)
 {
   MOZ_ASSERT(NS_IsMainThread());
   RefPtr<ServiceWorker> ref;
   for (auto sw : mServiceWorkerList) {
-    if (sw->MatchesDescriptor(aDescriptor)) {
+    if (sw->Descriptor().Matches(aDescriptor)) {
       ref = sw;
       return ref.forget();
     }
   }
   ref = ServiceWorker::Create(this, aDescriptor);
   return ref.forget();
 }
 
--- a/dom/serviceworkers/ServiceWorker.cpp
+++ b/dom/serviceworkers/ServiceWorker.cpp
@@ -136,25 +136,21 @@ ServiceWorker::PostMessage(JSContext* aC
   if (State() == ServiceWorkerState::Redundant) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
   mInner->PostMessage(GetParentObject(), aCx, aMessage, aTransferable, aRv);
 }
 
-bool
-ServiceWorker::MatchesDescriptor(const ServiceWorkerDescriptor& aDescriptor) const
+
+const ServiceWorkerDescriptor&
+ServiceWorker::Descriptor() const
 {
-  // Compare everything in the descriptor except the state.  That is mutable
-  // and may not exactly match.
-  return mDescriptor.PrincipalInfo() == aDescriptor.PrincipalInfo() &&
-         mDescriptor.Scope() == aDescriptor.Scope() &&
-         mDescriptor.ScriptURL() == aDescriptor.ScriptURL() &&
-         mDescriptor.Id() == aDescriptor.Id();
+  return mDescriptor;
 }
 
 void
 ServiceWorker::DisconnectFromOwner()
 {
   nsIGlobalObject* global = GetParentObject();
   if (global) {
     global->RemoveServiceWorker(this);
--- a/dom/serviceworkers/ServiceWorker.h
+++ b/dom/serviceworkers/ServiceWorker.h
@@ -78,18 +78,18 @@ public:
 
   void
   GetScriptURL(nsString& aURL) const;
 
   void
   PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
               const Sequence<JSObject*>& aTransferable, ErrorResult& aRv);
 
-  bool
-  MatchesDescriptor(const ServiceWorkerDescriptor& aDescriptor) const;
+  const ServiceWorkerDescriptor&
+  Descriptor() const;
 
   void
   DisconnectFromOwner() override;
 
 private:
   ServiceWorker(nsIGlobalObject* aWindow,
                 const ServiceWorkerDescriptor& aDescriptor,
                 Inner* aInner);