Bug 1433568 Remove the empty ServiceWorkerDescriptor() constructor. r=asuth
authorBen Kelly <ben@wanderview.com>
Mon, 29 Jan 2018 07:52:44 -0800
changeset 401223 873831981ed89de7b81ccdacba966d206cc3b701
parent 401222 15e5dcaa825751d2c7fa9b170e0d3e9306025301
child 401224 5e78fa0f7d18b0abd9f54d01b057d26c49499c9d
push id99322
push userbkelly@mozilla.com
push dateMon, 29 Jan 2018 15:52:51 +0000
treeherdermozilla-inbound@873831981ed8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1433568
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 1433568 Remove the empty ServiceWorkerDescriptor() constructor. r=asuth
dom/serviceworkers/ServiceWorkerDescriptor.cpp
dom/serviceworkers/ServiceWorkerDescriptor.h
dom/serviceworkers/ServiceWorkerInfo.cpp
--- a/dom/serviceworkers/ServiceWorkerDescriptor.cpp
+++ b/dom/serviceworkers/ServiceWorkerDescriptor.cpp
@@ -7,19 +7,28 @@
 #include "ServiceWorkerDescriptor.h"
 #include "mozilla/dom/IPCServiceWorkerDescriptor.h"
 #include "mozilla/dom/ServiceWorkerBinding.h"
 #include "mozilla/ipc/PBackgroundSharedTypes.h"
 
 namespace mozilla {
 namespace dom {
 
-ServiceWorkerDescriptor::ServiceWorkerDescriptor()
+ServiceWorkerDescriptor::ServiceWorkerDescriptor(uint64_t aId,
+                                                 nsIPrincipal* aPrincipal,
+                                                 const nsACString& aScope,
+                                                 ServiceWorkerState aState)
   : mData(MakeUnique<IPCServiceWorkerDescriptor>())
 {
+  MOZ_ALWAYS_SUCCEEDS(
+    PrincipalToPrincipalInfo(aPrincipal, &mData->principalInfo()));
+
+  mData->id() = aId;
+  mData->scope() = aScope;
+  mData->state() = aState;
 }
 
 ServiceWorkerDescriptor::ServiceWorkerDescriptor(uint64_t aId,
                                                  const mozilla::ipc::PrincipalInfo& aPrincipalInfo,
                                                  const nsACString& aScope,
                                                  ServiceWorkerState aState)
   : mData(MakeUnique<IPCServiceWorkerDescriptor>(aId, aPrincipalInfo,
                                                  nsCString(aScope), aState))
--- a/dom/serviceworkers/ServiceWorkerDescriptor.h
+++ b/dom/serviceworkers/ServiceWorkerDescriptor.h
@@ -1,16 +1,18 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #ifndef _mozilla_dom_ServiceWorkerDescriptor_h
 #define _mozilla_dom_ServiceWorkerDescriptor_h
 
+class nsIPrincipal;
+
 namespace mozilla {
 
 namespace ipc {
 class PrincipalInfo;
 } // namespace ipc
 
 namespace dom {
 
@@ -24,17 +26,20 @@ enum class ServiceWorkerState : uint8_t;
 class ServiceWorkerDescriptor final
 {
   // This class is largely a wrapper wround an IPDL generated struct.  We
   // need the wrapper class since IPDL generated code includes windows.h
   // which is in turn incompatible with bindings code.
   UniquePtr<IPCServiceWorkerDescriptor> mData;
 
 public:
-  ServiceWorkerDescriptor();
+  ServiceWorkerDescriptor(uint64_t aId,
+                          nsIPrincipal* aPrincipal,
+                          const nsACString& aScope,
+                          ServiceWorkerState aState);
 
   ServiceWorkerDescriptor(uint64_t aId,
                           const mozilla::ipc::PrincipalInfo& aPrincipalInfo,
                           const nsACString& aScope,
                           ServiceWorkerState aState);
 
   explicit ServiceWorkerDescriptor(const IPCServiceWorkerDescriptor& aDescriptor);
 
--- a/dom/serviceworkers/ServiceWorkerInfo.cpp
+++ b/dom/serviceworkers/ServiceWorkerInfo.cpp
@@ -216,16 +216,17 @@ ServiceWorkerInfo::UpdateState(ServiceWo
 }
 
 ServiceWorkerInfo::ServiceWorkerInfo(nsIPrincipal* aPrincipal,
                                      const nsACString& aScope,
                                      const nsACString& aScriptSpec,
                                      const nsAString& aCacheName,
                                      nsLoadFlags aImportsLoadFlags)
   : mPrincipal(aPrincipal)
+  , mDescriptor(GetNextID(), aPrincipal, aScope, ServiceWorkerState::Parsed)
   , mScriptSpec(aScriptSpec)
   , mCacheName(aCacheName)
   , mImportsLoadFlags(aImportsLoadFlags)
   , mCreationTime(PR_Now())
   , mCreationTimeStamp(TimeStamp::Now())
   , mInstalledTime(0)
   , mActivatedTime(0)
   , mRedundantTime(0)
@@ -238,22 +239,16 @@ ServiceWorkerInfo::ServiceWorkerInfo(nsI
   mOriginAttributes = mPrincipal->OriginAttributesRef();
   MOZ_ASSERT(!mScriptSpec.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
   // there is a service worker generating the script.
   MOZ_DIAGNOSTIC_ASSERT(mImportsLoadFlags & nsIChannel::LOAD_BYPASS_SERVICE_WORKER);
-
-  PrincipalInfo principalInfo;
-  MOZ_ALWAYS_SUCCEEDS(PrincipalToPrincipalInfo(aPrincipal, &principalInfo));
-
-  mDescriptor = ServiceWorkerDescriptor(GetNextID(), principalInfo, aScope,
-                                        ServiceWorkerState::Parsed);
 }
 
 ServiceWorkerInfo::~ServiceWorkerInfo()
 {
   MOZ_ASSERT(mServiceWorkerPrivate);
   mServiceWorkerPrivate->NoteDeadServiceWorkerInfo();
 }