Bug 772987 - Part 2: Use Static{Auto,Ref}Ptr where appropriate. r=mounir
authorJustin Lebar <justin.lebar@gmail.com>
Thu, 26 Jul 2012 15:33:45 -0400
changeset 100629 d5bc3b7322298e4695a309e68f5e75c3d2aace80
parent 100628 b9a1f5cae6ea23dc00c97401caffc9343ab2d65a
child 100630 7517b13c4d5770d982d7e4e998702303bd661a5e
push id12576
push userjlebar@mozilla.com
push dateThu, 26 Jul 2012 19:34:39 +0000
treeherdermozilla-inbound@7517b13c4d57 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmounir
bugs772987
milestone17.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 772987 - Part 2: Use Static{Auto,Ref}Ptr where appropriate. r=mounir
caps/src/nsScriptSecurityManager.cpp
dom/alarm/AlarmHalService.cpp
dom/alarm/AlarmHalService.h
dom/base/Navigator.cpp
dom/power/PowerManagerService.cpp
dom/power/PowerManagerService.h
hal/Hal.cpp
image/src/RasterImage.cpp
image/src/RasterImage.h
widget/gonk/OrientationObserver.cpp
--- a/caps/src/nsScriptSecurityManager.cpp
+++ b/caps/src/nsScriptSecurityManager.cpp
@@ -55,16 +55,17 @@
 #include "nsCDefaultURIFixup.h"
 #include "nsIChromeRegistry.h"
 #include "nsIContentSecurityPolicy.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/StandardInteger.h"
 #include "mozilla/ClearOnShutdown.h"
+#include "mozilla/StaticPtr.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 static NS_DEFINE_CID(kZipReaderCID, NS_ZIPREADER_CID);
 
 nsIIOService    *nsScriptSecurityManager::sIOService = nsnull;
 nsIXPConnect    *nsScriptSecurityManager::sXPConnect = nsnull;
@@ -3052,17 +3053,17 @@ nsresult nsScriptSecurityManager::Init()
     JS_SetSecurityCallbacks(sRuntime, &securityCallbacks);
     JS_InitDestroyPrincipalsCallback(sRuntime, nsJSPrincipals::Destroy);
 
     JS_SetTrustedPrincipals(sRuntime, system);
 
     return NS_OK;
 }
 
