Bug 1036877: add private dtor for Reference-counted RIL components. r=hsinyi
authorVicamo Yang <vyang@mozilla.com>
Fri, 11 Jul 2014 15:58:01 +0800
changeset 193442 d90e710df0c89f1edbb818bbde310b91a6ebc6c0
parent 193441 8e7237700f27a3031acccff89d1da88a31ee3b65
child 193443 4bfcc78bf111d39706a836b3aee573aa3f608b0c
push id27121
push userryanvm@gmail.com
push dateFri, 11 Jul 2014 19:59:41 +0000
treeherdermozilla-central@c11ea2f54a6a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsinyi
bugs1036877
milestone33.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 1036877: add private dtor for Reference-counted RIL components. r=hsinyi
dom/cellbroadcast/src/CellBroadcast.cpp
dom/icc/src/IccListener.h
dom/icc/src/IccManager.h
dom/mobileconnection/src/DOMMMIError.h
dom/mobileconnection/src/MobileCellInfo.h
dom/mobileconnection/src/MobileConnection.cpp
dom/mobileconnection/src/MobileConnection.h
dom/mobileconnection/src/MobileConnectionInfo.h
dom/mobileconnection/src/MobileNetworkInfo.h
dom/voicemail/Voicemail.cpp
--- a/dom/cellbroadcast/src/CellBroadcast.cpp
+++ b/dom/cellbroadcast/src/CellBroadcast.cpp
@@ -32,16 +32,22 @@ public:
     MOZ_ASSERT(mCellBroadcast);
   }
 
   void Disconnect()
   {
     MOZ_ASSERT(mCellBroadcast);
     mCellBroadcast = nullptr;
   }
+
+private:
+  ~Listener()
+  {
+    MOZ_ASSERT(!mCellBroadcast);
+  }
 };
 
 NS_IMPL_ISUPPORTS(CellBroadcast::Listener, nsICellBroadcastListener)
 
 /**
  * CellBroadcast Implementation.
  */
 
--- a/dom/icc/src/IccListener.h
+++ b/dom/icc/src/IccListener.h
@@ -16,28 +16,30 @@ class Icc;
 
 class IccListener MOZ_FINAL : public nsIIccListener
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIICCLISTENER
 
   IccListener(IccManager* aIccManager, uint32_t aClientId);
-  ~IccListener();
 
   void
   Shutdown();
 
   Icc*
   GetIcc()
   {
     return mIcc;
   }
 
 private:
+  ~IccListener();
+
+private:
   uint32_t mClientId;
   // We did not setup 'mIcc' and 'mIccManager' being a participant of cycle
   // collection is because in Navigator->Invalidate() it will call
   // mIccManager->Shutdown(), then IccManager will call Shutdown() of each
   // IccListener, this will release the reference and break the cycle.
   nsRefPtr<Icc> mIcc;
   nsRefPtr<IccManager> mIccManager;
   // mProvider is a xpcom service and will be released at shutdown, so it
--- a/dom/icc/src/IccManager.h
+++ b/dom/icc/src/IccManager.h
@@ -21,17 +21,16 @@ class IccManager MOZ_FINAL : public DOME
 public:
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IccManager, DOMEventTargetHelper)
 
   IccManager(nsPIDOMWindow* aWindow);
-  ~IccManager();
 
   void
   Shutdown();
 
   nsresult
   NotifyIccAdd(const nsAString& aIccId);
 
   nsresult
@@ -48,15 +47,18 @@ public:
 
   nsPIDOMWindow*
   GetParentObject() const { return GetOwner(); }
 
   virtual JSObject*
   WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
 private:
+  ~IccManager();
+
+private:
   nsTArray<nsRefPtr<IccListener>> mIccListeners;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_IccManager_h
--- a/dom/mobileconnection/src/DOMMMIError.h
+++ b/dom/mobileconnection/src/DOMMMIError.h
@@ -39,16 +39,19 @@ public:
 
   Nullable<int16_t>
   GetAdditionalInformation() const
   {
     return mInfo;
   }
 
 private:
+  ~DOMMMIError() {}
+
+private:
   nsString mServiceCode;
   Nullable<int16_t> mInfo;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_MmiError_h
--- a/dom/mobileconnection/src/MobileCellInfo.h
+++ b/dom/mobileconnection/src/MobileCellInfo.h
@@ -74,16 +74,19 @@ public:
 
   int32_t
   CdmaNetworkId() const
   {
     return mCdmaNetworkId;
   }
 
 private:
+  ~MobileCellInfo() {}
+
+private:
   nsCOMPtr<nsPIDOMWindow> mWindow;
   int32_t mGsmLocationAreaCode;
   int64_t mGsmCellId;
   int32_t mCdmaBaseStationId;
   int32_t mCdmaBaseStationLatitude;
   int32_t mCdmaBaseStationLongitude;
   int32_t mCdmaSystemId;
   int32_t mCdmaNetworkId;
