From bb892be2286fa0d92b7985aabaccafb2d8301123 Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Fri, 14 Oct 2022 14:34:30 +0000 Subject: [PATCH] Bug 1792567, part 1 - deCOM and remove unused methods in nsMacUtilsImpl. r=spohl Differential Revision: https://phabricator.services.mozilla.com/D158203 --- xpcom/base/moz.build | 1 - xpcom/base/nsIMacUtils.idl | 26 ----------- xpcom/base/nsMacUtilsImpl.cpp | 84 ----------------------------------- xpcom/base/nsMacUtilsImpl.h | 25 ++--------- xpcom/build/XPCOM.h | 1 - xpcom/build/components.conf | 6 --- 6 files changed, 3 insertions(+), 140 deletions(-) delete mode 100644 xpcom/base/nsIMacUtils.idl diff --git a/xpcom/base/moz.build b/xpcom/base/moz.build index b1f2295a778b..f83c3e213046 100644 --- a/xpcom/base/moz.build +++ b/xpcom/base/moz.build @@ -27,7 +27,6 @@ XPIDL_SOURCES += [ if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": XPIDL_SOURCES += [ "nsIMacPreferencesReader.idl", - "nsIMacUtils.idl", ] EXPORTS += [ "nsObjCExceptions.h", diff --git a/xpcom/base/nsIMacUtils.idl b/xpcom/base/nsIMacUtils.idl deleted file mode 100644 index c68f21a738e8..000000000000 --- a/xpcom/base/nsIMacUtils.idl +++ /dev/null @@ -1,26 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsISupports.idl" - -/** - * nsIMacUtils: Generic globally-available Mac-specific utilities. - */ - -[uuid(5E9072D7-FF95-455E-9466-8AF9841A72EC)] -interface nsIMacUtils : nsISupports -{ - /** - * Returns a string containing a list of architectures delimited - * by "-". Architecture sets are always in the same order: - * ppc > i386 > ppc64 > x86_64 > (future additions) - */ - readonly attribute AString architecturesInBinary; - - /** - * True when running under binary translation (Rosetta). - */ - readonly attribute boolean isTranslated; -}; diff --git a/xpcom/base/nsMacUtilsImpl.cpp b/xpcom/base/nsMacUtilsImpl.cpp index 818ad4c1f24e..5140f9fccf63 100644 --- a/xpcom/base/nsMacUtilsImpl.cpp +++ b/xpcom/base/nsMacUtilsImpl.cpp @@ -30,8 +30,6 @@ #endif #include -NS_IMPL_ISUPPORTS(nsMacUtilsImpl, nsIMacUtils) - using mozilla::StaticMutexAutoLock; using mozilla::Unused; @@ -57,88 +55,6 @@ std::atomic nsMacUtilsImpl::sIsXULTranslated = false; // Initialize with Unknown until we've checked if TCSM is available to set Atomic nsMacUtilsImpl::sTCSMStatus(TCSM_Unknown); -nsresult nsMacUtilsImpl::GetArchString(nsAString& aArchString) { - if (!mBinaryArchs.IsEmpty()) { - aArchString.Assign(mBinaryArchs); - return NS_OK; - } - - uint32_t archMask = base::PROCESS_ARCH_INVALID; - nsresult rv = GetArchitecturesForBundle(&archMask); - NS_ENSURE_SUCCESS(rv, rv); - - // The order in the string must always be the same so - // don't do this in the loop. - if (archMask & base::PROCESS_ARCH_PPC) { - mBinaryArchs.AppendLiteral("ppc"); - } - - if (archMask & base::PROCESS_ARCH_I386) { - if (!mBinaryArchs.IsEmpty()) { - mBinaryArchs.Append('-'); - } - mBinaryArchs.AppendLiteral("i386"); - } - - if (archMask & base::PROCESS_ARCH_PPC_64) { - if (!mBinaryArchs.IsEmpty()) { - mBinaryArchs.Append('-'); - } - mBinaryArchs.AppendLiteral("ppc64"); - } - - if (archMask & base::PROCESS_ARCH_X86_64) { - if (!mBinaryArchs.IsEmpty()) { - mBinaryArchs.Append('-'); - } - mBinaryArchs.AppendLiteral("x86_64"); - } - - if (archMask & base::PROCESS_ARCH_ARM_64) { - if (!mBinaryArchs.IsEmpty()) { - mBinaryArchs.Append('-'); - } - mBinaryArchs.AppendLiteral("arm64"); - } - - aArchString.Truncate(); - aArchString.Assign(mBinaryArchs); - - return (aArchString.IsEmpty() ? NS_ERROR_FAILURE : NS_OK); -} - -NS_IMETHODIMP -nsMacUtilsImpl::GetArchitecturesInBinary(nsAString& aArchString) { - return GetArchString(aArchString); -} - -// True when running under binary translation (Rosetta). -NS_IMETHODIMP -nsMacUtilsImpl::GetIsTranslated(bool* aIsTranslated) { -#ifdef __ppc__ - static bool sInitialized = false; - - // Initialize sIsNative to 1. If the sysctl fails because it doesn't - // exist, then translation is not possible, so the process must not be - // running translated. - static int32_t sIsNative = 1; - - if (!sInitialized) { - size_t sz = sizeof(sIsNative); - sysctlbyname("sysctl.proc_native", &sIsNative, &sz, nullptr, 0); - sInitialized = true; - } - - *aIsTranslated = !sIsNative; -#else - // Translation only exists for ppc code. Other architectures aren't - // translated. - *aIsTranslated = false; -#endif - - return NS_OK; -} - #if defined(MOZ_SANDBOX) || defined(__aarch64__) // Get the path to the .app directory (aka bundle) for the parent process. // When executing in the child process, this is the outer .app (such as diff --git a/xpcom/base/nsMacUtilsImpl.h b/xpcom/base/nsMacUtilsImpl.h index 237025e5258c..2ae5fc5dc361 100644 --- a/xpcom/base/nsMacUtilsImpl.h +++ b/xpcom/base/nsMacUtilsImpl.h @@ -7,7 +7,6 @@ #ifndef nsMacUtilsImpl_h___ #define nsMacUtilsImpl_h___ -#include "nsIMacUtils.h" #include "nsString.h" #include "mozilla/Atomics.h" #include "mozilla/Attributes.h" @@ -18,11 +17,10 @@ using mozilla::Atomic; using mozilla::StaticAutoPtr; using mozilla::StaticMutex; -class nsMacUtilsImpl final : public nsIMacUtils { - public: - NS_DECL_ISUPPORTS - NS_DECL_NSIMACUTILS +class nsIFile; +class nsMacUtilsImpl final { + public: nsMacUtilsImpl() {} // Return the repo directory and the repo object directory respectively. @@ -59,13 +57,6 @@ class nsMacUtilsImpl final : public nsIMacUtils { private: ~nsMacUtilsImpl() {} - - nsresult GetArchString(nsAString& aArchString); - - // A string containing a "-" delimited list of architectures - // in our binary. - nsString mBinaryArchs; - #if defined(MOZ_SANDBOX) || defined(__aarch64__) // Cache the appDir returned from GetAppPath to avoid doing I/O static StaticAutoPtr sCachedAppPath @@ -94,14 +85,4 @@ class nsMacUtilsImpl final : public nsIMacUtils { #endif }; -// Global singleton service -// 697BD3FD-43E5-41CE-AD5E-C339175C0818 -#define NS_MACUTILSIMPL_CID \ - { \ - 0x697BD3FD, 0x43E5, 0x41CE, { \ - 0xAD, 0x5E, 0xC3, 0x39, 0x17, 0x5C, 0x08, 0x18 \ - } \ - } -#define NS_MACUTILSIMPL_CONTRACTID "@mozilla.org/xpcom/mac-utils;1" - #endif /* nsMacUtilsImpl_h___ */ diff --git a/xpcom/build/XPCOM.h b/xpcom/build/XPCOM.h index 78e68dc809e7..1a04091dc4b4 100644 --- a/xpcom/build/XPCOM.h +++ b/xpcom/build/XPCOM.h @@ -127,7 +127,6 @@ #ifdef MOZ_WIDGET_COCOA # include "nsILocalFileMac.h" -# include "nsIMacUtils.h" #endif // xpcom/glue utility headers diff --git a/xpcom/build/components.conf b/xpcom/build/components.conf index 186f7be12c0d..5ef9ac4ebe01 100644 --- a/xpcom/build/components.conf +++ b/xpcom/build/components.conf @@ -255,10 +255,4 @@ if buildconfig.substs['MOZ_WIDGET_TOOLKIT'] == 'cocoa': 'type': 'nsMacPreferencesReader', 'headers': ['mozilla/nsMacPreferencesReader.h'], }, - { - 'cid': '{697bd3fd-43e5-41ce-ad5e-c339175c0818}', - 'contract_ids': ['@mozilla.org/xpcom/mac-utils;1'], - 'type': 'nsMacUtilsImpl', - 'headers': ['/xpcom/base/nsMacUtilsImpl.h'], - }, ]