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
This commit is contained in:
Markus Stange 2017-03-22 21:45:10 -04:00
Родитель 2a4fe61200
Коммит c1e6abcc0a
2 изменённых файлов: 8 добавлений и 20 удалений

Просмотреть файл

@ -61,16 +61,13 @@ CrossProcessProfilerController::CrossProcessProfilerController(
ProfilerControllingProcess* aProcess)
: mProcess(aProcess)
, mObserver(new ProfilerObserver(*this))
, mIsProfilerActive(false)
{
nsCOMPtr<nsIProfiler> profiler(do_GetService("@mozilla.org/tools/profiler;1"));
bool profilerActive = false;
DebugOnly<nsresult> 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<nsIProfilerStartParams> currentProfilerParams;
rv = profiler->GetStartParams(getter_AddRefs(currentProfilerParams));
nsCOMPtr<nsIProfiler> profiler(do_GetService("@mozilla.org/tools/profiler;1"));
DebugOnly<nsresult> 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

Просмотреть файл

@ -36,7 +36,6 @@ private:
ProfilerControllingProcess* mProcess;
RefPtr<ProfilerObserver> mObserver;
nsCString mProfile;
bool mIsProfilerActive;
};
} // namespace mozilla