Bug 1370673 - Discard exit profiles when the profiler is stopped. r=njn
authorMarkus Stange <mstange@themasta.com>
Tue, 06 Jun 2017 23:12:01 -0400
changeset 410895 0fbdafd2214dee63b4bf31c7891ed8c075c23cb5
parent 410894 61f5e3d8517c96ce70ec0cb5539dfd3b03f80a02
child 410896 4d5d122b04ea7867ecf84c4a354c3bd43c5a6c91
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1370673
milestone55.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 1370673 - Discard exit profiles when the profiler is stopped. r=njn MozReview-Commit-ID: DOJt32A1Em8
tools/profiler/gecko/nsProfiler.cpp
tools/profiler/gecko/nsProfiler.h
--- a/tools/profiler/gecko/nsProfiler.cpp
+++ b/tools/profiler/gecko/nsProfiler.cpp
@@ -126,17 +126,22 @@ nsProfiler::StartProfiler(uint32_t aEntr
   profiler_start(aEntries, aInterval, features, aFilters, aFilterCount);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsProfiler::StopProfiler()
 {
-  CancelGathering();
+  // If we have a Promise in flight, we should reject it.
+  if (mPromiseHolder.isSome()) {
+    mPromiseHolder->RejectIfExists(NS_ERROR_DOM_ABORT_ERR, __func__);
+  }
+  mExitProfiles.Clear();
+  ResetGathering();
 
   profiler_stop();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsProfiler::IsPaused(bool *aIsPaused)
@@ -610,26 +615,16 @@ nsProfiler::StartGathering(double aSince
   if (!mPendingProfiles) {
     FinishGathering();
   }
 
   return promise;
 }
 
 void
-nsProfiler::CancelGathering()
-{
-  // If we have a Promise in flight, we should reject it.
-  if (mPromiseHolder.isSome()) {
-    mPromiseHolder->RejectIfExists(NS_ERROR_DOM_ABORT_ERR, __func__);
-  }
-  ResetGathering();
-}
-
-void
 nsProfiler::FinishGathering()
 {
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
   MOZ_RELEASE_ASSERT(mWriter.isSome());
   MOZ_RELEASE_ASSERT(mPromiseHolder.isSome());
 
   // Close the "processes" array property.
   mWriter->EndArray();
--- a/tools/profiler/gecko/nsProfiler.h
+++ b/tools/profiler/gecko/nsProfiler.h
@@ -36,17 +36,16 @@ public:
   void GatheredOOPProfile(const nsACString& aProfile);
 
 private:
   ~nsProfiler();
 
   typedef mozilla::MozPromise<nsCString, nsresult, false> GatheringPromise;
 
   RefPtr<GatheringPromise> StartGathering(double aSinceTime);
-  void CancelGathering();
   void FinishGathering();
   void ResetGathering();
 
   bool mLockedForPrivateBrowsing;
 
   // These fields are all related to profile gathering.
   nsTArray<nsCString> mExitProfiles;
   mozilla::Maybe<mozilla::MozPromiseHolder<GatheringPromise>> mPromiseHolder;