Bug 1110935 - Part 1 - Assert we're on the main thread on public methods. r=keeler
authorCykesiopka <cykesiopka.bmo@gmail.com>
Mon, 02 Nov 2015 22:09:00 +0100
changeset 270992 38c38564a12ed2f6770f510355578a6b0a1e779f
parent 270991 cb0f1211b033725af6bb253715f18fccede02f18
child 270993 7fc3ebd52cbf5d6ca2b517a117c6bad1a2bbf666
push id29631
push usercbook@mozilla.com
push dateWed, 04 Nov 2015 11:00:16 +0000
treeherdermozilla-central@6077f51254c6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskeeler
bugs1110935
milestone45.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 1110935 - Part 1 - Assert we're on the main thread on public methods. r=keeler
security/manager/ssl/nsSecureBrowserUIImpl.cpp
security/manager/ssl/nsSecureBrowserUIImpl.h
--- a/security/manager/ssl/nsSecureBrowserUIImpl.cpp
+++ b/security/manager/ssl/nsSecureBrowserUIImpl.cpp
@@ -110,31 +110,35 @@ nsSecureBrowserUIImpl::nsSecureBrowserUI
   , mSubRequestsNoSecurity(0)
   , mRestoreSubrequests(false)
   , mOnLocationChangeSeen(false)
 #ifdef DEBUG
   , mOnStateLocationChangeReentranceDetection(0)
 #endif
   , mTransferringRequests(&gMapOps, sizeof(RequestHashEntry))
 {
+  MOZ_ASSERT(NS_IsMainThread());
+
   ResetStateTracking();
 
   if (!gSecureDocLog)
     gSecureDocLog = PR_NewLogModule("nsSecureBrowserUI");
 }
 
 NS_IMPL_ISUPPORTS(nsSecureBrowserUIImpl,
                   nsISecureBrowserUI,
                   nsIWebProgressListener,
                   nsISupportsWeakReference,
                   nsISSLStatusProvider)
 
 NS_IMETHODIMP
