Bug 1370673 - Discard exit profiles when the profiler is stopped. r?njn
MozReview-Commit-ID: DOJt32A1Em8
--- 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;