tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 237d40f6fbccc5c2e460bf0b0760797e3381ef88
parent f320908698fa6febcb43357ef3155a8988d65b40
Author: serge-sans-paille <sguelton@mozilla.com>
Date:   Mon,  3 Nov 2025 08:23:54 +0000

Bug 1997809 - Turn MOZ_RUNINIT UniquePtr initialization into MOZ_CONSTINIT r=emilio,media-playback-reviewers,karlt

UniquePtr is std::unique_ptr and its default constructor is constexpr.

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

Diffstat:
Mbrowser/app/nsBrowserApp.cpp | 2+-
Mdom/localstorage/ActorsParent.cpp | 2+-
Mdom/media/ExternalEngineStateMachine.cpp | 10+++++++---
Mdom/media/gtest/TestMediaDataDecoder.cpp | 4++--
Mdom/media/platforms/wmf/WMF.h | 3++-
Mdom/media/webrtc/tests/fuzztests/sdp_parser_libfuzz.cpp | 2+-
Mmozglue/android/APKOpen.cpp | 2+-
7 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/browser/app/nsBrowserApp.cpp b/browser/app/nsBrowserApp.cpp @@ -194,7 +194,7 @@ static bool HasFlag(int argc, char* argv[], const char* s) { return false; } -MOZ_RUNINIT Bootstrap::UniquePtr gBootstrap; +MOZ_CONSTINIT Bootstrap::UniquePtr gBootstrap; static int do_main(int argc, char* argv[], char* envp[]) { // Allow firefox.exe to launch XULRunner apps via -app <application.ini> diff --git a/dom/localstorage/ActorsParent.cpp b/dom/localstorage/ActorsParent.cpp @@ -2835,7 +2835,7 @@ using PrivateDatastoreHashtable = // event of an (unlikely) race where the private browsing windows are still // being torn down, will cause the Datastore to be discarded when the last // window actually goes away. -MOZ_RUNINIT UniquePtr<PrivateDatastoreHashtable> gPrivateDatastores; +MOZ_CONSTINIT UniquePtr<PrivateDatastoreHashtable> gPrivateDatastores; using DatabaseArray = nsTArray<Database*>; diff --git a/dom/media/ExternalEngineStateMachine.cpp b/dom/media/ExternalEngineStateMachine.cpp @@ -130,14 +130,18 @@ class ProcessCrashMonitor final { return sCrashMonitor.get(); } - static inline StaticMutex sMutex; - static inline MOZ_RUNINIT UniquePtr<ProcessCrashMonitor> sCrashMonitor; - static inline Atomic<bool> sIsShutdown{false}; + static StaticMutex sMutex; + static UniquePtr<ProcessCrashMonitor> sCrashMonitor; + static Atomic<bool> sIsShutdown; uint32_t mCrashNums; uint32_t mMaxCrashes; }; +StaticMutex ProcessCrashMonitor::sMutex; +MOZ_CONSTINIT UniquePtr<ProcessCrashMonitor> ProcessCrashMonitor::sCrashMonitor; +Atomic<bool> ProcessCrashMonitor::sIsShutdown{false}; + /* static */ const char* ExternalEngineStateMachine::StateToStr(State aNextState) { #define STATE_TO_STR(state) \ diff --git a/dom/media/gtest/TestMediaDataDecoder.cpp b/dom/media/gtest/TestMediaDataDecoder.cpp @@ -45,8 +45,8 @@ class PropertyTest : public ::testing::TestWithParam<ParamType> { }; MOZ_RUNINIT RefPtr<PDMFactory> PropertyTest::sFactory; MOZ_RUNINIT RefPtr<TaskQueue> PropertyTest::sTaskQueue; -MOZ_RUNINIT UniquePtr<VideoInfo> PropertyTest::sAVCInfo; -MOZ_RUNINIT UniquePtr<VideoInfo> PropertyTest::sVP9Info; +MOZ_CONSTINIT UniquePtr<VideoInfo> PropertyTest::sAVCInfo; +MOZ_CONSTINIT UniquePtr<VideoInfo> PropertyTest::sVP9Info; void CheckEquals(VideoInfo& aVideoInfo, MDD::PropertyName aPropertyName, const Maybe<MDD::PropertyValue>&& aExpectedValue, diff --git a/dom/media/platforms/wmf/WMF.h b/dom/media/platforms/wmf/WMF.h @@ -141,7 +141,8 @@ class MediaFoundationInitializer final { // WMF from threads with the same COM compartment model. HRESULT MFShutdown(); - MOZ_RUNINIT static inline UniquePtr<MediaFoundationInitializer> sInitializer; + MOZ_CONSTINIT static inline UniquePtr<MediaFoundationInitializer> + sInitializer; static inline StaticMutex sCreateMutex; static inline Atomic<bool> sIsShutdown{false}; const bool mHasInitialized; diff --git a/dom/media/webrtc/tests/fuzztests/sdp_parser_libfuzz.cpp b/dom/media/webrtc/tests/fuzztests/sdp_parser_libfuzz.cpp @@ -12,7 +12,7 @@ using namespace mozilla; -MOZ_RUNINIT static mozilla::UniquePtr<SdpParser::Results> sdpPtr; +MOZ_CONSTINIT static mozilla::UniquePtr<SdpParser::Results> sdpPtr; MOZ_RUNINIT static SipccSdpParser mParser; int FuzzingInitSdpParser(int* argc, char*** argv) { return 0; } diff --git a/mozglue/android/APKOpen.cpp b/mozglue/android/APKOpen.cpp @@ -135,7 +135,7 @@ void abortThroughJava(const char* msg) { env->PopLocalFrame(nullptr); } -MOZ_RUNINIT Bootstrap::UniquePtr gBootstrap; +MOZ_CONSTINIT Bootstrap::UniquePtr gBootstrap; #ifndef MOZ_FOLD_LIBS static void* sqlite_handle = nullptr; static void* nspr_handle = nullptr;