Bug 514280 Only use nsCOMPtr for interfaces r=bsmedberg
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Thu, 08 May 2014 20:08:38 +0100
changeset 182242 c738f7348dea0969d2f42e6ee494dbf58406af51
parent 182241 fa947e53a79013b942741c4c3c6bca8dcdead9ba
child 182243 cb0603410233da7435d9018c371558d30e7936c2
push id26752
push userkwierso@gmail.com
push dateFri, 09 May 2014 01:28:32 +0000
treeherdermozilla-central@92f071838af7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs514280
milestone32.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 514280 Only use nsCOMPtr for interfaces r=bsmedberg
content/base/src/nsDocument.cpp
dom/ipc/ContentParent.cpp
dom/media/MediaManager.cpp
layout/xul/nsXULPopupManager.cpp
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
netwerk/base/src/nsAsyncStreamCopier.cpp
netwerk/protocol/about/nsAboutCache.cpp
netwerk/test/TestUDPSocket.cpp
uriloader/exthandler/android/nsAndroidHandlerApp.cpp
uriloader/exthandler/android/nsMIMEInfoAndroid.cpp
xpcom/glue/nsID.h
xpcom/glue/nsISupportsImpl.h
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -310,16 +310,23 @@ nsIdentifierMapEntry::RemoveContentChang
 
 struct FireChangeArgs {
   Element* mFrom;
   Element* mTo;
   bool mImageOnly;
   bool mHaveImageOverride;
 };
 
