Bug 1110935 - Part 3 - Remove now unnecessary temp variables. r=keeler
authorCykesiopka <cykesiopka.bmo@gmail.com>
Mon, 02 Nov 2015 22:11:00 +0100
changeset 270891 8ef27a178bc2b3d503646ad509b21025c0437515
parent 270890 7fc3ebd52cbf5d6ca2b517a117c6bad1a2bbf666
child 270892 69c98520b770a36b4262524e0aff4a803cdc9481
push id67496
push usercbook@mozilla.com
push dateTue, 03 Nov 2015 08:23:43 +0000
treeherdermozilla-inbound@8ef27a178bc2 [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 3 - Remove now unnecessary temp variables. r=keeler
security/manager/ssl/nsSecureBrowserUIImpl.cpp
--- a/security/manager/ssl/nsSecureBrowserUIImpl.cpp
+++ b/security/manager/ssl/nsSecureBrowserUIImpl.cpp
@@ -385,56 +385,46 @@ void
 nsSecureBrowserUIImpl::ResetStateTracking()
 {
   mDocumentRequestsInProgress = 0;
   mTransferringRequests.Clear();
 }
 
 void
 nsSecureBrowserUIImpl::EvaluateAndUpdateSecurityState(nsIRequest* aRequest,
-                                                      nsISupports *info,
+                                                      nsISupports* info,
                                                       bool withNewLocation,
                                                       bool withNewSink)
 {
-  /* I explicitly ignore the camelCase variable naming style here,
-     I want to make it clear these are temp variables that relate to the 
-     member variables with the same suffix.*/
-
-  uint32_t temp_NewToplevelSecurityState = nsIWebProgressListener::STATE_IS_INSECURE;
-  bool temp_NewToplevelIsEV = false;
+  mNewToplevelIsEV = false;
 
   bool updateStatus = false;
   nsCOMPtr<nsISSLStatus> temp_SSLStatus;
 
-    temp_NewToplevelSecurityState =
-      GetSecurityStateFromSecurityInfoAndRequest(info, aRequest);
+  mNewToplevelSecurityState =
+    GetSecurityStateFromSecurityInfoAndRequest(info, aRequest);
 
-    MOZ_LOG(gSecureDocLog, LogLevel::Debug,
-           ("SecureUI:%p: OnStateChange: remember mNewToplevelSecurityState => %x\n", this,
-            temp_NewToplevelSecurityState));
+  MOZ_LOG(gSecureDocLog, LogLevel::Debug,
+          ("SecureUI:%p: OnStateChange: remember mNewToplevelSecurityState => %x\n",
+           this, mNewToplevelSecurityState));
 
-    nsCOMPtr<nsISSLStatusProvider> sp = do_QueryInterface(info);
-    if (sp) {
-      // Ignore result
-      updateStatus = true;
-      (void) sp->GetSSLStatus(getter_AddRefs(temp_SSLStatus));
-      if (temp_SSLStatus) {
-        bool aTemp;
-        if (NS_SUCCEEDED(temp_SSLStatus->GetIsExtendedValidation(&aTemp))) {
-          temp_NewToplevelIsEV = aTemp;
-        }
+  nsCOMPtr<nsISSLStatusProvider> sp(do_QueryInterface(info));
+  if (sp) {
+    // Ignore result
+    updateStatus = true;
+    (void) sp->GetSSLStatus(getter_AddRefs(temp_SSLStatus));
+    if (temp_SSLStatus) {
+      bool aTemp;
+      if (NS_SUCCEEDED(temp_SSLStatus->GetIsExtendedValidation(&aTemp))) {
+        mNewToplevelIsEV = aTemp;
       }
     }
-
-  // assume temp_NewToplevelSecurityState was set in this scope!
-  // see code that is directly above
+  }
 
   mNewToplevelSecurityStateKnown = true;
-  mNewToplevelSecurityState = temp_NewToplevelSecurityState;
-  mNewToplevelIsEV = temp_NewToplevelIsEV;
   if (updateStatus) {
     mSSLStatus = temp_SSLStatus;
   }
   MOZ_LOG(gSecureDocLog, LogLevel::Debug,
          ("SecureUI:%p: remember securityInfo %p\n", this,
           info));
   nsCOMPtr<nsIAssociatedContentSecurity> associatedContentSecurityFromRequest(
     do_QueryInterface(aRequest));
@@ -573,33 +563,21 @@ nsSecureBrowserUIImpl::OnStateChange(nsI
     I suggest, we look at all incoming requests.
     If a request is NOT for the toplevel DOM window, we will always treat it as a subdocument request,
     regardless of whether the load flags indicate a top level document.
   */
 
   nsCOMPtr<nsIDOMWindow> windowForProgress;
   aWebProgress->GetDOMWindow(getter_AddRefs(windowForProgress));
 
-  nsCOMPtr<nsIDOMWindow> window;
-  bool isViewSource;
-
-  nsCOMPtr<nsINetUtil> ioService;
-
-  window = do_QueryReferent(mWindow);
+  nsCOMPtr<nsIDOMWindow> window(do_QueryReferent(mWindow));
   NS_ASSERTION(window, "Window has gone away?!");
-  isViewSource = mIsViewSource;
-  ioService = mIOService;
 
-  if (!ioService)
-  {
-    ioService = do_GetService(NS_IOSERVICE_CONTRACTID);
-    if (ioService)
-    {
-      mIOService = ioService;
-    }
+  if (!mIOService) {
+    mIOService = do_GetService(NS_IOSERVICE_CONTRACTID);
   }
 
   bool isNoContentResponse = false;
   nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aRequest);
   if (httpChannel) 
   {
     uint32_t response;
     isNoContentResponse = NS_SUCCEEDED(httpChannel->GetResponseStatus(&response)) &&
@@ -624,18 +602,19 @@ nsSecureBrowserUIImpl::OnStateChange(nsI
   {
       MOZ_LOG(gSecureDocLog, LogLevel::Debug,
              ("SecureUI:%p: OnStateChange: progress: no window known\n", this));
   }
 
   MOZ_LOG(gSecureDocLog, LogLevel::Debug,
          ("SecureUI:%p: OnStateChange\n", this));
 
-  if (isViewSource)
+  if (mIsViewSource) {
     return NS_OK;
+  }
 
   if (!aRequest)
   {
     MOZ_LOG(gSecureDocLog, LogLevel::Debug,
            ("SecureUI:%p: OnStateChange with null request\n", this));
     return NS_ERROR_NULL_POINTER;
   }
 
@@ -716,22 +695,22 @@ nsSecureBrowserUIImpl::OnStateChange(nsI
           }
         }
       }
     }
   }
 
   // This will ignore all resource, chrome, data, file, moz-icon, and anno
   // protocols. Local resources are treated as trusted.
-  if (uri && ioService) {
+  if (uri && mIOService) {
     bool hasFlag;
-    nsresult rv = 
-      ioService->URIChainHasFlags(uri, 
-                                  nsIProtocolHandler::URI_IS_LOCAL_RESOURCE,
-                                  &hasFlag);
+    nsresult rv =
+      mIOService->URIChainHasFlags(uri,
+                                   nsIProtocolHandler::URI_IS_LOCAL_RESOURCE,
+                                   &hasFlag);
     if (NS_SUCCEEDED(rv) && hasFlag) {
       isSubDocumentRelevant = false;
     }
   }
 
 #if defined(DEBUG)
   nsCString info2;
   uint32_t testFlags = loadFlags;
@@ -899,26 +878,24 @@ nsSecureBrowserUIImpl::OnStateChange(nsI
   if (aProgressStateFlags & STATE_START
       &&
       aProgressStateFlags & STATE_IS_REQUEST
       &&
       isToplevelProgress
       &&
       loadFlags & nsIChannel::LOAD_DOCUMENT_URI)
   {
-    bool inProgress;
-
     int32_t saveSubBroken;
     int32_t saveSubNo;
     nsCOMPtr<nsIAssociatedContentSecurity> prevContentSecurity;
 
     int32_t newSubBroken = 0;
     int32_t newSubNo = 0;
 
-    inProgress = (mDocumentRequestsInProgress!=0);
+    bool inProgress = (mDocumentRequestsInProgress != 0);
 
     if (allowSecurityStateChange && !inProgress) {
       saveSubBroken = mSubRequestsBrokenSecurity;
       saveSubNo = mSubRequestsNoSecurity;
       prevContentSecurity = do_QueryInterface(mCurrentToplevelSecurityInfo);
     }
 
     if (allowSecurityStateChange && !inProgress)
@@ -1007,26 +984,23 @@ nsSecureBrowserUIImpl::OnStateChange(nsI
   if (aProgressStateFlags & STATE_STOP
       &&
       aProgressStateFlags & STATE_IS_REQUEST
       &&
       isToplevelProgress
       &&
       loadFlags & nsIChannel::LOAD_DOCUMENT_URI)
   {
-    int32_t temp_DocumentRequestsInProgress;
     nsCOMPtr<nsISecurityEventSink> temp_ToplevelEventSink;
 
-    temp_DocumentRequestsInProgress = mDocumentRequestsInProgress;
     if (allowSecurityStateChange) {
       temp_ToplevelEventSink = mToplevelEventSink;
     }
 
-    if (temp_DocumentRequestsInProgress <= 0)
-    {
+    if (mDocumentRequestsInProgress <= 0) {
       // Ignore stop requests unless a document load is in progress
       // Unfortunately on application start, see some stops without having seen any starts...
       return NS_OK;
     }
 
     MOZ_LOG(gSecureDocLog, LogLevel::Debug,
            ("SecureUI:%p: OnStateChange: --mDocumentRequestsInProgress\n", this
             ));
@@ -1068,18 +1042,18 @@ nsSecureBrowserUIImpl::OnStateChange(nsI
     if (mRestoreSubrequests && !inProgress)
     {
       // We get here when there were no OnLocationChange between 
       // OnStateChange(START) and OnStateChange(STOP).  Then the load has not
       // been rendered but has been retargeted in some other way then by external
       // app handler.  Restore mSubRequests* members to what the current security 
       // state info holds (it was reset to all zero in OnStateChange(START) 
       // before).
-      nsCOMPtr<nsIAssociatedContentSecurity> currentContentSecurity;
-      currentContentSecurity = do_QueryInterface(mCurrentToplevelSecurityInfo);
+      nsCOMPtr<nsIAssociatedContentSecurity> currentContentSecurity(
+        do_QueryInterface(mCurrentToplevelSecurityInfo));
 
       // Drop this indication flag, the restore operation is just being done.
       mRestoreSubrequests = false;
 
       // We can do this since the state didn't actually change.
       mNewToplevelSecurityStateKnown = true;
 
       int32_t subBroken = 0;
@@ -1120,20 +1094,17 @@ nsSecureBrowserUIImpl::OnStateChange(nsI
       // but the security state of the new top level document might not yet been known.
       // 
       // At this point, we are learning about the security state of a sub-document.
       // We must not update the security state based on the sub content,
       // if the new top level state is not yet known.
       //
       // We skip updating the security state in this case.
 
-      bool temp_NewToplevelSecurityStateKnown;
-      temp_NewToplevelSecurityStateKnown = mNewToplevelSecurityStateKnown;
-
-      if (temp_NewToplevelSecurityStateKnown) {
+      if (mNewToplevelSecurityStateKnown) {
         UpdateSecurityState(aRequest, false, false);
       }
     }
 
     return NS_OK;
   }
 
   return NS_OK;
@@ -1191,27 +1162,25 @@ nsSecureBrowserUIImpl::UpdateSecuritySta
   if (flagsChanged || withNewLocation || withUpdateStatus) {
     TellTheWorld(aRequest);
   }
 }
 
 void
 nsSecureBrowserUIImpl::TellTheWorld(nsIRequest* aRequest)
 {
-  nsCOMPtr<nsISecurityEventSink> toplevelEventSink;
   uint32_t state = STATE_IS_INSECURE;
-  toplevelEventSink = mToplevelEventSink;
   GetState(&state);
 
-  if (toplevelEventSink) {
+  if (mToplevelEventSink) {
     MOZ_LOG(gSecureDocLog, LogLevel::Debug,
            ("SecureUI:%p: UpdateSecurityState: calling OnSecurityChange\n",
             this));
 
-    toplevelEventSink->OnSecurityChange(aRequest, state);
+    mToplevelEventSink->OnSecurityChange(aRequest, state);
   } else {
     MOZ_LOG(gSecureDocLog, LogLevel::Debug,
            ("SecureUI:%p: UpdateSecurityState: NO mToplevelEventSink!\n",
             this));
 
   }
 }
 
@@ -1292,20 +1261,17 @@ nsSecureBrowserUIImpl::OnLocationChange(
   // state of the new toplevel document might not yet be known.
   // 
   // At this point, we are learning about the security state of a sub-document.
   // We must not update the security state based on the sub content, if the new
   // top level state is not yet known.
   //
   // We skip updating the security state in this case.
 
-  bool temp_NewToplevelSecurityStateKnown;
-  temp_NewToplevelSecurityStateKnown = mNewToplevelSecurityStateKnown;
-
-  if (temp_NewToplevelSecurityStateKnown) {
+  if (mNewToplevelSecurityStateKnown) {
     UpdateSecurityState(aRequest, true, false);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSecureBrowserUIImpl::OnStatusChange(nsIWebProgress* aWebProgress,