-static nsRefPtr<nsScriptSecurityManager> gScriptSecMan;
+static StaticRefPtr<nsScriptSecurityManager> gScriptSecMan;
 
 jsid nsScriptSecurityManager::sEnabledID   = JSID_VOID;
 
 nsScriptSecurityManager::~nsScriptSecurityManager(void)
 {
     Preferences::RemoveObservers(this, kObservedPrefs);
     delete mOriginToPolicyMap;
     if(mDefaultPolicy)
--- a/dom/alarm/AlarmHalService.cpp
+++ b/dom/alarm/AlarmHalService.cpp
@@ -20,17 +20,17 @@ AlarmHalService::Init()
 
 /* virtual */ AlarmHalService::~AlarmHalService() 
 {
   if (mAlarmEnabled) {
     UnregisterTheOneAlarmObserver();
   }
 }
 
-/* static */ nsRefPtr<AlarmHalService> AlarmHalService::sSingleton;
+/* static */ StaticRefPtr<AlarmHalService> AlarmHalService::sSingleton;
 
 /* static */ already_AddRefed<nsIAlarmHalService>
 AlarmHalService::GetInstance()
 {
   if (!sSingleton) {
     sSingleton = new AlarmHalService();
     sSingleton->Init(); 
     ClearOnShutdown(&sSingleton);
--- a/dom/alarm/AlarmHalService.h
+++ b/dom/alarm/AlarmHalService.h
@@ -2,16 +2,17 @@
  * 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_alarm_AlarmHalService_h
 #define mozilla_dom_alarm_AlarmHalService_h
 
 #include "base/basictypes.h"
 #include "mozilla/ClearOnShutdown.h"
+#include "mozilla/StaticPtr.h"
 #include "mozilla/Hal.h"
 #include "mozilla/Services.h"
 #include "nsIAlarmHalService.h"
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 #include "prtime.h"
 
 namespace mozilla {
@@ -23,25 +24,25 @@ class AlarmHalService : public nsIAlarmH
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIALARMHALSERVICE
 
   void Init();
   virtual ~AlarmHalService();
 
-  static nsRefPtr<AlarmHalService> sSingleton;
   static already_AddRefed<nsIAlarmHalService> GetInstance();
 
   // Implementing hal::AlarmObserver
   void Notify(const mozilla::void_t& aVoid);
 
 private:
   bool mAlarmEnabled;
   nsCOMPtr<nsIAlarmFiredCb> mAlarmFiredCb;
+  static StaticRefPtr<AlarmHalService> sSingleton;
 
   // TODO The mTimezoneChangedCb would be called 
   // when a timezone-changed event is detected 
   // at run-time. To do so, we can register a 
   // timezone-changed observer, see bug 714358.
   // We need to adjust the alarm time respect to
   // the correct timezone where user is located.
   nsCOMPtr<nsITimezoneChangedCb> mTimezoneChangedCb;
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -30,16 +30,17 @@
 #include "PowerManager.h"
 #include "nsIDOMWakeLock.h"
 #include "nsIPowerManagerService.h"
 #include "SmsManager.h"
 #include "nsISmsService.h"
 #include "mozilla/Hal.h"
 #include "nsIWebNavigation.h"
 #include "mozilla/ClearOnShutdown.h"
+#include "mozilla/StaticPtr.h"
 #include "Connection.h"
 #include "MobileConnection.h"
 #include "nsIIdleObserver.h"
 
 #ifdef MOZ_MEDIA_NAVIGATOR
 #include "MediaManager.h"
 #endif
 #ifdef MOZ_B2G_RIL
@@ -603,17 +604,17 @@ public:
 
 private:
   nsWeakPtr mWindow;
   nsWeakPtr mDocument;
 };
 
 NS_IMPL_ISUPPORTS1(VibrateWindowListener, nsIDOMEventListener)
 
-nsRefPtr<VibrateWindowListener> gVibrateWindowListener;
+StaticRefPtr<VibrateWindowListener> gVibrateWindowListener;
 
 NS_IMETHODIMP
 VibrateWindowListener::HandleEvent(nsIDOMEvent* aEvent)
 {
   nsCOMPtr<nsIDOMEventTarget> target;
   aEvent->GetTarget(getter_AddRefs(target));
   nsCOMPtr<nsIDOMDocument> doc = do_QueryInterface(target);
 
--- a/dom/power/PowerManagerService.cpp
+++ b/dom/power/PowerManagerService.cpp
@@ -12,17 +12,17 @@
 #include "WakeLock.h"
 
 namespace mozilla {
 namespace dom {
 namespace power {
 
 NS_IMPL_ISUPPORTS1(PowerManagerService, nsIPowerManagerService)
 
-/* static */ nsRefPtr<PowerManagerService> PowerManagerService::sSingleton;
+/* static */ StaticRefPtr<PowerManagerService> PowerManagerService::sSingleton;
 
 /* static */ already_AddRefed<nsIPowerManagerService>
 PowerManagerService::GetInstance()
 {
   if (!sSingleton) {
     sSingleton = new PowerManagerService();
     sSingleton->Init();
     ClearOnShutdown(&sSingleton);
--- a/dom/power/PowerManagerService.h
+++ b/dom/power/PowerManagerService.h
@@ -7,16 +7,17 @@
 
 #include "nsCOMPtr.h"
 #include "nsDataHashtable.h"
 #include "nsHashKeys.h"
 #include "nsTArray.h"
 #include "nsIPowerManagerService.h"
 #include "mozilla/Observer.h"
 #include "Types.h"
+#include "mozilla/StaticPtr.h"
 
 namespace mozilla {
 namespace dom {
 namespace power {
 
 class PowerManagerService
   : public nsIPowerManagerService
   , public WakeLockObserver
@@ -34,17 +35,17 @@ public:
 
 private:
 
   ~PowerManagerService();
 
   void ComputeWakeLockState(const hal::WakeLockInformation& aWakeLockInfo,
                             nsAString &aState);
 
-  static nsRefPtr<PowerManagerService> sSingleton;
+  static StaticRefPtr<PowerManagerService> sSingleton;
 
   nsTArray<nsCOMPtr<nsIDOMMozWakeLockListener> > mWakeLockListeners;
 };
 
 } // namespace power
 } // namespace dom
 } // namespace mozilla
 
--- a/hal/Hal.cpp
+++ b/hal/Hal.cpp
@@ -12,16 +12,17 @@
 #include "nsXULAppAPI.h"
 #include "mozilla/Observer.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMWindow.h"
 #include "mozilla/Services.h"
 #include "nsIWebNavigation.h"
 #include "nsITabChild.h"
 #include "nsIDocShell.h"
+#include "mozilla/StaticPtr.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "WindowIdentifier.h"
 #include "mozilla/dom/ScreenOrientation.h"
 
 using namespace mozilla::services;
 
 #define PROXY_IF_SANDBOXED(_call)                 \
   do {                                            \
@@ -69,17 +70,17 @@ WindowIsActive(nsIDOMWindow *window)
   window->GetDocument(getter_AddRefs(doc));
   NS_ENSURE_TRUE(doc, false);
 
   bool hidden = true;
   doc->GetMozHidden(&hidden);
   return !hidden;
 }
 
-nsAutoPtr<WindowIdentifier::IDArrayType> gLastIDToVibrate;
+StaticAutoPtr<WindowIdentifier::IDArrayType> gLastIDToVibrate;
 
 void InitLastIDToVibrate()
 {
   gLastIDToVibrate = new WindowIdentifier::IDArrayType();
   ClearOnShutdown(&gLastIDToVibrate);
 }
 
 } // anonymous namespace
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -133,17 +133,17 @@ DiscardingEnabled()
   }
 
   return enabled;
 }
 
 namespace mozilla {
 namespace image {
 
-/* static */ nsRefPtr<RasterImage::DecodeWorker> RasterImage::DecodeWorker::sSingleton;
+/* static */ StaticRefPtr<RasterImage::DecodeWorker> RasterImage::DecodeWorker::sSingleton;
 
 #ifndef DEBUG
 NS_IMPL_ISUPPORTS3(RasterImage, imgIContainer, nsIProperties,
                    nsISupportsWeakReference)
 #else
 NS_IMPL_ISUPPORTS4(RasterImage, imgIContainer, nsIProperties,
                    imgIContainerDebug, nsISupportsWeakReference)
 #endif
--- a/image/src/RasterImage.h
+++ b/image/src/RasterImage.h
@@ -26,16 +26,17 @@
 #include "nsWeakReference.h"
 #include "nsTArray.h"
 #include "imgFrame.h"
 #include "nsThreadUtils.h"
 #include "DiscardTracker.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/LinkedList.h"
+#include "mozilla/StaticPtr.h"
 #ifdef DEBUG
   #include "imgIContainerDebug.h"
 #endif
 
 class imgIDecoder;
 class imgIContainerObserver;
 class nsIInputStream;
 
@@ -420,17 +421,17 @@ private:
      * @return NS_ERROR if an error is encountered, and NS_OK otherwise.  (Note
      *         that we return NS_OK even when the size was not found.)
      */
     nsresult DecodeUntilSizeAvailable(RasterImage* aImg);
 
     NS_IMETHOD Run();
 
   private: /* statics */
-    static nsRefPtr<DecodeWorker> sSingleton;
+    static StaticRefPtr<DecodeWorker> sSingleton;
 
   private: /* methods */
     DecodeWorker()
       : mPendingInEventLoop(false)
     {}
 
     /* Post ourselves to the event loop if we're not currently pending. */
     void EnsurePendingInEventLoop();
--- a/widget/gonk/OrientationObserver.cpp
+++ b/widget/gonk/OrientationObserver.cpp
@@ -12,16 +12,17 @@
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 #include "base/basictypes.h"
 #include "mozilla/ClearOnShutdown.h"
+#include "mozilla/StaticPtr.h"
 #include "mozilla/Hal.h"
 #include "nsIScreen.h"
 #include "nsIScreenManager.h"
 #include "OrientationObserver.h"
 #include "mozilla/HalSensor.h"
 
 using namespace mozilla;
 using namespace dom;
@@ -145,17 +146,17 @@ ConvertToDomOrientation(PRUint32 aRotati
   }
 
   *aResult = eScreenOrientation_None;
   return NS_ERROR_ILLEGAL_VALUE;
 }
 
 // Note that all operations with sOrientationSensorObserver
 // should be on the main thread.
-static nsAutoPtr<OrientationObserver> sOrientationSensorObserver;
+static StaticAutoPtr<OrientationObserver> sOrientationSensorObserver;
 
 } // Anonymous namespace
 
 OrientationObserver*
 OrientationObserver::GetInstance()
 {
   if (!sOrientationSensorObserver) {
     sOrientationSensorObserver = new OrientationObserver();