+// XXX Workaround for bug 980560 to maintain the existing broken semantics
+template<>
+struct nsIStyleRule::COMTypeInfo<css::Rule, void> {
+  static const nsIID kIID NS_HIDDEN;
+};
+const nsIID nsIStyleRule::COMTypeInfo<css::Rule, void>::kIID = NS_ISTYLE_RULE_IID;
+
 namespace mozilla {
 namespace dom {
 
 static PLDHashOperator
 CustomDefinitionsTraverse(CustomElementHashKey* aKey,
                           CustomElementDefinition* aDefinition,
                           void* aArg)
 {
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -293,16 +293,23 @@ MaybeTestPBackground()
 
     nsCOMPtr<nsIObserver> observer = new BackgroundTester();
     nsresult rv = observerService->AddObserver(observer, "profile-after-change",
                                                false);
     MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
 #endif
 }
 
+// XXX Workaround for bug 986973 to maintain the existing broken semantics
+template<>
+struct nsIConsoleService::COMTypeInfo<nsConsoleService, void> {
+  static const nsIID kIID NS_HIDDEN;
+};
+const nsIID nsIConsoleService::COMTypeInfo<nsConsoleService, void>::kIID = NS_ICONSOLESERVICE_IID;
+
 namespace mozilla {
 namespace dom {
 
 #define NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC "ipc:network:set-offline"
 
 class MemoryReportRequestParent : public PMemoryReportRequestParent
 {
 public:
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -54,16 +54,28 @@
 #endif
 
 // GetCurrentTime is defined in winbase.h as zero argument macro forwarding to
 // GetTickCount() and conflicts with MediaStream::GetCurrentTime.
 #ifdef GetCurrentTime
 #undef GetCurrentTime
 #endif
 
+// XXX Workaround for bug 986974 to maintain the existing broken semantics
+template<>
+struct nsIMediaDevice::COMTypeInfo<mozilla::VideoDevice, void> {
+  static const nsIID kIID NS_HIDDEN;
+};
+const nsIID nsIMediaDevice::COMTypeInfo<mozilla::VideoDevice, void>::kIID = NS_IMEDIADEVICE_IID;
+template<>
+struct nsIMediaDevice::COMTypeInfo<mozilla::AudioDevice, void> {
+  static const nsIID kIID NS_HIDDEN;
+};
+const nsIID nsIMediaDevice::COMTypeInfo<mozilla::AudioDevice, void>::kIID = NS_IMEDIADEVICE_IID;
+
 namespace mozilla {
 
 #ifdef LOG
 #undef LOG
 #endif
 
 #ifdef PR_LOGGING
 PRLogModuleInfo*
--- a/layout/xul/nsXULPopupManager.cpp
+++ b/layout/xul/nsXULPopupManager.cpp
@@ -1389,17 +1389,17 @@ nsXULPopupManager::FirePopupHidingEvent(
         nsAutoString animate;
         aPopup->GetAttr(kNameSpaceID_None, nsGkAtoms::animate, animate);
 
         // If animate="false" then don't transition at all. If animate="cancel",
         // only show the transition if cancelling the popup or rolling up.
         // Otherwise, always show the transition.
         if (!animate.EqualsLiteral("false") &&
             (!animate.EqualsLiteral("cancel") || aIsRollup)) {
-          nsCOMPtr<TransitionEnder> ender = new TransitionEnder(aPopup, aDeselectMenu);
+          nsRefPtr<TransitionEnder> ender = new TransitionEnder(aPopup, aDeselectMenu);
           aPopup->AddSystemEventListener(NS_LITERAL_STRING("transitionend"),
                                          ender, false, false);
           return;
         }
       }
 #endif
 
       HidePopupCallback(aPopup, popupFrame, aNextPopup, aLastPopup,
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -142,16 +142,22 @@ static const int MEDIA_STREAM_MUTE = 0x8
 PRLogModuleInfo *signalingLogInfo() {
   static PRLogModuleInfo *logModuleInfo = nullptr;
   if (!logModuleInfo) {
     logModuleInfo = PR_NewLogModule("signaling");
   }
   return logModuleInfo;
 }
 
+// XXX Workaround for bug 998092 to maintain the existing broken semantics
+template<>
+struct nsISupportsWeakReference::COMTypeInfo<nsSupportsWeakReference, void> {
+  static const nsIID kIID NS_HIDDEN;
+};
+const nsIID nsISupportsWeakReference::COMTypeInfo<nsSupportsWeakReference, void>::kIID = NS_ISUPPORTSWEAKREFERENCE_IID;
 
 namespace sipcc {
 
 #ifdef MOZILLA_INTERNAL_API
 RTCStatsQuery::RTCStatsQuery(bool internal) : internalStats(internal) {
 }
 
 RTCStatsQuery::~RTCStatsQuery() {
--- a/netwerk/base/src/nsAsyncStreamCopier.cpp
+++ b/netwerk/base/src/nsAsyncStreamCopier.cpp
@@ -372,18 +372,17 @@ nsAsyncStreamCopier::AsyncCopy(nsIReques
     if (!mShouldSniffBuffering) {
         // No buffer sniffing required, let's proceed
         AsyncCopyInternal();
         return NS_OK;
     }
 
     if (NS_IsMainThread()) {
         // Don't perform buffer sniffing on the main thread
-        nsCOMPtr<AsyncApplyBufferingPolicyEvent> event
-            = new AsyncApplyBufferingPolicyEvent(this);
+        nsCOMPtr<nsIRunnable> event = new AsyncApplyBufferingPolicyEvent(this);
         rv = mTarget->Dispatch(event, NS_DISPATCH_NORMAL);
         if (NS_FAILED(rv)) {
           Cancel(rv);
         }
         return NS_OK;
     }
 
     // We're not going to block the main thread, so let's sniff here
--- a/netwerk/protocol/about/nsAboutCache.cpp
+++ b/netwerk/protocol/about/nsAboutCache.cpp
@@ -166,17 +166,17 @@ nsAboutCache::VisitNextStorage()
 
     mStorageName = mStorageList[0];
     mStorageList.RemoveElementAt(0);
 
     // Must re-dispatch since we cannot start another visit cycle
     // from visitor callback.  The cache v1 service doesn't like it.
     // TODO - mayhemer, bug 913828, remove this dispatch and call
     // directly.
-    nsCOMPtr<nsRunnableMethod<nsAboutCache> > event =
+    nsCOMPtr<nsIRunnable> event =
         NS_NewRunnableMethod(this, &nsAboutCache::FireVisitStorage);
     return NS_DispatchToMainThread(event);
 }
 
 void
 nsAboutCache::FireVisitStorage()
 {
     nsresult rv;
--- a/netwerk/test/TestUDPSocket.cpp
+++ b/netwerk/test/TestUDPSocket.cpp
@@ -317,17 +317,17 @@ main(int32_t argc, char *argv[])
   // Read response from server
   NS_ENSURE_SUCCESS(clientListener->mResult, -1);
 
   // Setup timer to detect multicast failure
   nsCOMPtr<nsITimer> timer = do_CreateInstance("@mozilla.org/timer;1");
   if (NS_WARN_IF(!timer)) {
     return -1;
   }
-  nsCOMPtr<MulticastTimerCallback> timerCb = new MulticastTimerCallback();
+  nsRefPtr<MulticastTimerCallback> timerCb = new MulticastTimerCallback();
 
   // The following multicast tests using multiple sockets require a firewall
   // exception on Windows XP before they pass.  For now, we'll skip them here.
   // Later versions of Windows don't seem to have this issue.
 #ifdef XP_WIN
   OSVERSIONINFO OsVersion;
   OsVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
 #pragma warning(push)
--- a/uriloader/exthandler/android/nsAndroidHandlerApp.cpp
+++ b/uriloader/exthandler/android/nsAndroidHandlerApp.cpp
@@ -50,16 +50,23 @@ nsAndroidHandlerApp::GetDetailedDescript
 NS_IMETHODIMP
 nsAndroidHandlerApp::SetDetailedDescription(const nsAString & aDescription)
 {
   mDescription.Assign(aDescription);
 
   return NS_OK;
 }
 
+// XXX Workaround for bug 986975 to maintain the existing broken semantics
+template<>
+struct nsISharingHandlerApp::COMTypeInfo<nsAndroidHandlerApp, void> {
+  static const nsIID kIID NS_HIDDEN;
+};
+const nsIID nsISharingHandlerApp::COMTypeInfo<nsAndroidHandlerApp, void>::kIID = NS_IHANDLERAPP_IID;
+
 NS_IMETHODIMP
 nsAndroidHandlerApp::Equals(nsIHandlerApp *aHandlerApp, bool *aRetval)
 {
   nsCOMPtr<nsAndroidHandlerApp> aApp = do_QueryInterface(aHandlerApp);
   *aRetval = aApp && aApp->mName.Equals(mName) &&
     aApp->mDescription.Equals(mDescription);
   return NS_OK;
 }
--- a/uriloader/exthandler/android/nsMIMEInfoAndroid.cpp
+++ b/uriloader/exthandler/android/nsMIMEInfoAndroid.cpp
@@ -397,16 +397,23 @@ nsMIMEInfoAndroid::SystemChooser::GetDet
   return NS_OK;
 }
 
 nsresult
 nsMIMEInfoAndroid::SystemChooser::SetDetailedDescription(const nsAString&) {
   return NS_OK;
 }
 
+// XXX Workaround for bug 986975 to maintain the existing broken semantics
+template<>
+struct nsIHandlerApp::COMTypeInfo<nsMIMEInfoAndroid::SystemChooser, void> {
+  static const nsIID kIID NS_HIDDEN;
+};
+const nsIID nsIHandlerApp::COMTypeInfo<nsMIMEInfoAndroid::SystemChooser, void>::kIID = NS_IHANDLERAPP_IID;
+
 nsresult
 nsMIMEInfoAndroid::SystemChooser::Equals(nsIHandlerApp *aHandlerApp, bool *aRetVal) {
   nsCOMPtr<nsMIMEInfoAndroid::SystemChooser> info = do_QueryInterface(aHandlerApp);
   if (info)
     return mOuter->Equals(info->mOuter, aRetVal);
   *aRetVal = false;
   return NS_OK;
 }
--- a/xpcom/glue/nsID.h
+++ b/xpcom/glue/nsID.h
@@ -108,33 +108,34 @@ typedef nsID nsIID;
  
 #define NS_DEFINE_IID(_name, _iidspec) \
   const nsIID _name = _iidspec
 
 /**
  * A macro to build the static const IID accessor method. The Dummy
  * template parameter only exists so that the kIID symbol will be linked
  * properly (weak symbol on linux, gnu_linkonce on mac, multiple-definitions
- * merged on windows). Dummy should always be instantiated as "int".
+ * merged on windows). Dummy should always be instantiated as "void".
  */
 
 #define NS_DECLARE_STATIC_IID_ACCESSOR(the_iid)                         \
-  template <class Dummy>                                                \
-  struct COMTypeInfo                                                    \
-  {                                                                     \
-    static const nsIID kIID NS_HIDDEN;                                  \
-  };
+  template<typename T, typename U>                                      \
+  struct COMTypeInfo;
 
 #define NS_DEFINE_STATIC_IID_ACCESSOR(the_interface, the_iid)           \
-  template <class Dummy>                                                \
-  const nsIID the_interface::COMTypeInfo<Dummy>::kIID NS_HIDDEN = the_iid;
+  template <typename T>                                                 \
+  struct the_interface::COMTypeInfo<the_interface, T> {                 \
+    static const nsIID kIID NS_HIDDEN;                                  \
+  };                                                                    \
+  template <typename T>                                                 \
+  const nsIID the_interface::COMTypeInfo<the_interface, T>::kIID NS_HIDDEN = the_iid;
 
 /**
  * A macro to build the static const CID accessor method
  */
 
 #define NS_DEFINE_STATIC_CID_ACCESSOR(the_cid) \
   static const nsID& GetCID() {static const nsID cid = the_cid; return cid;}
 
-#define NS_GET_IID(T) (T::COMTypeInfo<int>::kIID)
-#define NS_GET_TEMPLATE_IID(T) (T::template COMTypeInfo<int>::kIID)
+#define NS_GET_IID(T) (T::COMTypeInfo<T, void>::kIID)
+#define NS_GET_TEMPLATE_IID(T) (T::template COMTypeInfo<T, void>::kIID)
 
 #endif
--- a/xpcom/glue/nsISupportsImpl.h
+++ b/xpcom/glue/nsISupportsImpl.h
@@ -657,24 +657,24 @@ NS_IMETHODIMP _class::QueryInterface(REF
   NS_ASSERTION(aInstancePtr,                                                  \
                "QueryInterface requires a non-NULL destination!");            \
   nsresult rv = NS_ERROR_FAILURE;
 
 #define NS_INTERFACE_TABLE_BEGIN                                              \
   static const QITableEntry table[] = {
 
 #define NS_INTERFACE_TABLE_ENTRY(_class, _interface)                          \
-  { &_interface::COMTypeInfo<int>::kIID,                                      \
+  { &NS_GET_IID(_interface),                                                  \
     int32_t(reinterpret_cast<char*>(                                          \
                         static_cast<_interface*>((_class*) 0x1000)) -         \
                reinterpret_cast<char*>((_class*) 0x1000))                     \
   },
 
 #define NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, _interface, _implClass)    \
-  { &_interface::COMTypeInfo<int>::kIID,                                      \
+  { &NS_GET_IID(_interface),                                                  \
     int32_t(reinterpret_cast<char*>(                                          \
                         static_cast<_interface*>(                             \
                                        static_cast<_implClass*>(              \
                                                       (_class*) 0x1000))) -   \
                reinterpret_cast<char*>((_class*) 0x1000))                     \
   },
 
 /*