--- a/dom/mobileconnection/src/MobileConnection.cpp
+++ b/dom/mobileconnection/src/MobileConnection.cpp
@@ -57,16 +57,22 @@ public:
     MOZ_ASSERT(mMobileConnection);
   }
 
   void Disconnect()
   {
     MOZ_ASSERT(mMobileConnection);
     mMobileConnection = nullptr;
   }
+
+private:
+  ~Listener()
+  {
+    MOZ_ASSERT(!mMobileConnection);
+  }
 };
 
 NS_IMPL_ISUPPORTS(MobileConnection::Listener, nsIMobileConnectionListener)
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(MobileConnection)
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(MobileConnection,
                                                   DOMEventTargetHelper)
@@ -125,16 +131,21 @@ MobileConnection::Shutdown()
     mProvider->UnregisterMobileConnectionMsg(mClientId, mListener);
     mProvider = nullptr;
     mListener = nullptr;
     mVoice = nullptr;
     mData = nullptr;
   }
 }
 
+MobileConnection::~MobileConnection()
+{
+  MOZ_ASSERT(!(mProvider || mListener || mVoice || mData));
+}
+
 JSObject*
 MobileConnection::WrapObject(JSContext* aCx)
 {
   return MozMobileConnectionBinding::Wrap(aCx, this);
 }
 
 bool
 MobileConnection::CheckPermission(const char* aType) const
--- a/dom/mobileconnection/src/MobileConnection.h
+++ b/dom/mobileconnection/src/MobileConnection.h
@@ -151,16 +151,19 @@ public:
   IMPL_EVENT_HANDLER(cfstatechange)
   IMPL_EVENT_HANDLER(emergencycbmodechange)
   IMPL_EVENT_HANDLER(otastatuschange)
   IMPL_EVENT_HANDLER(iccchange)
   IMPL_EVENT_HANDLER(radiostatechange)
   IMPL_EVENT_HANDLER(clirmodechange)
 
 private:
+  ~MobileConnection();
+
+private:
   uint32_t mClientId;
   nsCOMPtr<nsIMobileConnectionProvider> mProvider;
   nsRefPtr<Listener> mListener;
   nsRefPtr<MobileConnectionInfo> mVoice;
   nsRefPtr<MobileConnectionInfo> mData;
 
   bool
   CheckPermission(const char* aType) const;
--- a/dom/mobileconnection/src/MobileConnectionInfo.h
+++ b/dom/mobileconnection/src/MobileConnectionInfo.h
@@ -89,16 +89,19 @@ public:
 
   MobileCellInfo*
   GetCell() const
   {
     return mCellInfo;
   }
 
 private:
+  ~MobileConnectionInfo() {}
+
+private:
   bool mConnected;
   bool mEmergencyCallsOnly;
   bool mRoaming;
   nsCOMPtr<nsPIDOMWindow> mWindow;
   nsRefPtr<MobileNetworkInfo> mNetworkInfo;
   nsRefPtr<MobileCellInfo> mCellInfo;
   Nullable<MobileConnectionState> mState;
   Nullable<MobileConnectionType> mType;
--- a/dom/mobileconnection/src/MobileNetworkInfo.h
+++ b/dom/mobileconnection/src/MobileNetworkInfo.h
@@ -57,16 +57,19 @@ public:
         return Nullable<MobileNetworkState>(static_cast<MobileNetworkState>(i));
       }
     }
 
     return Nullable<MobileNetworkState>();
   }
 
 private:
+  ~MobileNetworkInfo() {}
+
+private:
   nsCOMPtr<nsPIDOMWindow> mWindow;
   nsString mShortName;
   nsString mLongName;
   nsString mMcc;
   nsString mMnc;
   nsString mState;
 };
 
--- a/dom/voicemail/Voicemail.cpp
+++ b/dom/voicemail/Voicemail.cpp
@@ -34,16 +34,22 @@ public:
     MOZ_ASSERT(mVoicemail);
   }
 
   void Disconnect()
   {
     MOZ_ASSERT(mVoicemail);
     mVoicemail = nullptr;
   }
+
+private:
+  ~Listener()
+  {
+    MOZ_ASSERT(!mVoicemail);
+  }
 };
 
 NS_IMPL_ISUPPORTS(Voicemail::Listener, nsIVoicemailListener)
 
 Voicemail::Voicemail(nsPIDOMWindow* aWindow,
                      nsIVoicemailProvider* aProvider)
   : DOMEventTargetHelper(aWindow)
   , mProvider(aProvider)