Bug 1792567, part 1 - deCOM and remove unused methods in nsMacUtilsImpl. r=spohl

Differential Revision: https://phabricator.services.mozilla.com/D158203
This commit is contained in:
Andrew McCreight 2022-10-14 14:34:30 +00:00
parent d0f14ae8ef
commit bb892be228
6 changed files with 3 additions and 140 deletions

View File

@ -27,7 +27,6 @@ XPIDL_SOURCES += [
if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa":
XPIDL_SOURCES += [ XPIDL_SOURCES += [
"nsIMacPreferencesReader.idl", "nsIMacPreferencesReader.idl",
"nsIMacUtils.idl",
] ]
EXPORTS += [ EXPORTS += [
"nsObjCExceptions.h", "nsObjCExceptions.h",

View File

@ -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;
};

View File

@ -30,8 +30,6 @@
#endif #endif
#include <sys/sysctl.h> #include <sys/sysctl.h>
NS_IMPL_ISUPPORTS(nsMacUtilsImpl, nsIMacUtils)
using mozilla::StaticMutexAutoLock; using mozilla::StaticMutexAutoLock;
using mozilla::Unused; using mozilla::Unused;
@ -57,88 +55,6 @@ std::atomic<bool> nsMacUtilsImpl::sIsXULTranslated = false;
// Initialize with Unknown until we've checked if TCSM is available to set // Initialize with Unknown until we've checked if TCSM is available to set
Atomic<nsMacUtilsImpl::TCSMStatus> nsMacUtilsImpl::sTCSMStatus(TCSM_Unknown); Atomic<nsMacUtilsImpl::TCSMStatus> 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__) #if defined(MOZ_SANDBOX) || defined(__aarch64__)
// Get the path to the .app directory (aka bundle) for the parent process. // 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 // When executing in the child process, this is the outer .app (such as

View File

@ -7,7 +7,6 @@
#ifndef nsMacUtilsImpl_h___ #ifndef nsMacUtilsImpl_h___
#define nsMacUtilsImpl_h___ #define nsMacUtilsImpl_h___
#include "nsIMacUtils.h"
#include "nsString.h" #include "nsString.h"
#include "mozilla/Atomics.h" #include "mozilla/Atomics.h"
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
@ -18,11 +17,10 @@ using mozilla::Atomic;
using mozilla::StaticAutoPtr; using mozilla::StaticAutoPtr;
using mozilla::StaticMutex; using mozilla::StaticMutex;
class nsMacUtilsImpl final : public nsIMacUtils { class nsIFile;
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIMACUTILS
class nsMacUtilsImpl final {
public:
nsMacUtilsImpl() {} nsMacUtilsImpl() {}
// Return the repo directory and the repo object directory respectively. // Return the repo directory and the repo object directory respectively.
@ -59,13 +57,6 @@ class nsMacUtilsImpl final : public nsIMacUtils {
private: private:
~nsMacUtilsImpl() {} ~nsMacUtilsImpl() {}
nsresult GetArchString(nsAString& aArchString);
// A string containing a "-" delimited list of architectures
// in our binary.
nsString mBinaryArchs;
#if defined(MOZ_SANDBOX) || defined(__aarch64__) #if defined(MOZ_SANDBOX) || defined(__aarch64__)
// Cache the appDir returned from GetAppPath to avoid doing I/O // Cache the appDir returned from GetAppPath to avoid doing I/O
static StaticAutoPtr<nsCString> sCachedAppPath static StaticAutoPtr<nsCString> sCachedAppPath
@ -94,14 +85,4 @@ class nsMacUtilsImpl final : public nsIMacUtils {
#endif #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___ */ #endif /* nsMacUtilsImpl_h___ */

View File

@ -127,7 +127,6 @@
#ifdef MOZ_WIDGET_COCOA #ifdef MOZ_WIDGET_COCOA
# include "nsILocalFileMac.h" # include "nsILocalFileMac.h"
# include "nsIMacUtils.h"
#endif #endif
// xpcom/glue utility headers // xpcom/glue utility headers

View File

@ -255,10 +255,4 @@ if buildconfig.substs['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
'type': 'nsMacPreferencesReader', 'type': 'nsMacPreferencesReader',
'headers': ['mozilla/nsMacPreferencesReader.h'], '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'],
},
] ]