Bug 1594181 - Reset external variable properly on destruction. r=mccr8
authorAlex Chronopoulos <achronop@gmail.com>
Mon, 18 Nov 2019 10:42:40 +0000
changeset 502398 a67caf145931c59a6471afd2dc0f7bb68f2fe6f4
parent 502397 e127df386eaf5caf0db224afac2052d906f2b8d8
child 502399 68c4c2622a23a76ad4ee3fe130b82c0d9d39ab19
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1594181
milestone72.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 1594181 - Reset external variable properly on destruction. r=mccr8 Differential Revision: https://phabricator.services.mozilla.com/D52639
dom/media/mediacapabilities/BenchmarkStorageChild.cpp
dom/media/mediacapabilities/BenchmarkStorageChild.h
--- a/dom/media/mediacapabilities/BenchmarkStorageChild.cpp
+++ b/dom/media/mediacapabilities/BenchmarkStorageChild.cpp
@@ -19,9 +19,16 @@ PBenchmarkStorageChild* BenchmarkStorage
     PContentChild* contentChild = dom::ContentChild::GetSingleton();
     MOZ_ASSERT(contentChild);
     contentChild->SendPBenchmarkStorageConstructor();
   }
   MOZ_ASSERT(sChild);
   return sChild;
 }
 
+BenchmarkStorageChild::~BenchmarkStorageChild() {
+  MOZ_ASSERT(NS_IsMainThread());
+  if (sChild == this) {
+    sChild = nullptr;
+  }
+}
+
 }  // namespace mozilla
--- a/dom/media/mediacapabilities/BenchmarkStorageChild.h
+++ b/dom/media/mediacapabilities/BenchmarkStorageChild.h
@@ -12,15 +12,16 @@
 namespace mozilla {
 
 class BenchmarkStorageChild : public PBenchmarkStorageChild {
  public:
   /* Singleton class to avoid recreating the protocol every time we need access
    * to the storage. */
   static PBenchmarkStorageChild* Instance();
 
+  ~BenchmarkStorageChild();
  private:
   BenchmarkStorageChild() = default;
 };
 
 }  // namespace mozilla
 
 #endif  // include_dom_media_mediacapabilities_BenchmarkStorageChild_h