bug 1249738 - make sScreenConfigurationObservers a function static r=dhylands
authorTrevor Saunders <tbsaunde@tbsaunde.org>
Fri, 19 Feb 2016 11:31:43 -0500
changeset 285727 4b7370854a0be419daf53e1be636aed4f28ce86f
parent 285726 5e27306cd8fb1e7eb0ea859691601b657ceb6727
child 285728 0f8651cfdccb0c6534853b4c8d12da79e5eca267
push id72500
push usertsaunders@mozilla.com
push dateFri, 26 Feb 2016 16:06:18 +0000
treeherdermozilla-inbound@a871b30278aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdhylands
bugs1249738
milestone47.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 1249738 - make sScreenConfigurationObservers a function static r=dhylands
hal/Hal.cpp
--- a/hal/Hal.cpp
+++ b/hal/Hal.cpp
@@ -349,17 +349,23 @@ protected:
     PROXY_IF_SANDBOXED(DisableScreenConfigurationNotifications());
   }
 
   void GetCurrentInformationInternal(ScreenConfiguration* aInfo) {
     PROXY_IF_SANDBOXED(GetCurrentScreenConfiguration(aInfo));
   }
 };
 
-static ScreenConfigurationObserversManager sScreenConfigurationObservers;
+static ScreenConfigurationObserversManager&
+ScreenConfigurationObservers()
+{
+  AssertMainThread();
+  static ScreenConfigurationObserversManager sScreenConfigurationObservers;
+  return sScreenConfigurationObservers;
+}
 
 void
 RegisterBatteryObserver(BatteryObserver* aObserver)
 {
   AssertMainThread();
   BatteryObservers().AddObserver(aObserver);
 }
 
@@ -697,38 +703,38 @@ NotifyWakeLockChange(const WakeLockInfor
   AssertMainThread();
   sWakeLockObservers.BroadcastInformation(aInfo);
 }
 
 void
 RegisterScreenConfigurationObserver(ScreenConfigurationObserver* aObserver)
 {
   AssertMainThread();
-  sScreenConfigurationObservers.AddObserver(aObserver);
+  ScreenConfigurationObservers().AddObserver(aObserver);
 }
 
 void
 UnregisterScreenConfigurationObserver(ScreenConfigurationObserver* aObserver)
 {
   AssertMainThread();
-  sScreenConfigurationObservers.RemoveObserver(aObserver);
+  ScreenConfigurationObservers().RemoveObserver(aObserver);
 }
 
 void
 GetCurrentScreenConfiguration(ScreenConfiguration* aScreenConfiguration)
 {
   AssertMainThread();
-  *aScreenConfiguration = sScreenConfigurationObservers.GetCurrentInformation();
+  *aScreenConfiguration = ScreenConfigurationObservers().GetCurrentInformation();
 }
 
 void
 NotifyScreenConfigurationChange(const ScreenConfiguration& aScreenConfiguration)
 {
-  sScreenConfigurationObservers.CacheInformation(aScreenConfiguration);
-  sScreenConfigurationObservers.BroadcastCachedInformation();
+  ScreenConfigurationObservers().CacheInformation(aScreenConfiguration);
+  ScreenConfigurationObservers().BroadcastCachedInformation();
 }
 
 bool
 LockScreenOrientation(const dom::ScreenOrientationInternal& aOrientation)
 {
   AssertMainThread();
   RETURN_PROXY_IF_SANDBOXED(LockScreenOrientation(aOrientation), false);
 }