Bug 1330185 - Use a top-level PProfiler protocol to control the profiler in other processes. r=njn, r=billm

MozReview-Commit-ID: EROfGuYQ6a0
This commit is contained in:
Markus Stange
2017-05-22 13:47:02 -04:00
parent a8a3be76d1
commit 5775b5cb1b
33 changed files with 817 additions and 658 deletions

View File

@@ -53,7 +53,9 @@
#include "mozilla/ipc/CrashReporterClient.h"
#endif
#include "GeckoProfiler.h"
#ifdef MOZ_GECKO_PROFILER
#include "ChildProfilerController.h"
#endif
using namespace mozilla;
using namespace mozilla::ipc;
@@ -284,6 +286,11 @@ PluginModuleChild::InitForChrome(const std::string& aPluginFilename,
GetIPCChannel()->SetAbortOnError(true);
#ifdef MOZ_GECKO_PROFILER
mProfilerController = new ChildProfilerController();
Unused << SendInitProfiler(mProfilerController->SetUpEndpoints(OtherPid()));
#endif
// TODO: use PluginPRLibrary here
#if defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS)
@@ -746,6 +753,13 @@ PluginModuleChild::AnswerInitCrashReporter(Shmem&& aShmem, mozilla::dom::NativeT
void
PluginModuleChild::ActorDestroy(ActorDestroyReason why)
{
#ifdef MOZ_GECKO_PROFILER
if (mProfilerController) {
mProfilerController->Shutdown();
mProfilerController = nullptr;
}
#endif
if (!mIsChrome) {
PluginModuleChild* chromeInstance = PluginModuleChild::GetChrome();
if (chromeInstance) {
@@ -2665,54 +2679,6 @@ PluginModuleChild::ProcessNativeEvents() {
}
#endif
mozilla::ipc::IPCResult
PluginModuleChild::RecvStartProfiler(const ProfilerInitParams& params)
{
nsTArray<const char*> filterArray;
for (size_t i = 0; i < params.filters().Length(); ++i) {
filterArray.AppendElement(params.filters()[i].get());
}
profiler_start(params.entries(), params.interval(), params.features(),
filterArray.Elements(), filterArray.Length());
return IPC_OK();
}
mozilla::ipc::IPCResult
PluginModuleChild::RecvStopProfiler()
{
profiler_stop();
return IPC_OK();
}
mozilla::ipc::IPCResult
PluginModuleChild::RecvPauseProfiler(const bool& aPause)
{
if (aPause) {
profiler_pause();
} else {
profiler_resume();
}
return IPC_OK();
}
mozilla::ipc::IPCResult
PluginModuleChild::RecvGatherProfile()
{
nsCString profileCString;
UniquePtr<char[]> profile = profiler_get_profile();
if (profile != nullptr) {
profileCString = nsCString(profile.get(), strlen(profile.get()));
} else {
profileCString = nsCString("", 0);
}
Unused << SendProfile(profileCString, false);
return IPC_OK();
}
NPError
PluginModuleChild::PluginRequiresAudioDeviceChanges(
PluginInstanceChild* aInstance,