Bug 1719218 - Build ProfilerParent even when MOZ_GECKO_PROFILER is not defined, r=gerald,necko-reviewers,nika,dragana.

Differential Revision: https://phabricator.services.mozilla.com/D119131
This commit is contained in:
Florian Quèze 2021-07-08 16:20:08 +00:00
parent 410d1986fc
commit 673e38408d
7 changed files with 47 additions and 51 deletions

View File

@ -314,8 +314,8 @@
#ifdef MOZ_GECKO_PROFILER
# include "nsIProfiler.h"
# include "ProfilerParent.h"
#endif
#include "ProfilerParent.h"
#ifdef MOZ_CODE_COVERAGE
# include "mozilla/CodeCoverageHandler.h"
@ -1699,9 +1699,7 @@ void ContentParent::Init() {
}
#endif // #ifdef ACCESSIBILITY
#ifdef MOZ_GECKO_PROFILER
Unused << SendInitProfiler(ProfilerParent::CreateForProcess(OtherPid()));
#endif
// Ensure that the default set of permissions are avaliable in the content
// process before we try to load any URIs in it.

View File

@ -24,9 +24,7 @@
# include "mozilla/WinDllServices.h"
#endif
#ifdef MOZ_GECKO_PROFILER
# include "ProfilerParent.h"
#endif
#include "ProfilerParent.h"
#include "RDDProcessHost.h"
namespace mozilla {
@ -62,9 +60,7 @@ bool RDDChild::Init() {
SendInit(updates, brokerFd, Telemetry::CanRecordReleaseData());
#ifdef MOZ_GECKO_PROFILER
Unused << SendInitProfiler(ProfilerParent::CreateForProcess(OtherPid()));
#endif
gfxVars::AddReceiver(this);
auto* gpm = gfx::GPUProcessManager::Get();

View File

@ -31,10 +31,7 @@
#include "mozilla/layers/LayerTreeOwnerTracker.h"
#include "nsIGfxInfo.h"
#include "nsIObserverService.h"
#ifdef MOZ_GECKO_PROFILER
# include "ProfilerParent.h"
#endif
#include "ProfilerParent.h"
namespace mozilla {
namespace gfx {
@ -77,9 +74,7 @@ void GPUChild::Init() {
gfxVars::AddReceiver(this);
#ifdef MOZ_GECKO_PROFILER
Unused << SendInitProfiler(ProfilerParent::CreateForProcess(OtherPid()));
#endif
}
void GPUChild::OnVarChanged(const GfxVarUpdate& aVar) { SendUpdateVar(aVar); }

View File

@ -11,6 +11,7 @@
#include "nsAppRunner.h"
#include "nsIOService.h"
#include "nsIObserverService.h"
#include "ProfilerParent.h"
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
# include "mozilla/SandboxBroker.h"
@ -18,10 +19,6 @@
# include "mozilla/SandboxSettings.h"
#endif
#ifdef MOZ_GECKO_PROFILER
# include "ProfilerParent.h"
#endif
#if defined(XP_MACOSX) && defined(MOZ_SANDBOX)
# include "mozilla/Sandbox.h"
#endif
@ -176,10 +173,8 @@ void SocketProcessHost::InitAfterConnect(bool aSucceeded) {
Unused << GetActor()->SendInit(attributes);
#ifdef MOZ_GECKO_PROFILER
Unused << GetActor()->SendInitProfiler(
ProfilerParent::CreateForProcess(GetActor()->OtherPid()));
#endif
if (mListener) {
mListener->OnProcessLaunchComplete(this, true);

View File

@ -6,7 +6,9 @@
#include "ProfilerParent.h"
#include "nsProfiler.h"
#ifdef MOZ_GECKO_PROFILER
# include "nsProfiler.h"
#endif
#include "mozilla/BaseProfilerDetail.h"
#include "mozilla/ClearOnShutdown.h"
@ -26,6 +28,35 @@ namespace mozilla {
using namespace ipc;
/* static */
Endpoint<PProfilerChild> ProfilerParent::CreateForProcess(
base::ProcessId aOtherPid) {
MOZ_RELEASE_ASSERT(NS_IsMainThread());
Endpoint<PProfilerChild> child;
#ifdef MOZ_GECKO_PROFILER
Endpoint<PProfilerParent> parent;
nsresult rv = PProfiler::CreateEndpoints(base::GetCurrentProcId(), aOtherPid,
&parent, &child);
if (NS_FAILED(rv)) {
MOZ_CRASH("Failed to create top level actor for PProfiler!");
}
RefPtr<ProfilerParent> actor = new ProfilerParent(aOtherPid);
if (!parent.Bind(actor)) {
MOZ_CRASH("Failed to bind parent actor for PProfiler!");
}
// mSelfRef will be cleared in DeallocPProfilerParent.
actor->mSelfRef = actor;
actor->Init();
#endif
return child;
}
#ifdef MOZ_GECKO_PROFILER
class ProfilerParentTracker;
// This class is responsible for gathering updates from chunk managers in
@ -355,13 +386,13 @@ void ProfileBufferGlobalController::HandleChunkManagerNonFinalUpdate(
mReleasedTotalBytes = mReleasedTotalBytes - destroyedReleased + newlyReleased;
#ifdef DEBUG
# ifdef DEBUG
size_t totalReleased = 0;
for (const TimeStampAndBytesAndPid& item : mReleasedChunksByTime) {
totalReleased += item.mBytes;
}
MOZ_ASSERT(mReleasedTotalBytes == totalReleased);
#endif // DEBUG
# endif // DEBUG
std::vector<ProfileBufferControlledChunkManager::ChunkMetadata> toDestroy;
while (mUnreleasedTotalBytes + mReleasedTotalBytes > mMaximumBytes &&
@ -541,31 +572,6 @@ ProfilerParentTracker::~ProfilerParentTracker() {
}
}
/* static */
Endpoint<PProfilerChild> ProfilerParent::CreateForProcess(
base::ProcessId aOtherPid) {
MOZ_RELEASE_ASSERT(NS_IsMainThread());
Endpoint<PProfilerParent> parent;
Endpoint<PProfilerChild> child;
nsresult rv = PProfiler::CreateEndpoints(base::GetCurrentProcId(), aOtherPid,
&parent, &child);
if (NS_FAILED(rv)) {
MOZ_CRASH("Failed to create top level actor for PProfiler!");
}
RefPtr<ProfilerParent> actor = new ProfilerParent(aOtherPid);
if (!parent.Bind(actor)) {
MOZ_CRASH("Failed to bind parent actor for PProfiler!");
}
// mSelfRef will be cleared in DeallocPProfilerParent.
actor->mSelfRef = actor;
actor->Init();
return child;
}
ProfilerParent::ProfilerParent(base::ProcessId aChildPid)
: mChildPid(aChildPid), mDestroyed(false) {
MOZ_COUNT_CTOR(ProfilerParent);
@ -807,4 +813,6 @@ void ProfilerParent::ActorDestroy(ActorDestroyReason aActorDestroyReason) {
void ProfilerParent::ActorDealloc() { mSelfRef = nullptr; }
#endif
} // namespace mozilla

View File

@ -15,7 +15,6 @@ if CONFIG["MOZ_GECKO_PROFILER"]:
"public/GeckoProfilerReporter.h",
"public/ProfilerChild.h",
"public/ProfilerCodeAddressService.h",
"public/ProfilerParent.h",
"public/shared-libraries.h",
]
UNIFIED_SOURCES += [
@ -32,7 +31,6 @@ if CONFIG["MOZ_GECKO_PROFILER"]:
"gecko/nsProfilerStartParams.cpp",
"gecko/ProfilerChild.cpp",
"gecko/ProfilerIOInterposeObserver.cpp",
"gecko/ProfilerParent.cpp",
]
if CONFIG["MOZ_REPLACE_MALLOC"] and CONFIG["MOZ_PROFILER_MEMORY"]:
SOURCES += [
@ -132,6 +130,7 @@ if CONFIG["MOZ_GECKO_PROFILER"]:
UNIFIED_SOURCES += [
"core/MicroGeckoProfiler.cpp",
"core/ProfilerBindings.cpp",
"gecko/ProfilerParent.cpp",
]
IPDL_SOURCES += [
@ -144,6 +143,7 @@ include("/ipc/chromium/chromium-config.mozbuild")
EXPORTS += [
"public/GeckoProfiler.h",
"public/ProfilerBindings.h",
"public/ProfilerParent.h",
]
EXPORTS.mozilla += [

View File

@ -36,6 +36,7 @@ class ProfilerParent final : public PProfilerParent {
static mozilla::ipc::Endpoint<PProfilerChild> CreateForProcess(
base::ProcessId aOtherPid);
#ifdef MOZ_GECKO_PROFILER
typedef MozPromise<Shmem, ResponseRejectReason, true>
SingleProcessProfilePromise;
@ -75,7 +76,6 @@ class ProfilerParent final : public PProfilerParent {
friend class ProfilerParentTracker;
explicit ProfilerParent(base::ProcessId aChildPid);
virtual ~ProfilerParent();
void Init();
void ActorDestroy(ActorDestroyReason aActorDestroyReason) override;
@ -88,6 +88,10 @@ class ProfilerParent final : public PProfilerParent {
nsTArray<MozPromiseHolder<SingleProcessProfilePromise>>
mPendingRequestedProfiles;
bool mDestroyed;
#endif // MOZ_GECKO_PROFILER
private:
virtual ~ProfilerParent();
};
} // namespace mozilla