From c1e6abcc0a6772cd4649e93f309a2bf7229313af Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Wed, 22 Mar 2017 21:45:10 -0400 Subject: [PATCH] Bug 1321907 - Remove mIsProfilerActive. r=njn Replace it with profiler_is_active() in one place, and simply remove it in the other places. These other places are: - Around the call to profiler_OOP_exit_profile: profiler_OOP_exit_profile itself already checks whether the profiler is running and does nothing if it's not. - When handling the 'profiler-subprocess-gather' notification. This notification is sent by the profiler because it's interested in the profile, so there's little reason to reject it. - In RecvProfile: If the child process sent us a profile, it did so in response to a GatherProfile request, so chances are that we're still interested in that response. These changes may get us a little closer to a state where you can call getProfileDataAsync, stop the profiler before the content process profiles have all come in, and then still receive a response with all the profiles. At the moment, stopping the profiler will abort the profile gathering process, but that seems more like an accident and less like the behavior you'd want. MozReview-Commit-ID: 2tRXC70BztJ --HG-- extra : rebase_source : 3b2f6f51d75d5f0d439e1a815d84164a5a763603 --- .../gecko/CrossProcessProfilerController.cpp | 27 ++++++------------- .../public/CrossProcessProfilerController.h | 1 - 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/tools/profiler/gecko/CrossProcessProfilerController.cpp b/tools/profiler/gecko/CrossProcessProfilerController.cpp index 522e27ac2b71..044480fc0c7b 100644 --- a/tools/profiler/gecko/CrossProcessProfilerController.cpp +++ b/tools/profiler/gecko/CrossProcessProfilerController.cpp @@ -61,16 +61,13 @@ CrossProcessProfilerController::CrossProcessProfilerController( ProfilerControllingProcess* aProcess) : mProcess(aProcess) , mObserver(new ProfilerObserver(*this)) - , mIsProfilerActive(false) { - nsCOMPtr profiler(do_GetService("@mozilla.org/tools/profiler;1")); - bool profilerActive = false; - DebugOnly rv = profiler->IsActive(&profilerActive); - MOZ_ASSERT(NS_SUCCEEDED(rv)); - - if (profilerActive) { + if (profiler_is_active()) { + // If the profiler is already running in this process, start it in the + // child process immediately. nsCOMPtr currentProfilerParams; - rv = profiler->GetStartParams(getter_AddRefs(currentProfilerParams)); + nsCOMPtr profiler(do_GetService("@mozilla.org/tools/profiler;1")); + DebugOnly rv = profiler->GetStartParams(getter_AddRefs(currentProfilerParams)); MOZ_ASSERT(NS_SUCCEEDED(rv)); StartProfiler(currentProfilerParams); @@ -87,7 +84,7 @@ CrossProcessProfilerController::CrossProcessProfilerController( CrossProcessProfilerController::~CrossProcessProfilerController() { - if (mIsProfilerActive && !mProfile.IsEmpty()) { + if (!mProfile.IsEmpty()) { profiler_OOP_exit_profile(mProfile); } @@ -116,8 +113,6 @@ CrossProcessProfilerController::StartProfiler(nsIProfilerStartParams* aParams) ipcParams.threadFilters() = aParams->GetThreadFilterNames(); mProcess->SendStartProfiler(ipcParams); - - mIsProfilerActive = true; } void @@ -129,10 +124,8 @@ CrossProcessProfilerController::Observe(nsISupports* aSubject, // need to tell the other process that we're interested in its profile, // and we tell the gatherer that we've forwarded the request, so that it // can keep track of the number of pending profiles. - if (mIsProfilerActive) { - profiler_will_gather_OOP_profile(); - mProcess->SendGatherProfile(); - } + profiler_will_gather_OOP_profile(); + mProcess->SendGatherProfile(); } else if (!strcmp(aTopic, "profiler-subprocess")) { // profiler-subprocess is sent once the gatherer knows that all other @@ -155,7 +148,6 @@ CrossProcessProfilerController::Observe(nsISupports* aSubject, StartProfiler(params); } else if (!strcmp(aTopic, "profiler-stopped")) { - mIsProfilerActive = false; mProcess->SendStopProfiler(); } else if (!strcmp(aTopic, "profiler-paused")) { @@ -171,9 +163,6 @@ CrossProcessProfilerController::Observe(nsISupports* aSubject, void CrossProcessProfilerController::RecvProfile(const nsCString& aProfile) { - if (NS_WARN_IF(!mIsProfilerActive)) { - return; - } // Store the profile on this object. mProfile = aProfile; // Tell the gatherer that we've received the profile from this process, but diff --git a/tools/profiler/public/CrossProcessProfilerController.h b/tools/profiler/public/CrossProcessProfilerController.h index 4689985cdd81..6ad82ef3099e 100644 --- a/tools/profiler/public/CrossProcessProfilerController.h +++ b/tools/profiler/public/CrossProcessProfilerController.h @@ -36,7 +36,6 @@ private: ProfilerControllingProcess* mProcess; RefPtr mObserver; nsCString mProfile; - bool mIsProfilerActive; }; } // namespace mozilla