Bug 1686838 [wpt PR 27194] - [webcodecs] Deprecate VideoFrame.destroy()., a=testonly
[gecko.git] / xpcom / base / nsMacUtilsImpl.h
blobdd0afa2305465c808adcce4eddcd792405773d25
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsMacUtilsImpl_h___
8 #define nsMacUtilsImpl_h___
10 #include "nsIMacUtils.h"
11 #include "nsString.h"
12 #include "mozilla/Atomics.h"
13 #include "mozilla/Attributes.h"
14 #include "mozilla/StaticMutex.h"
15 #include "mozilla/StaticPtr.h"
17 using mozilla::Atomic;
18 using mozilla::StaticAutoPtr;
19 using mozilla::StaticMutex;
21 class nsMacUtilsImpl final : public nsIMacUtils {
22 public:
23 NS_DECL_ISUPPORTS
24 NS_DECL_NSIMACUTILS
26 nsMacUtilsImpl() {}
28 // Return the repo directory and the repo object directory respectively.
29 // These should only be used on Mac developer builds to determine the path
30 // to the repo or object directory.
31 static nsresult GetRepoDir(nsIFile** aRepoDir);
32 static nsresult GetObjDir(nsIFile** aObjDir);
34 #if defined(MOZ_SANDBOX)
35 static bool GetAppPath(nsCString& aAppPath);
36 # ifdef DEBUG
37 static nsresult GetBloatLogDir(nsCString& aDirectoryPath);
38 static nsresult GetDirectoryPath(const char* aPath,
39 nsCString& aDirectoryPath);
40 # endif /* DEBUG */
41 #endif /* MOZ_SANDBOX */
43 static void EnableTCSMIfAvailable();
44 static bool IsTCSMAvailable();
45 static uint32_t GetPhysicalCPUCount();
46 static nsresult GetArchitecturesForBundle(uint32_t* aArchMask);
47 static nsresult GetArchitecturesForBinary(const char* aPath,
48 uint32_t* aArchMask);
50 #if defined(__aarch64__)
51 // Pre-translate binaries to avoid translation delays when launching
52 // x64 child process instances for the first time. i.e. on first launch
53 // after installation or after an update. Translations are cached so
54 // repeated launches of the binaries do not encounter delays.
55 static int PreTranslateXUL();
56 static int PreTranslateBinary(nsCString aBinaryPath);
57 #endif
59 private:
60 ~nsMacUtilsImpl() {}
62 nsresult GetArchString(nsAString& aArchString);
64 // A string containing a "-" delimited list of architectures
65 // in our binary.
66 nsString mBinaryArchs;
68 #if defined(MOZ_SANDBOX)
69 // Cache the appDir returned from GetAppPath to avoid doing I/O
70 static StaticAutoPtr<nsCString> sCachedAppPath;
71 // For thread safe setting/checking of sCachedAppPath
72 static StaticMutex sCachedAppPathMutex;
73 // Utility method to call ClearOnShutdown() on the main thread
74 static nsresult ClearCachedAppPathOnShutdown();
75 #endif
77 // The cached machine architectures of the .app bundle which can
78 // be multiple architectures for universal binaries.
79 static std::atomic<uint32_t> sBundleArchMaskAtomic;
81 #if defined(__aarch64__)
82 // Limit XUL translation to one attempt
83 static std::atomic<bool> sIsXULTranslated;
84 #endif
86 enum TCSMStatus { TCSM_Unknown = 0, TCSM_Available, TCSM_Unavailable };
87 static mozilla::Atomic<nsMacUtilsImpl::TCSMStatus> sTCSMStatus;
89 static nsresult EnableTCSM();
90 #if defined(DEBUG)
91 static bool IsTCSMEnabled();
92 #endif
95 // Global singleton service
96 // 697BD3FD-43E5-41CE-AD5E-C339175C0818
97 #define NS_MACUTILSIMPL_CID \
98 { \
99 0x697BD3FD, 0x43E5, 0x41CE, { \
100 0xAD, 0x5E, 0xC3, 0x39, 0x17, 0x5C, 0x08, 0x18 \
103 #define NS_MACUTILSIMPL_CONTRACTID "@mozilla.org/xpcom/mac-utils;1"
105 #endif /* nsMacUtilsImpl_h___ */