Bug 1363036 - Part 1: Remove MOZ_DIAGNOSTIC_ASSERTs previously added for bug hunting. r?smaug draft
authorSamael Wang <freesamael@gmail.com>
Mon, 22 May 2017 11:25:54 +0800
changeset 582880 bde2a7f515979ad881b5e97183459f4d7ea2ba1e
parent 582257 9851fcb0bf4d855c36729d7de19f0fa5c9f69776
child 582881 86a145c2ef13871cd5799f65df5b0002dfb051e1
child 584234 15d2400559754f1dc6b08d3f0f0fb7e8ddfb8acd
push id60225
push userbmo:sawang@mozilla.com
push dateTue, 23 May 2017 09:57:14 +0000
reviewerssmaug
bugs1363036
milestone55.0a1
Bug 1363036 - Part 1: Remove MOZ_DIAGNOSTIC_ASSERTs previously added for bug hunting. r?smaug MozReview-Commit-ID: BAkuRlHtMcP
docshell/shistory/nsSHEntry.cpp
docshell/shistory/nsSHEntryShared.cpp
docshell/shistory/nsSHistory.cpp
xpcom/ds/nsExpirationTracker.h
--- a/docshell/shistory/nsSHEntry.cpp
+++ b/docshell/shistory/nsSHEntry.cpp
@@ -974,12 +974,12 @@ nsSHEntry::SetLastTouched(uint32_t aLast
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHEntry::SetSHistory(nsISHistory* aSHistory)
 {
   nsWeakPtr shistory = do_GetWeakReference(aSHistory);
   // mSHistory can not be changed once it's set
-  MOZ_DIAGNOSTIC_ASSERT(!mShared->mSHistory || (mShared->mSHistory == shistory));
+  MOZ_ASSERT(!mShared->mSHistory || (mShared->mSHistory == shistory));
   mShared->mSHistory = shistory;
   return NS_OK;
 }
--- a/docshell/shistory/nsSHEntryShared.cpp
+++ b/docshell/shistory/nsSHEntryShared.cpp
@@ -132,17 +132,17 @@ nsSHEntryShared::SetContentViewer(nsICon
 
   if (mContentViewer || !aViewer) {
     DropPresentationState();
   }
 
   // If we're setting mContentViewer to null, state should already be cleared
   // in the DropPresentationState() call above; If we're setting it to a
   // non-null content viewer, the entry shouldn't have been tracked either.
-  MOZ_DIAGNOSTIC_ASSERT(!GetExpirationState()->IsTracked());
+  MOZ_ASSERT(!GetExpirationState()->IsTracked());
   mContentViewer = aViewer;
 
   if (mContentViewer) {
     // mSHistory is only set for root entries, but in general bfcache only
     // applies to root entries as well. BFCache for subframe navigation has been
     // disabled since 2005 in bug 304860.
     nsCOMPtr<nsISHistoryInternal> shistory = do_QueryReferent(mSHistory);
     if (shistory) {
--- a/docshell/shistory/nsSHistory.cpp
+++ b/docshell/shistory/nsSHistory.cpp
@@ -1315,17 +1315,17 @@ nsSHistory::AddToExpirationTracker(nsIBF
   mHistoryTracker->AddObject(entry);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHistory::RemoveFromExpirationTracker(nsIBFCacheEntry* aEntry)
 {
   RefPtr<nsSHEntryShared> entry = static_cast<nsSHEntryShared*>(aEntry);
-  MOZ_DIAGNOSTIC_ASSERT(mHistoryTracker && !mHistoryTracker->IsEmpty());
+  MOZ_ASSERT(mHistoryTracker && !mHistoryTracker->IsEmpty());
   if (!mHistoryTracker || !entry) {
     return NS_ERROR_FAILURE;
   }
 
   mHistoryTracker->RemoveObject(entry);
   return NS_OK;
 }
 
@@ -1923,29 +1923,26 @@ nsSHistory::InitiateLoad(nsISHEntry* aFr
   return aFrameDS->LoadURI(nextURI, loadInfo,
                            nsIWebNavigation::LOAD_FLAGS_NONE, false);
 
 }
 
 NS_IMETHODIMP
 nsSHistory::SetRootDocShell(nsIDocShell* aDocShell)
 {
-  MOZ_DIAGNOSTIC_ASSERT(!aDocShell || !mRootDocShell);
   mRootDocShell = aDocShell;
 
   // Init mHistoryTracker on setting mRootDocShell so we can bind its event
   // target to the tabGroup.
   if (mRootDocShell) {
     nsCOMPtr<nsPIDOMWindowOuter> win = mRootDocShell->GetWindow();
     if (!win) {
       return NS_ERROR_UNEXPECTED;
     }
 
-    // mHistroyTracker can only be set once.
-    MOZ_DIAGNOSTIC_ASSERT(!mHistoryTracker);
     RefPtr<mozilla::dom::TabGroup> tabGroup = win->TabGroup();
     mHistoryTracker = mozilla::MakeUnique<HistoryTracker>(
       this,
       mozilla::Preferences::GetUint(CONTENT_VIEWER_TIMEOUT_SECONDS,
                                     CONTENT_VIEWER_TIMEOUT_SECONDS_DEFAULT),
       tabGroup->EventTargetFor(mozilla::TaskCategory::Other));
   }
 
--- a/xpcom/ds/nsExpirationTracker.h
+++ b/xpcom/ds/nsExpirationTracker.h
@@ -142,18 +142,18 @@ public:
   /**
    * Add an object to be tracked. It must not already be tracked. It will
    * be added to the newest generation, i.e., as if it was just used.
    * @return an error on out-of-memory
    */
   nsresult AddObjectLocked(T* aObj, const AutoLock& aAutoLock)
   {
     nsExpirationState* state = aObj->GetExpirationState();
-    MOZ_DIAGNOSTIC_ASSERT(!state->IsTracked(),
-                          "Tried to add an object that's already tracked");
+    MOZ_ASSERT(!state->IsTracked(),
+               "Tried to add an object that's already tracked");
     nsTArray<T*>& generation = mGenerations[mNewestGeneration];
     uint32_t index = generation.Length();
     if (index > nsExpirationState::MAX_INDEX_IN_GENERATION) {
       NS_WARNING("More than 256M elements tracked, this is probably a problem");
       return NS_ERROR_OUT_OF_MEMORY;
     }
     if (index == 0) {
       // We might need to start the timer
@@ -171,28 +171,28 @@ public:
   }
 
   /**
    * Remove an object from the tracker. It must currently be tracked.
    */
   void RemoveObjectLocked(T* aObj, const AutoLock& aAutoLock)
   {
     nsExpirationState* state = aObj->GetExpirationState();
-    MOZ_DIAGNOSTIC_ASSERT(state->IsTracked(), "Tried to remove an object that's not tracked");
+    MOZ_ASSERT(state->IsTracked(), "Tried to remove an object that's not tracked");
     nsTArray<T*>& generation = mGenerations[state->mGeneration];
     uint32_t index = state->mIndexInGeneration;
-    MOZ_DIAGNOSTIC_ASSERT(generation.Length() > index &&
-                          generation[index] == aObj, "Object is lying about its index");
+    MOZ_ASSERT(generation.Length() > index &&
+               generation[index] == aObj, "Object is lying about its index");
     // Move the last object to fill the hole created by removing aObj
     uint32_t last = generation.Length() - 1;
     T* lastObj = generation[last];
     generation[index] = lastObj;
     lastObj->GetExpirationState()->mIndexInGeneration = index;
     generation.RemoveElementAt(last);
-    MOZ_DIAGNOSTIC_ASSERT(generation.Length() == last);
+    MOZ_ASSERT(generation.Length() == last);
     state->mGeneration = nsExpirationState::NOT_TRACKED;
     // We do not check whether we need to stop the timer here. The timer
     // will check that itself next time it fires. Checking here would not
     // be efficient since we'd need to track all generations. Also we could
     // thrash by incessantly creating and destroying timers if someone
     // kept adding and removing an object from the tracker.
   }