Bug 1492014 document WorkletLoadInfo thread safety and relax destructor thread assertion r=baku
authorKarl Tomlinson <karlt+@karlt.net>
Tue, 18 Sep 2018 09:34:11 +0000
changeset 494588 19c7245a11e00acf6fba35314a1c63c59a42785e
parent 494587 8bfd0578ebaf1372d5470b95ba36e1facb4ec014
child 494589 7576b6eca5d15aba8a8fab074a60c21a4180f491
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1492014
milestone64.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 1492014 document WorkletLoadInfo thread safety and relax destructor thread assertion r=baku Depends on D6101 Differential Revision: https://phabricator.services.mozilla.com/D6102
dom/worklet/WorkletImpl.cpp
dom/worklet/WorkletImpl.h
--- a/dom/worklet/WorkletImpl.cpp
+++ b/dom/worklet/WorkletImpl.cpp
@@ -34,17 +34,17 @@ WorkletLoadInfo::WorkletLoadInfo(nsPIDOM
     mOuterWindowID = outerWindow->WindowID();
   } else {
     mOuterWindowID = 0;
   }
 }
 
 WorkletLoadInfo::~WorkletLoadInfo()
 {
-  MOZ_ASSERT(NS_IsMainThread());
+  MOZ_ASSERT(!mPrincipal || NS_IsMainThread());
 }
 
 // ---------------------------------------------------------------------------
 // WorkletImpl
 
 /* static */ already_AddRefed<dom::Worklet>
 WorkletImpl::CreateWorklet(nsPIDOMWindowInner* aWindow,
                            nsIPrincipal* aPrincipal,
--- a/dom/worklet/WorkletImpl.h
+++ b/dom/worklet/WorkletImpl.h
@@ -40,20 +40,22 @@ public:
 
   nsIPrincipal* Principal() const
   {
     MOZ_ASSERT(NS_IsMainThread());
     return mPrincipal;
   }
 
 private:
+  // Modified only in constructor.
   uint64_t mOuterWindowID;
-  uint64_t mInnerWindowID;
-  bool mDumpEnabled;
-  OriginAttributes mOriginAttributes;
+  const uint64_t mInnerWindowID;
+  const bool mDumpEnabled;
+  const OriginAttributes mOriginAttributes;
+  // Accessed on only worklet parent thread.
   nsCOMPtr<nsIPrincipal> mPrincipal;
 
   friend class WorkletImpl;
   friend class WorkletThread;
 };
 
 /**
  * WorkletImpl is accessed from both the worklet's parent thread (on which the
@@ -90,16 +92,18 @@ public:
   // Any thread.
   const WorkletLoadInfo& LoadInfo() const { return mWorkletLoadInfo; }
 
 private:
   WorkletImpl(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal,
               WorkletType aWorkletType);
   ~WorkletImpl();
 
+  // The only WorkletLoadInfo member modified is mPrincipal which is accessed
+  // on only the parent thread.
   WorkletLoadInfo mWorkletLoadInfo;
   const WorkletType mWorkletType;
 
   // Parent thread only.
   RefPtr<dom::WorkletThread> mWorkletThread;
 };
 
 } // namespace mozilla