bug 1249738 - make sNetworkObservers a function static r=dhylands
authorTrevor Saunders <tbsaunde@tbsaunde.org>
Fri, 19 Feb 2016 11:28:00 -0500
changeset 322161 5e27306cd8fb1e7eb0ea859691601b657ceb6727
parent 322160 73c742908f3fa81180be5df7d8b051260af5c5d2
child 322162 4b7370854a0be419daf53e1be636aed4f28ce86f
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [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 sNetworkObservers a function static r=dhylands
hal/Hal.cpp
--- a/hal/Hal.cpp
+++ b/hal/Hal.cpp
@@ -311,17 +311,23 @@ protected:
     PROXY_IF_SANDBOXED(DisableNetworkNotifications());
   }
 
   void GetCurrentInformationInternal(NetworkInformation* aInfo) {
     PROXY_IF_SANDBOXED(GetCurrentNetworkInformation(aInfo));
   }
 };
 
-static NetworkObserversManager sNetworkObservers;
+static NetworkObserversManager&
+NetworkObservers()
+{
+  static NetworkObserversManager sNetworkObservers;
+  AssertMainThread();
+  return sNetworkObservers;
+}
 
 class WakeLockObserversManager : public ObserversManager<WakeLockInformation>
 {
 protected:
   void EnableNotifications() {
     PROXY_IF_SANDBOXED(EnableWakeLockNotifications());
   }
 
@@ -597,38 +603,38 @@ NotifySensorChange(const SensorData &aSe
 
   observers.Broadcast(aSensorData);
 }
 
 void
 RegisterNetworkObserver(NetworkObserver* aObserver)
 {
   AssertMainThread();
-  sNetworkObservers.AddObserver(aObserver);
+  NetworkObservers().AddObserver(aObserver);
 }
 
 void
 UnregisterNetworkObserver(NetworkObserver* aObserver)
 {
   AssertMainThread();
-  sNetworkObservers.RemoveObserver(aObserver);
+  NetworkObservers().RemoveObserver(aObserver);
 }
 
 void
 GetCurrentNetworkInformation(NetworkInformation* aInfo)
 {
   AssertMainThread();
-  *aInfo = sNetworkObservers.GetCurrentInformation();
+  *aInfo = NetworkObservers().GetCurrentInformation();
 }
 
 void
 NotifyNetworkChange(const NetworkInformation& aInfo)
 {
-  sNetworkObservers.CacheInformation(aInfo);
-  sNetworkObservers.BroadcastCachedInformation();
+  NetworkObservers().CacheInformation(aInfo);
+  NetworkObservers().BroadcastCachedInformation();
 }
 
 void Reboot()
 {
   AssertMainProcess();
   AssertMainThread();
   PROXY_IF_SANDBOXED(Reboot());
 }