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;
}
bool
ContentChild::RecvPauseProfiler(const bool& aPause)
{
if (aPause) {
profiler_pause();
} else {
profiler_resume();
}
return true;
}
bool
ContentChild::RecvGatherProfile()
{

View File

@ -393,6 +393,7 @@ public:
const double& aInterval,
nsTArray<nsCString>&& aFeatures,
nsTArray<nsCString>&& aThreadNameFilters) override;
virtual bool RecvPauseProfiler(const bool& aPause) override;
virtual bool RecvStopProfiler() override;
virtual bool RecvGatherProfile() override;
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
"profiler-started",
"profiler-stopped",
"profiler-paused",
"profiler-resumed",
"profiler-subprocess-gather",
"profiler-subprocess",
#endif
@ -3113,6 +3115,12 @@ ContentParent::Observe(nsISupports* aSubject,
else if (!strcmp(aTopic, "profiler-stopped")) {
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")) {
mGatherer = static_cast<ProfileGatherer*>(aSubject);
mGatherer->WillGatherOOPProfile();

View File

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

View File

@ -842,12 +842,26 @@ bool mozilla_sampler_is_paused() {
void mozilla_sampler_pause() {
if (Sampler::GetActiveSampler()) {
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() {
if (Sampler::GetActiveSampler()) {
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
}
}