Bug 1513057 - P7: Setup Gecko profiler on the socket process r=dragana,mayhemer,mstange

Differential Revision: https://phabricator.services.mozilla.com/D14351

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kershaw Chang 2019-01-11 13:30:47 +00:00
Родитель 1c5e5caaaf
Коммит f66295c49c
4 изменённых файлов: 41 добавлений и 0 удалений

Просмотреть файл

@ -5,6 +5,7 @@
include MemoryReportTypes; include MemoryReportTypes;
include protocol PSocketProcessBridge; include protocol PSocketProcessBridge;
include protocol PProfiler;
include PrefsTypes; include PrefsTypes;
using mozilla::dom::NativeThreadId from "mozilla/dom/TabMessageUtils.h"; using mozilla::dom::NativeThreadId from "mozilla/dom/TabMessageUtils.h";
@ -28,6 +29,7 @@ child:
MaybeFileDesc DMDFile); MaybeFileDesc DMDFile);
async SetOffline(bool offline); async SetOffline(bool offline);
async InitSocketProcessBridgeParent(ProcessId processId, Endpoint<PSocketProcessBridgeParent> endpoint); async InitSocketProcessBridgeParent(ProcessId processId, Endpoint<PSocketProcessBridgeParent> endpoint);
async InitProfiler(Endpoint<PProfilerChild> aEndpoint);
}; };
} // namespace net } // namespace net

Просмотреть файл

@ -17,6 +17,10 @@
#include "ProcessUtils.h" #include "ProcessUtils.h"
#include "SocketProcessBridgeParent.h" #include "SocketProcessBridgeParent.h"
#ifdef MOZ_GECKO_PROFILER
#include "ChildProfilerController.h"
#endif
namespace mozilla { namespace mozilla {
namespace net { namespace net {
@ -76,6 +80,13 @@ void SocketProcessChild::ActorDestroy(ActorDestroyReason aWhy) {
ProcessChild::QuickExit(); ProcessChild::QuickExit();
} }
#ifdef MOZ_GECKO_PROFILER
if (mProfilerController) {
mProfilerController->Shutdown();
mProfilerController = nullptr;
}
#endif
CrashReporterClient::DestroySingleton(); CrashReporterClient::DestroySingleton();
XRE_ShutdownChildProcess(); XRE_ShutdownChildProcess();
} }
@ -131,6 +142,15 @@ mozilla::ipc::IPCResult SocketProcessChild::RecvInitSocketProcessBridgeParent(
return IPC_OK(); return IPC_OK();
} }
mozilla::ipc::IPCResult SocketProcessChild::RecvInitProfiler(
Endpoint<PProfilerChild>&& aEndpoint) {
#ifdef MOZ_GECKO_PROFILER
mProfilerController =
mozilla::ChildProfilerController::Create(std::move(aEndpoint));
#endif
return IPC_OK();
}
void SocketProcessChild::DestroySocketProcessBridgeParent(ProcessId aId) { void SocketProcessChild::DestroySocketProcessBridgeParent(ProcessId aId) {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());

Просмотреть файл

@ -9,6 +9,10 @@
#include "mozilla/net/PSocketProcessChild.h" #include "mozilla/net/PSocketProcessChild.h"
#include "nsRefPtrHashtable.h" #include "nsRefPtrHashtable.h"
namespace mozilla {
class ChildProfilerController;
}
namespace mozilla { namespace mozilla {
namespace net { namespace net {
@ -36,6 +40,8 @@ class SocketProcessChild final : public PSocketProcessChild {
mozilla::ipc::IPCResult RecvInitSocketProcessBridgeParent( mozilla::ipc::IPCResult RecvInitSocketProcessBridgeParent(
const ProcessId& aContentProcessId, const ProcessId& aContentProcessId,
Endpoint<mozilla::net::PSocketProcessBridgeParent>&& aEndpoint) override; Endpoint<mozilla::net::PSocketProcessBridgeParent>&& aEndpoint) override;
mozilla::ipc::IPCResult RecvInitProfiler(
Endpoint<mozilla::PProfilerChild>&& aEndpoint) override;
void CleanUp(); void CleanUp();
void DestroySocketProcessBridgeParent(ProcessId aId); void DestroySocketProcessBridgeParent(ProcessId aId);
@ -45,6 +51,10 @@ class SocketProcessChild final : public PSocketProcessChild {
// This table keeps SocketProcessBridgeParent alive in socket process. // This table keeps SocketProcessBridgeParent alive in socket process.
nsRefPtrHashtable<nsUint32HashKey, SocketProcessBridgeParent> nsRefPtrHashtable<nsUint32HashKey, SocketProcessBridgeParent>
mSocketProcessBridgeParentMap; mSocketProcessBridgeParentMap;
#ifdef MOZ_GECKO_PROFILER
RefPtr<ChildProfilerController> mProfilerController;
#endif
}; };
} // namespace net } // namespace net

Просмотреть файл

@ -9,6 +9,10 @@
#include "nsIObserverService.h" #include "nsIObserverService.h"
#include "SocketProcessParent.h" #include "SocketProcessParent.h"
#ifdef MOZ_GECKO_PROFILER
#include "ProfilerParent.h"
#endif
namespace mozilla { namespace mozilla {
namespace net { namespace net {
@ -213,6 +217,11 @@ void SocketProcessHost::InitAfterConnect(bool aSucceeded) {
DebugOnly<nsresult> result = ioService->GetOffline(&offline); DebugOnly<nsresult> result = ioService->GetOffline(&offline);
MOZ_ASSERT(NS_SUCCEEDED(result), "Failed getting offline?"); MOZ_ASSERT(NS_SUCCEEDED(result), "Failed getting offline?");
#ifdef MOZ_GECKO_PROFILER
Unused << GetActor()->SendInitProfiler(
ProfilerParent::CreateForProcess(GetActor()->OtherPid()));
#endif
Unused << GetActor()->SendSetOffline(offline); Unused << GetActor()->SendSetOffline(offline);
mOfflineObserver = new OfflineObserver(this); mOfflineObserver = new OfflineObserver(this);