Bug 1370673 - Discard exit profiles when the profiler is stopped. r?njn draft
authorMarkus Stange <mstange@themasta.com>
Tue, 06 Jun 2017 23:12:01 -0400
changeset 589987 6435897897319b218dbe5b3880d8c5cf7884fc85
parent 589747 6cd0639e02ded96057e7fa325623a1245efd4535
child 589988 e0537adbca408f40549adcd8a0e7f71fdd014be9
child 590387 4e22257a5b49dd02159cd5406d5dc1de9e782695
push id62565
push userbmo:mstange@themasta.com
push dateWed, 07 Jun 2017 03:17:07 +0000
reviewersnjn
bugs1370673
milestone55.0a1
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;