Bug 1255459 - Use AutoRestore in ObservedDocShell::PopMarkers. r=smaug
authorTom Tromey <tom@tromey.com>
Thu, 10 Mar 2016 08:59:00 -0500
changeset 339768 aaa66a4fcd17e846a58035d54722f4f47ffbed6b
parent 339767 711999c346bf91efc38436872b6b5f98dd436d30
child 339769 bc7045b5a4d55ca44a59692cfe02c317c3a1f1d7
push id12803
push userjbeich@FreeBSD.org
push dateSun, 13 Mar 2016 09:48:54 +0000
reviewerssmaug
bugs1255459
milestone48.0a1
Bug 1255459 - Use AutoRestore in ObservedDocShell::PopMarkers. r=smaug MozReview-Commit-ID: IbPoXdjfbQu
docshell/base/timeline/ObservedDocShell.cpp
--- a/docshell/base/timeline/ObservedDocShell.cpp
+++ b/docshell/base/timeline/ObservedDocShell.cpp
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ObservedDocShell.h"
 
 #include "AbstractTimelineMarker.h"
 #include "LayerTimelineMarker.h"
 #include "MainThreadUtils.h"
 #include "mozilla/Move.h"
-#include "mozilla/ScopeExit.h"
+#include "mozilla/AutoRestore.h"
 
 namespace mozilla {
 
 ObservedDocShell::ObservedDocShell(nsIDocShell* aDocShell)
   : MarkersStorage("ObservedDocShellMutex")
   , mDocShell(aDocShell)
   , mPopping(false)
 {
@@ -60,18 +60,18 @@ ObservedDocShell::ClearMarkers()
 void
 ObservedDocShell::PopMarkers(JSContext* aCx,
                              nsTArray<dom::ProfileTimelineMarker>& aStore)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MutexAutoLock lock(GetLock()); // for `mOffTheMainThreadTimelineMarkers`.
 
   MOZ_RELEASE_ASSERT(!mPopping);
+  AutoRestore<bool> resetPopping(mPopping);
   mPopping = true;
-  auto resetPopping = MakeScopeExit([&] { mPopping = false; });
 
   // First, move all of our markers into a single array. We'll chose
   // the `mTimelineMarkers` store because that's where we expect most of
   // our markers to be.
   mTimelineMarkers.AppendElements(Move(mOffTheMainThreadTimelineMarkers));
 
   // If we see an unpaired START, we keep it around for the next call
   // to ObservedDocShell::PopMarkers. We store the kept START objects here.