Bug 1185737 - Propagate pause and resume commands to child processes. r=BenWa

When we pause the sampler in the parent, we should pause it in the child as well.
Similarly, when the parent resumes, the child should also resume.
This commit is contained in:
Mike Conley 2015-07-15 12:39:39 -04:00
parent 5373b86d2f
commit 711844b5be
5 changed files with 36 additions and 0 deletions

View File

@ -2612,6 +2612,18 @@ ContentChild::RecvStopProfiler()
return true; return true;
} }
bool
ContentChild::RecvPauseProfiler(const bool& aPause)
{
if (aPause) {
profiler_pause();
} else {
profiler_resume();
}
return true;
}
bool bool
ContentChild::RecvGatherProfile() ContentChild::RecvGatherProfile()
{ {

View File

@ -393,6 +393,7 @@ public:
const double& aInterval, const double& aInterval,
nsTArray<nsCString>&& aFeatures, nsTArray<nsCString>&& aFeatures,
nsTArray<nsCString>&& aThreadNameFilters) override; nsTArray<nsCString>&& aThreadNameFilters) override;
virtual bool RecvPauseProfiler(const bool& aPause) override;
virtual bool RecvStopProfiler() override; virtual bool RecvStopProfiler() override;
virtual bool RecvGatherProfile() override; virtual bool RecvGatherProfile() override;
virtual bool RecvDomainSetChanged(const uint32_t& aSetType, const uint32_t& aChangeType, virtual bool RecvDomainSetChanged(const uint32_t& aSetType, const uint32_t& aChangeType,

View File

@ -669,6 +669,8 @@ static const char* sObserverTopics[] = {
#ifdef MOZ_ENABLE_PROFILER_SPS #ifdef MOZ_ENABLE_PROFILER_SPS
"profiler-started", "profiler-started",
"profiler-stopped", "profiler-stopped",
"profiler-paused",
"profiler-resumed",
"profiler-subprocess-gather", "profiler-subprocess-gather",
"profiler-subprocess", "profiler-subprocess",
#endif #endif
@ -3113,6 +3115,12 @@ ContentParent::Observe(nsISupports* aSubject,
else if (!strcmp(aTopic, "profiler-stopped")) { else if (!strcmp(aTopic, "profiler-stopped")) {
unused << SendStopProfiler(); unused << SendStopProfiler();
} }
else if (!strcmp(aTopic, "profiler-paused")) {
unused << SendPauseProfiler(true);
}
else if (!strcmp(aTopic, "profiler-resumed")) {
unused << SendPauseProfiler(false);
}
else if (!strcmp(aTopic, "profiler-subprocess-gather")) { else if (!strcmp(aTopic, "profiler-subprocess-gather")) {
mGatherer = static_cast<ProfileGatherer*>(aSubject); mGatherer = static_cast<ProfileGatherer*>(aSubject);
mGatherer->WillGatherOOPProfile(); mGatherer->WillGatherOOPProfile();

View File

@ -622,6 +622,7 @@ child:
async StartProfiler(uint32_t aEntries, double aInterval, nsCString[] aFeatures, async StartProfiler(uint32_t aEntries, double aInterval, nsCString[] aFeatures,
nsCString[] aThreadNameFilters); nsCString[] aThreadNameFilters);
async StopProfiler(); async StopProfiler();
async PauseProfiler(bool aPause);
async GatherProfile(); async GatherProfile();

View File

@ -842,12 +842,26 @@ bool mozilla_sampler_is_paused() {
void mozilla_sampler_pause() { void mozilla_sampler_pause() {
if (Sampler::GetActiveSampler()) { if (Sampler::GetActiveSampler()) {
Sampler::GetActiveSampler()->SetPaused(true); Sampler::GetActiveSampler()->SetPaused(true);
#ifndef SPS_STANDALONE
if (Sampler::CanNotifyObservers()) {
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
if (os)
os->NotifyObservers(nullptr, "profiler-paused", nullptr);
}
#endif
} }
} }
void mozilla_sampler_resume() { void mozilla_sampler_resume() {
if (Sampler::GetActiveSampler()) { if (Sampler::GetActiveSampler()) {
Sampler::GetActiveSampler()->SetPaused(false); Sampler::GetActiveSampler()->SetPaused(false);
#ifndef SPS_STANDALONE
if (Sampler::CanNotifyObservers()) {
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
if (os)
os->NotifyObservers(nullptr, "profiler-resumed", nullptr);
}
#endif
} }
} }