Bug 1103094 - Start profiling subprocesses if the parent process is already profiling. r=BenWa
This commit is contained in:
@@ -2807,22 +2807,20 @@ ContentChild::RecvOnAppThemeChanged()
|
||||
}
|
||||
|
||||
bool
|
||||
ContentChild::RecvStartProfiler(const uint32_t& aEntries,
|
||||
const double& aInterval,
|
||||
nsTArray<nsCString>&& aFeatures,
|
||||
nsTArray<nsCString>&& aThreadNameFilters)
|
||||
ContentChild::RecvStartProfiler(const ProfilerInitParams& params)
|
||||
{
|
||||
nsTArray<const char*> featureArray;
|
||||
for (size_t i = 0; i < aFeatures.Length(); ++i) {
|
||||
featureArray.AppendElement(aFeatures[i].get());
|
||||
for (size_t i = 0; i < params.features().Length(); ++i) {
|
||||
featureArray.AppendElement(params.features()[i].get());
|
||||
}
|
||||
|
||||
nsTArray<const char*> threadNameFilterArray;
|
||||
for (size_t i = 0; i < aThreadNameFilters.Length(); ++i) {
|
||||
threadNameFilterArray.AppendElement(aThreadNameFilters[i].get());
|
||||
for (size_t i = 0; i < params.threadFilters().Length(); ++i) {
|
||||
threadNameFilterArray.AppendElement(params.threadFilters()[i].get());
|
||||
}
|
||||
|
||||
profiler_start(aEntries, aInterval, featureArray.Elements(), featureArray.Length(),
|
||||
profiler_start(params.entries(), params.interval(),
|
||||
featureArray.Elements(), featureArray.Length(),
|
||||
threadNameFilterArray.Elements(), threadNameFilterArray.Length());
|
||||
|
||||
return true;
|
||||
|
||||
@@ -424,10 +424,7 @@ public:
|
||||
const bool& aResult) override;
|
||||
virtual bool RecvUpdateWindow(const uintptr_t& aChildId) override;
|
||||
|
||||
virtual bool RecvStartProfiler(const uint32_t& aEntries,
|
||||
const double& aInterval,
|
||||
nsTArray<nsCString>&& aFeatures,
|
||||
nsTArray<nsCString>&& aThreadNameFilters) override;
|
||||
virtual bool RecvStartProfiler(const ProfilerInitParams& params) override;
|
||||
virtual bool RecvPauseProfiler(const bool& aPause) override;
|
||||
virtual bool RecvStopProfiler() override;
|
||||
virtual bool RecvGatherProfile() override;
|
||||
|
||||
@@ -1557,6 +1557,21 @@ ContentParent::Init()
|
||||
Unused << SendActivateA11y();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_ENABLE_PROFILER_SPS
|
||||
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) {
|
||||
nsCOMPtr<nsIProfilerStartParams> currentProfilerParams;
|
||||
rv = profiler->GetStartParams(getter_AddRefs(currentProfilerParams));
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
StartProfiler(currentProfilerParams);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@@ -3275,13 +3290,7 @@ ContentParent::Observe(nsISupports* aSubject,
|
||||
#ifdef MOZ_ENABLE_PROFILER_SPS
|
||||
else if (!strcmp(aTopic, "profiler-started")) {
|
||||
nsCOMPtr<nsIProfilerStartParams> params(do_QueryInterface(aSubject));
|
||||
uint32_t entries;
|
||||
double interval;
|
||||
params->GetEntries(&entries);
|
||||
params->GetInterval(&interval);
|
||||
const nsTArray<nsCString>& features = params->GetFeatures();
|
||||
const nsTArray<nsCString>& threadFilterNames = params->GetThreadFilterNames();
|
||||
Unused << SendStartProfiler(entries, interval, features, threadFilterNames);
|
||||
StartProfiler(params);
|
||||
}
|
||||
else if (!strcmp(aTopic, "profiler-stopped")) {
|
||||
Unused << SendStopProfiler();
|
||||
@@ -5709,6 +5718,24 @@ ContentParent::RecvGetAndroidSystemInfo(AndroidSystemInfo* aInfo)
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
ContentParent::StartProfiler(nsIProfilerStartParams* aParams)
|
||||
{
|
||||
if (NS_WARN_IF(!aParams)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ProfilerInitParams ipcParams;
|
||||
|
||||
ipcParams.enabled() = true;
|
||||
aParams->GetEntries(&ipcParams.entries());
|
||||
aParams->GetInterval(&ipcParams.interval());
|
||||
ipcParams.features() = aParams->GetFeatures();
|
||||
ipcParams.threadFilters() = aParams->GetThreadFilterNames();
|
||||
|
||||
Unused << SendStartProfiler(ipcParams);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
||||
@@ -935,6 +935,7 @@ private:
|
||||
virtual bool RecvGamepadListenerRemoved() override;
|
||||
virtual bool RecvProfile(const nsCString& aProfile) override;
|
||||
virtual bool RecvGetGraphicsDeviceInitData(DeviceInitData* aOut) override;
|
||||
void StartProfiler(nsIProfilerStartParams* aParams);
|
||||
|
||||
virtual bool RecvGetDeviceStorageLocation(const nsString& aType,
|
||||
nsString* aPath) override;
|
||||
|
||||
@@ -65,6 +65,7 @@ include PBackgroundSharedTypes;
|
||||
include PContentPermission;
|
||||
include BrowserConfiguration;
|
||||
include GraphicsMessages;
|
||||
include ProfilerTypes;
|
||||
|
||||
// Workaround to prevent error if PContentChild.cpp & PContentBridgeParent.cpp
|
||||
// are put into different UnifiedProtocolsXX.cpp files.
|
||||
@@ -651,8 +652,7 @@ child:
|
||||
/**
|
||||
* Control the Gecko Profiler in the child process.
|
||||
*/
|
||||
async StartProfiler(uint32_t aEntries, double aInterval, nsCString[] aFeatures,
|
||||
nsCString[] aThreadNameFilters);
|
||||
async StartProfiler(ProfilerInitParams params);
|
||||
async StopProfiler();
|
||||
async PauseProfiler(bool aPause);
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ include protocol PPluginInstance;
|
||||
include protocol PPluginScriptableObject;
|
||||
include protocol PCrashReporter;
|
||||
include protocol PContent;
|
||||
include ProfilerTypes;
|
||||
|
||||
using NPError from "npapi.h";
|
||||
using NPNVariable from "npapi.h";
|
||||
@@ -93,8 +94,7 @@ child:
|
||||
/**
|
||||
* Control the Gecko Profiler in the plugin process.
|
||||
*/
|
||||
async StartProfiler(uint32_t aEntries, double aInterval, nsCString[] aFeatures,
|
||||
nsCString[] aThreadNameFilters);
|
||||
async StartProfiler(ProfilerInitParams params);
|
||||
async StopProfiler();
|
||||
|
||||
async GatherProfile();
|
||||
|
||||
@@ -2524,22 +2524,20 @@ PluginModuleChild::ProcessNativeEvents() {
|
||||
#endif
|
||||
|
||||
bool
|
||||
PluginModuleChild::RecvStartProfiler(const uint32_t& aEntries,
|
||||
const double& aInterval,
|
||||
nsTArray<nsCString>&& aFeatures,
|
||||
nsTArray<nsCString>&& aThreadNameFilters)
|
||||
PluginModuleChild::RecvStartProfiler(const ProfilerInitParams& params)
|
||||
{
|
||||
nsTArray<const char*> featureArray;
|
||||
for (size_t i = 0; i < aFeatures.Length(); ++i) {
|
||||
featureArray.AppendElement(aFeatures[i].get());
|
||||
for (size_t i = 0; i < params.features().Length(); ++i) {
|
||||
featureArray.AppendElement(params.features()[i].get());
|
||||
}
|
||||
|
||||
nsTArray<const char*> threadNameFilterArray;
|
||||
for (size_t i = 0; i < aThreadNameFilters.Length(); ++i) {
|
||||
threadNameFilterArray.AppendElement(aThreadNameFilters[i].get());
|
||||
for (size_t i = 0; i < params.threadFilters().Length(); ++i) {
|
||||
threadNameFilterArray.AppendElement(params.threadFilters()[i].get());
|
||||
}
|
||||
|
||||
profiler_start(aEntries, aInterval, featureArray.Elements(), featureArray.Length(),
|
||||
profiler_start(params.entries(), params.interval(),
|
||||
featureArray.Elements(), featureArray.Length(),
|
||||
threadNameFilterArray.Elements(), threadNameFilterArray.Length());
|
||||
|
||||
return true;
|
||||
|
||||
@@ -147,10 +147,7 @@ protected:
|
||||
virtual bool
|
||||
RecvProcessNativeEventsInInterruptCall() override;
|
||||
|
||||
virtual bool RecvStartProfiler(const uint32_t& aEntries,
|
||||
const double& aInterval,
|
||||
nsTArray<nsCString>&& aFeatures,
|
||||
nsTArray<nsCString>&& aThreadNameFilters) override;
|
||||
virtual bool RecvStartProfiler(const ProfilerInitParams& params) override;
|
||||
virtual bool RecvStopProfiler() override;
|
||||
virtual bool RecvGatherProfile() override;
|
||||
|
||||
|
||||
@@ -3150,7 +3150,15 @@ PluginProfilerObserver::Observe(nsISupports *aSubject,
|
||||
params->GetInterval(&interval);
|
||||
const nsTArray<nsCString>& features = params->GetFeatures();
|
||||
const nsTArray<nsCString>& threadFilterNames = params->GetThreadFilterNames();
|
||||
Unused << mPmp->SendStartProfiler(entries, interval, features, threadFilterNames);
|
||||
|
||||
ProfilerInitParams ipcParams;
|
||||
ipcParams.enabled() = true;
|
||||
ipcParams.entries() = entries;
|
||||
ipcParams.interval() = interval;
|
||||
ipcParams.features() = features;
|
||||
ipcParams.threadFilters() = threadFilterNames;
|
||||
|
||||
Unused << mPmp->SendStartProfiler(ipcParams);
|
||||
} else if (!strcmp(aTopic, "profiler-stopped")) {
|
||||
Unused << mPmp->SendStopProfiler();
|
||||
} else if (!strcmp(aTopic, "profiler-subprocess-gather")) {
|
||||
|
||||
16
tools/profiler/gecko/ProfilerTypes.ipdlh
Normal file
16
tools/profiler/gecko/ProfilerTypes.ipdlh
Normal file
@@ -0,0 +1,16 @@
|
||||
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
struct ProfilerInitParams {
|
||||
bool enabled;
|
||||
uint32_t entries;
|
||||
double interval;
|
||||
nsCString[] threadFilters;
|
||||
nsCString[] features;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
@@ -109,6 +109,12 @@ if CONFIG['MOZ_ENABLE_PROFILER_SPS']:
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
||||
|
||||
IPDL_SOURCES += [
|
||||
'gecko/ProfilerTypes.ipdlh',
|
||||
]
|
||||
|
||||
include('/ipc/chromium/chromium-config.mozbuild')
|
||||
|
||||
EXPORTS += [
|
||||
'public/GeckoProfiler.h',
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user