-nsSecureBrowserUIImpl::Init(nsIDOMWindow *aWindow)
+nsSecureBrowserUIImpl::Init(nsIDOMWindow* aWindow)
 {
+  MOZ_ASSERT(NS_IsMainThread());
+
   if (MOZ_LOG_TEST(gSecureDocLog, LogLevel::Debug)) {
     nsCOMPtr<nsIDOMWindow> window(do_QueryReferent(mWindow));
 
     MOZ_LOG(gSecureDocLog, LogLevel::Debug,
            ("SecureUI:%p: Init: mWindow: %p, aWindow: %p\n", this,
             window.get(), aWindow));
   }
 
@@ -181,16 +185,17 @@ nsSecureBrowserUIImpl::Init(nsIDOMWindow
 
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSecureBrowserUIImpl::GetState(uint32_t* aState)
 {
+  MOZ_ASSERT(NS_IsMainThread());
   ReentrantMonitorAutoEnter lock(mReentrantMonitor);
   return MapInternalToExternalState(aState, mNotifiedSecurityState, mNotifiedToplevelIsEV);
 }
 
 // static
 already_AddRefed<nsISupports> 
 nsSecureBrowserUIImpl::ExtractSecurityInfo(nsIRequest* aRequest)
 {
@@ -298,18 +303,19 @@ nsSecureBrowserUIImpl::MapInternalToExte
 
   if (docShell->GetHasTrackingContentLoaded())
     *aState |= nsIWebProgressListener::STATE_LOADED_TRACKING_CONTENT;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSecureBrowserUIImpl::SetDocShell(nsIDocShell *aDocShell)
+nsSecureBrowserUIImpl::SetDocShell(nsIDocShell* aDocShell)
 {
+  MOZ_ASSERT(NS_IsMainThread());
   nsresult rv;
   mDocShell = do_GetWeakReference(aDocShell, &rv);
   return rv;
 }
 
 static uint32_t GetSecurityStateFromSecurityInfoAndRequest(nsISupports* info,
                                                            nsIRequest* request)
 {
@@ -476,16 +482,17 @@ nsSecureBrowserUIImpl::UpdateSubrequestM
 }
 
 NS_IMETHODIMP
 nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress,
                                      nsIRequest* aRequest,
                                      uint32_t aProgressStateFlags,
                                      nsresult aStatus)
 {
+  MOZ_ASSERT(NS_IsMainThread());
 #ifdef DEBUG
   nsAutoAtomic atomic(mOnStateLocationChangeReentranceDetection);
   NS_ASSERTION(mOnStateLocationChangeReentranceDetection == 1,
                "unexpected parallel nsIWebProgress OnStateChange and/or OnLocationChange notification");
 #endif
   /*
     All discussion, unless otherwise mentioned, only refers to
     http, https, file or wyciwig requests.
@@ -1256,16 +1263,17 @@ nsSecureBrowserUIImpl::TellTheWorld(nsIR
 }
 
 NS_IMETHODIMP
 nsSecureBrowserUIImpl::OnLocationChange(nsIWebProgress* aWebProgress,
                                         nsIRequest* aRequest,
                                         nsIURI* aLocation,
                                         uint32_t aFlags)
 {
+  MOZ_ASSERT(NS_IsMainThread());
 #ifdef DEBUG
   nsAutoAtomic atomic(mOnStateLocationChangeReentranceDetection);
   NS_ASSERTION(mOnStateLocationChangeReentranceDetection == 1,
                "unexpected parallel nsIWebProgress OnStateChange and/or OnLocationChange notification");
 #endif
   MOZ_LOG(gSecureDocLog, LogLevel::Debug,
          ("SecureUI:%p: OnLocationChange\n", this));
 
@@ -1358,28 +1366,29 @@ nsSecureBrowserUIImpl::OnStatusChange(ns
                                       nsresult aStatus,
                                       const char16_t* aMessage)
 {
   NS_NOTREACHED("notification excluded in AddProgressListener(...)");
   return NS_OK;
 }
 
 nsresult
-nsSecureBrowserUIImpl::OnSecurityChange(nsIWebProgress *aWebProgress,
-                                        nsIRequest *aRequest,
+nsSecureBrowserUIImpl::OnSecurityChange(nsIWebProgress* aWebProgress,
+                                        nsIRequest* aRequest,
                                         uint32_t state)
 {
+  MOZ_ASSERT(NS_IsMainThread());
 #if defined(DEBUG)
   nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest));
   if (!channel)
     return NS_OK;
 
   nsCOMPtr<nsIURI> aURI;
   channel->GetURI(getter_AddRefs(aURI));
-  
+
   if (aURI) {
     nsAutoCString temp;
     aURI->GetSpec(temp);
     MOZ_LOG(gSecureDocLog, LogLevel::Debug,
            ("SecureUI:%p: OnSecurityChange: (%x) %s\n", this,
             state, temp.get()));
   }
 #endif
@@ -1387,16 +1396,17 @@ nsSecureBrowserUIImpl::OnSecurityChange(
   return NS_OK;
 }
 
 // nsISSLStatusProvider methods
 NS_IMETHODIMP
 nsSecureBrowserUIImpl::GetSSLStatus(nsISSLStatus** _result)
 {
   NS_ENSURE_ARG_POINTER(_result);
+  MOZ_ASSERT(NS_IsMainThread());
 
   ReentrantMonitorAutoEnter lock(mReentrantMonitor);
 
   switch (mNotifiedSecurityState)
   {
     case lis_broken_security:
     case lis_mixed_security:
     case lis_high_security:
--- a/security/manager/ssl/nsSecureBrowserUIImpl.h
+++ b/security/manager/ssl/nsSecureBrowserUIImpl.h
@@ -37,17 +37,17 @@ class nsSecureBrowserUIImpl : public nsI
                               public nsIWebProgressListener,
                               public nsSupportsWeakReference,
                               public nsISSLStatusProvider
 {
 public:
   
   nsSecureBrowserUIImpl();
   
-  NS_DECL_THREADSAFE_ISUPPORTS
+  NS_DECL_ISUPPORTS
   NS_DECL_NSIWEBPROGRESSLISTENER
   NS_DECL_NSISECUREBROWSERUI
   NS_DECL_NSISSLSTATUSPROVIDER
 
 protected:
   virtual ~nsSecureBrowserUIImpl() {};
 
   mozilla::ReentrantMonitor mReentrantMonitor;