Backed out changeset bc00f3a6a496 (bug 1194049) in case this caused the memory leaks on linux on a CLOSED TREE
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Wed, 14 Oct 2015 13:35:00 +0200
changeset 607005 0c3b3b4b1bd456ba72b8fcf2da3d14ee8c2a1ab8
parent 607004 96042c38d46ccb874bd2227bd5d1638c3c0f448b
child 607006 af3290dc0520ef3b5c318e77e08a3171dedd5258
push id93006
push userjyavenard@mozilla.com
push dateThu, 15 Oct 2015 05:15:33 +0000
treeherdertry@45ea2a01301e [default view] [failures only]
bugs1194049
milestone43.0a2
backs outbc00f3a6a496b1ebc0a2dd6211fb4f0a2331f2fb
Backed out changeset bc00f3a6a496 (bug 1194049) in case this caused the memory leaks on linux on a CLOSED TREE
dom/presentation/provider/MulticastDNSDeviceProvider.cpp
--- a/dom/presentation/provider/MulticastDNSDeviceProvider.cpp
+++ b/dom/presentation/provider/MulticastDNSDeviceProvider.cpp
@@ -1,15 +1,14 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 #include "MulticastDNSDeviceProvider.h"
-#include "MainThreadUtils.h"
 #include "mozilla/Logging.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "nsAutoPtr.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIObserverService.h"
 #include "nsIPresentationDevice.h"
 #include "nsServiceManagerUtils.h"
