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

MozReview-Commit-ID: EROfGuYQ6a0
This commit is contained in:
Markus Stange
2017-05-30 15:06:14 -04:00
parent 7f01640df3
commit 9b5004bdc9
32 changed files with 792 additions and 638 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;
@@ -210,6 +212,15 @@ PluginModuleChild::InitForContent(Endpoint<PPluginModuleChild>&& aEndpoint)
return true;
}
mozilla::ipc::IPCResult
PluginModuleChild::RecvInitProfiler(Endpoint<mozilla::PProfilerChild>&& aEndpoint)
{
#ifdef MOZ_GECKO_PROFILER
mProfilerController = ChildProfilerController::Create(Move(aEndpoint));
#endif
return IPC_OK();
}
mozilla::ipc::IPCResult
PluginModuleChild::RecvDisableFlashProtectedMode()
{
@@ -750,6 +761,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) {
@@ -2724,54 +2742,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,