From 8dd16259287f58f9273002717ec4d27e97127719 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:43:14 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- xpcom/base/MemoryTelemetry.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'xpcom/base/MemoryTelemetry.h') diff --git a/xpcom/base/MemoryTelemetry.h b/xpcom/base/MemoryTelemetry.h index b7c7fe8ad6..f8c4bebb1a 100644 --- a/xpcom/base/MemoryTelemetry.h +++ b/xpcom/base/MemoryTelemetry.h @@ -8,6 +8,7 @@ #define mozilla_MemoryTelemetry_h #include "mozilla/TimeStamp.h" +#include "mozilla/Maybe.h" #include "mozilla/Result.h" #include "nsIObserver.h" #include "nsITimer.h" @@ -40,10 +41,14 @@ class MemoryTelemetry final : public nsIObserver, const std::function& aCompletionCallback = nullptr); /** - * Does expensive initialization, which should happen only after startup has - * completed, and the event loop is idle. + * Called to signal that we can begin collecting telemetry. */ - nsresult DelayedInit(); + void DelayedInit(); + + /** + * Notify that the browser is active and telemetry should be recorded soon. + */ + void Poke(); nsresult Shutdown(); @@ -57,14 +62,19 @@ class MemoryTelemetry final : public nsIObserver, static Result GetOpenTabsCount(); void GatherTotalMemory(); - nsresult FinishGatheringTotalMemory(int64_t aTotalMemory, + nsresult FinishGatheringTotalMemory(Maybe aTotalMemory, const nsTArray& aChildSizes); nsCOMPtr mThreadPool; bool mGatheringTotalMemory = false; - TimeStamp mLastPoll{}; + TimeStamp mLastRun{}; + TimeStamp mLastPoke{}; + nsCOMPtr mTimer; + + // True if startup is finished and it's okay to start gathering telemetry. + bool mCanRun = false; }; } // namespace mozilla -- cgit v1.2.3