@@ -92,18 +91,16 @@ NS_IMPL_ISUPPORTS(MulticastDNSDeviceProv
 MulticastDNSDeviceProvider::~MulticastDNSDeviceProvider()
 {
   Uninit();
 }
 
 nsresult
 MulticastDNSDeviceProvider::Init()
 {
-  MOZ_ASSERT(NS_IsMainThread());
-
   if (mInitialized) {
     return NS_OK;
   }
 
   nsresult rv;
 
   mMulticastDNS = do_GetService(DNSSERVICEDISCOVERY_CONTRACT_ID, &rv);
   if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -139,18 +136,16 @@ MulticastDNSDeviceProvider::Init()
 
   mInitialized = true;
   return NS_OK;
 }
 
 nsresult
 MulticastDNSDeviceProvider::Uninit()
 {
-  MOZ_ASSERT(NS_IsMainThread());
-
   if (!mInitialized) {
     return NS_OK;
   }
 
   Preferences::RemoveObservers(this, kObservedPrefs);
 
   StopDiscovery(NS_OK);
   UnregisterService(NS_OK);
@@ -165,17 +160,16 @@ MulticastDNSDeviceProvider::Uninit()
   mInitialized = false;
   return NS_OK;
 }
 
 nsresult
 MulticastDNSDeviceProvider::RegisterService()
 {
   LOG_I("RegisterService: %s (%d)", mServiceName.get(), mDiscoverable);
-  MOZ_ASSERT(NS_IsMainThread());
 
   if (!mDiscoverable) {
     return NS_OK;
   }
 
   MOZ_ASSERT(!mRegisterRequest);
 
   nsresult rv;
@@ -212,65 +206,57 @@ MulticastDNSDeviceProvider::RegisterServ
   return mMulticastDNS->RegisterService(serviceInfo,
                                         mWrappedListener,
                                         getter_AddRefs(mRegisterRequest));
 }
 
 nsresult
 MulticastDNSDeviceProvider::UnregisterService(nsresult aReason)
 {
-  MOZ_ASSERT(NS_IsMainThread());
-
   if (mRegisterRequest) {
     mRegisterRequest->Cancel(aReason);
     mRegisterRequest = nullptr;
   }
 
   if (mPresentationServer) {
     mPresentationServer->SetListener(nullptr);
     mPresentationServer->Close();
   }
 
   return NS_OK;
 }
 
 nsresult
 MulticastDNSDeviceProvider::StopDiscovery(nsresult aReason)
 {
-  MOZ_ASSERT(NS_IsMainThread());
-
   if (mDiscoveryRequest) {
     mDiscoveryRequest->Cancel(aReason);
     mDiscoveryRequest = nullptr;
   }
 
   return NS_OK;
 }
 
 // nsIPresentationDeviceProvider
 NS_IMETHODIMP
 MulticastDNSDeviceProvider::GetListener(nsIPresentationDeviceListener** aListener)
 {
-  MOZ_ASSERT(NS_IsMainThread());
-
   if (NS_WARN_IF(!aListener)) {
     return NS_ERROR_INVALID_POINTER;
   }
 
   nsCOMPtr<nsIPresentationDeviceListener> listener = do_QueryReferent(mDeviceListener);
   listener.forget(aListener);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 MulticastDNSDeviceProvider::SetListener(nsIPresentationDeviceListener* aListener)
 {
-  MOZ_ASSERT(NS_IsMainThread());
-
   mDeviceListener = do_GetWeakReference(aListener);
 
   nsresult rv;
   if (mDeviceListener) {
     if (NS_WARN_IF(NS_FAILED(rv = Init()))) {
       return rv;
     }
   } else {
@@ -281,17 +267,16 @@ MulticastDNSDeviceProvider::SetListener(
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 MulticastDNSDeviceProvider::ForceDiscovery()
 {
   LOG_I("ForceDiscovery (%d)", mDiscoveryEnabled);
-  MOZ_ASSERT(NS_IsMainThread());
 
   if (!mDiscoveryEnabled) {
     return NS_OK;
   }
 
   MOZ_ASSERT(mMulticastDNS);
 
   StopDiscovery(NS_OK);
@@ -307,35 +292,29 @@ MulticastDNSDeviceProvider::ForceDiscove
   return NS_OK;
 }
 
 // nsIDNSServiceDiscoveryListener
 NS_IMETHODIMP
 MulticastDNSDeviceProvider::OnDiscoveryStarted(const nsACString& aServiceType)
 {
   LOG_I("OnDiscoveryStarted");
-  MOZ_ASSERT(NS_IsMainThread());
-
   return NS_OK;
 }
 
 NS_IMETHODIMP
 MulticastDNSDeviceProvider::OnDiscoveryStopped(const nsACString& aServiceType)
 {
   LOG_I("OnDiscoveryStopped");
-  MOZ_ASSERT(NS_IsMainThread());
-
   return NS_OK;
 }
 
 NS_IMETHODIMP
 MulticastDNSDeviceProvider::OnServiceFound(nsIDNSServiceInfo* aServiceInfo)
 {
-  MOZ_ASSERT(NS_IsMainThread());
-
   if (NS_WARN_IF(!aServiceInfo)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   nsresult rv ;
 
   nsAutoCString serviceName;
   if (NS_WARN_IF(NS_FAILED(rv = aServiceInfo->GetServiceName(serviceName)))) {
@@ -364,18 +343,16 @@ MulticastDNSDeviceProvider::OnServiceFou
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 MulticastDNSDeviceProvider::OnServiceLost(nsIDNSServiceInfo* aServiceInfo)
 {
-  MOZ_ASSERT(NS_IsMainThread());
-
   if (NS_WARN_IF(!aServiceInfo)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   nsresult rv;
 
   nsAutoCString serviceName;
   if (NS_WARN_IF(NS_FAILED(rv = aServiceInfo->GetServiceName(serviceName)))) {
@@ -401,37 +378,31 @@ MulticastDNSDeviceProvider::OnServiceLos
   return NS_OK;
 }
 
 NS_IMETHODIMP
 MulticastDNSDeviceProvider::OnStartDiscoveryFailed(const nsACString& aServiceType,
                                                    int32_t aErrorCode)
 {
   LOG_E("OnStartDiscoveryFailed: %d", aErrorCode);
-  MOZ_ASSERT(NS_IsMainThread());
-
   return NS_OK;
 }
 
 NS_IMETHODIMP
 MulticastDNSDeviceProvider::OnStopDiscoveryFailed(const nsACString& aServiceType,
                                                   int32_t aErrorCode)
 {
   LOG_E("OnStopDiscoveryFailed: %d", aErrorCode);
-  MOZ_ASSERT(NS_IsMainThread());
-
   return NS_OK;
 }
 
 // nsIDNSRegistrationListener
 NS_IMETHODIMP
 MulticastDNSDeviceProvider::OnServiceRegistered(nsIDNSServiceInfo* aServiceInfo)
 {
-  MOZ_ASSERT(NS_IsMainThread());
-
   if (NS_WARN_IF(!aServiceInfo)) {
     return NS_ERROR_INVALID_ARG;
   }
   nsresult rv;
 
   nsAutoCString name;
   if (NS_WARN_IF(NS_FAILED(rv = aServiceInfo->GetServiceName(name)))) {
     return rv;
@@ -446,27 +417,24 @@ MulticastDNSDeviceProvider::OnServiceReg
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 MulticastDNSDeviceProvider::OnServiceUnregistered(nsIDNSServiceInfo* aServiceInfo)
 {
   LOG_I("OnServiceUnregistered");
-  MOZ_ASSERT(NS_IsMainThread());
-
   return NS_OK;
 }
 
 NS_IMETHODIMP
 MulticastDNSDeviceProvider::OnRegistrationFailed(nsIDNSServiceInfo* aServiceInfo,
                                                  int32_t aErrorCode)
 {
   LOG_E("OnRegistrationFailed: %d", aErrorCode);
-  MOZ_ASSERT(NS_IsMainThread());
 
   mRegisterRequest = nullptr;
 
   nsresult rv;
 
   if (aErrorCode == nsIDNSRegistrationListener::ERROR_SERVICE_NOT_RUNNING) {
     if (NS_WARN_IF(NS_FAILED(rv = RegisterService()))) {
       return rv;
@@ -476,27 +444,23 @@ MulticastDNSDeviceProvider::OnRegistrati
   return NS_OK;
 }
 
 NS_IMETHODIMP
 MulticastDNSDeviceProvider::OnUnregistrationFailed(nsIDNSServiceInfo* aServiceInfo,
                                                    int32_t aErrorCode)
 {
   LOG_E("OnUnregistrationFailed: %d", aErrorCode);
-  MOZ_ASSERT(NS_IsMainThread());
-
   return NS_OK;
 }
 
 // nsIDNSServiceResolveListener
 NS_IMETHODIMP
 MulticastDNSDeviceProvider::OnServiceResolved(nsIDNSServiceInfo* aServiceInfo)
 {
-  MOZ_ASSERT(NS_IsMainThread());
-
   if (NS_WARN_IF(!aServiceInfo)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   nsresult rv;
 
   nsAutoCString serviceName;
   if (NS_WARN_IF(NS_FAILED(rv = aServiceInfo->GetServiceName(serviceName)))) {
@@ -548,27 +512,24 @@ MulticastDNSDeviceProvider::OnServiceRes
   return NS_OK;
 }
 
 NS_IMETHODIMP
 MulticastDNSDeviceProvider::OnResolveFailed(nsIDNSServiceInfo* aServiceInfo,
                                             int32_t aErrorCode)
 {
   LOG_E("OnResolveFailed: %d", aErrorCode);
-  MOZ_ASSERT(NS_IsMainThread());
-
   return NS_OK;
 }
 
 // nsITCPPresentationServerListener
 NS_IMETHODIMP
 MulticastDNSDeviceProvider::OnClose(nsresult aReason)
 {
   LOG_I("OnClose: %x", aReason);
-  MOZ_ASSERT(NS_IsMainThread());
 
   UnregisterService(aReason);
 
   nsresult rv;
 
   if (mDiscoveryEnabled && NS_WARN_IF(NS_FAILED(rv = ForceDiscovery()))) {
     return rv;
   }
@@ -581,18 +542,16 @@ MulticastDNSDeviceProvider::OnClose(nsre
 }
 
 // nsIObserver
 NS_IMETHODIMP
 MulticastDNSDeviceProvider::Observe(nsISupports* aSubject,
                                     const char* aTopic,
                                     const char16_t* aData)
 {
-  MOZ_ASSERT(NS_IsMainThread());
-
   NS_ConvertUTF16toUTF8 data(aData);
   LOG_I("Observe: topic = %s, data = %s", aTopic, data.get());
 
   if (!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
     if (data.EqualsLiteral(PREF_PRESENTATION_DISCOVERY)) {
       OnDiscoveryChanged(Preferences::GetBool(PREF_PRESENTATION_DISCOVERY));
     } else if (data.EqualsLiteral(PREF_PRESENTATION_DISCOVERABLE)) {
       OnDiscoverableChanged(Preferences::GetBool(PREF_PRESENTATION_DISCOVERABLE));
@@ -603,47 +562,44 @@ MulticastDNSDeviceProvider::Observe(nsIS
 
   return NS_OK;
 }
 
 nsresult
 MulticastDNSDeviceProvider::OnDiscoveryChanged(bool aEnabled)
 {
   LOG_I("DiscoveryEnabled = %d\n", aEnabled);
-  MOZ_ASSERT(NS_IsMainThread());
 
   mDiscoveryEnabled = aEnabled;
 
   if (mDiscoveryEnabled) {
     return ForceDiscovery();
   }
 
   return StopDiscovery(NS_OK);
 }
 
 nsresult
 MulticastDNSDeviceProvider::OnDiscoverableChanged(bool aEnabled)
 {
   LOG_I("Discoverable = %d\n", aEnabled);
-  MOZ_ASSERT(NS_IsMainThread());
 
   mDiscoverable = aEnabled;
 
   if (mDiscoverable) {
     return RegisterService();
   }
 
   return UnregisterService(NS_OK);
 }
 
 nsresult
 MulticastDNSDeviceProvider::OnServiceNameChanged(const nsCString& aServiceName)
 {
   LOG_I("serviceName = %s\n", aServiceName.get());
-  MOZ_ASSERT(NS_IsMainThread());
 
   mServiceName = aServiceName;
 
   nsresult rv;
   if (NS_WARN_IF(NS_FAILED(rv = UnregisterService(NS_OK)))) {
     return rv;
   }