2014-05-05 21:30:39 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2000-01-27 12:40:17 +03:00
|
|
|
|
2006-07-06 10:32:03 +04:00
|
|
|
#ifndef _NSSYSTEMINFO_H_
|
|
|
|
#define _NSSYSTEMINFO_H_
|
2000-01-27 12:40:17 +03:00
|
|
|
|
2006-07-06 10:32:03 +04:00
|
|
|
#include "nsHashPropertyBag.h"
|
2019-06-12 18:56:59 +03:00
|
|
|
#include "nsISystemInfo.h"
|
|
|
|
#include "mozilla/MozPromise.h"
|
2014-07-01 07:48:57 +04:00
|
|
|
|
2015-11-04 22:08:14 +03:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
# include "mozilla/dom/PContent.h"
|
|
|
|
#endif // MOZ_WIDGET_ANDROID
|
|
|
|
|
2021-11-16 18:11:32 +03:00
|
|
|
#if defined(XP_WIN)
|
|
|
|
# include <inspectable.h>
|
|
|
|
|
|
|
|
// The UUID comes from winrt/windows.system.profile.idl
|
|
|
|
// in the Windows SDK
|
|
|
|
MIDL_INTERFACE("7D1D81DB-8D63-4789-9EA5-DDCF65A94F3C")
|
|
|
|
IWindowsIntegrityPolicyStatics : public IInspectable {
|
|
|
|
public:
|
|
|
|
virtual HRESULT STDMETHODCALLTYPE get_IsEnabled(bool* value) = 0;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2020-11-23 19:12:02 +03:00
|
|
|
class nsISerialEventTarget;
|
|
|
|
|
2019-06-12 18:56:59 +03:00
|
|
|
struct FolderDiskInfo {
|
|
|
|
nsCString model;
|
|
|
|
nsCString revision;
|
|
|
|
bool isSSD;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DiskInfo {
|
|
|
|
FolderDiskInfo binary;
|
|
|
|
FolderDiskInfo profile;
|
|
|
|
FolderDiskInfo system;
|
|
|
|
};
|
|
|
|
|
2019-09-20 23:52:32 +03:00
|
|
|
struct OSInfo {
|
|
|
|
uint32_t installYear;
|
2020-02-25 22:28:42 +03:00
|
|
|
bool hasSuperfetch;
|
|
|
|
bool hasPrefetch;
|
2019-09-20 23:52:32 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ProcessInfo {
|
Bug 1723945 - nsSystemInfo.cpp: On non-x86_{32,64} Linux, CollectProcessInfo can silently fail and insert junk data into the process. r=nika.
This doesn't happen on any P1 platforms. It affects all non-x86/x86_64
Linuxes though, in this example, aarch64-linux. It causes Valgrind runs on
aarch64-linux to report hundreds of errors. In short, attempts to read
various fields from /proc/cpuinfo fail, because `CollectProcessInfo()` assumes
that it is looking at a /proc/cpuinfo file from a x86_{32,64} target, but its
format is very different on non x86 targets. Unfortunately the parsing fails,
but the failure is not detected, resulting in the uninitialised fields being
treated as if they contained real data.
The simple fix here is just to give default values for these fields.
Differential Revision: https://phabricator.services.mozilla.com/D123189
2021-09-13 12:43:36 +03:00
|
|
|
bool isWow64 = false;
|
|
|
|
bool isWowARM64 = false;
|
2021-11-16 18:11:32 +03:00
|
|
|
// Whether or not the system is Windows 10 or 11 in S Mode.
|
|
|
|
// S Mode existed prior to us being able to query it, so this
|
|
|
|
// is unreliable on Windows versions prior to 1810.
|
|
|
|
bool isWindowsSMode = false;
|
Bug 1723945 - nsSystemInfo.cpp: On non-x86_{32,64} Linux, CollectProcessInfo can silently fail and insert junk data into the process. r=nika.
This doesn't happen on any P1 platforms. It affects all non-x86/x86_64
Linuxes though, in this example, aarch64-linux. It causes Valgrind runs on
aarch64-linux to report hundreds of errors. In short, attempts to read
various fields from /proc/cpuinfo fail, because `CollectProcessInfo()` assumes
that it is looking at a /proc/cpuinfo file from a x86_{32,64} target, but its
format is very different on non x86 targets. Unfortunately the parsing fails,
but the failure is not detected, resulting in the uninitialised fields being
treated as if they contained real data.
The simple fix here is just to give default values for these fields.
Differential Revision: https://phabricator.services.mozilla.com/D123189
2021-09-13 12:43:36 +03:00
|
|
|
int32_t cpuCount = 0;
|
|
|
|
int32_t cpuCores = 0;
|
2019-12-31 19:28:18 +03:00
|
|
|
nsCString cpuVendor;
|
2022-11-01 23:22:23 +03:00
|
|
|
nsCString cpuName;
|
Bug 1723945 - nsSystemInfo.cpp: On non-x86_{32,64} Linux, CollectProcessInfo can silently fail and insert junk data into the process. r=nika.
This doesn't happen on any P1 platforms. It affects all non-x86/x86_64
Linuxes though, in this example, aarch64-linux. It causes Valgrind runs on
aarch64-linux to report hundreds of errors. In short, attempts to read
various fields from /proc/cpuinfo fail, because `CollectProcessInfo()` assumes
that it is looking at a /proc/cpuinfo file from a x86_{32,64} target, but its
format is very different on non x86 targets. Unfortunately the parsing fails,
but the failure is not detected, resulting in the uninitialised fields being
treated as if they contained real data.
The simple fix here is just to give default values for these fields.
Differential Revision: https://phabricator.services.mozilla.com/D123189
2021-09-13 12:43:36 +03:00
|
|
|
int32_t cpuFamily = 0;
|
|
|
|
int32_t cpuModel = 0;
|
|
|
|
int32_t cpuStepping = 0;
|
|
|
|
int32_t l2cacheKB = 0;
|
|
|
|
int32_t l3cacheKB = 0;
|
|
|
|
int32_t cpuSpeed = 0;
|
2019-09-20 23:52:32 +03:00
|
|
|
};
|
|
|
|
|
2019-06-12 18:56:59 +03:00
|
|
|
typedef mozilla::MozPromise<DiskInfo, nsresult, /* IsExclusive */ false>
|
|
|
|
DiskInfoPromise;
|
|
|
|
|
2019-08-02 15:55:38 +03:00
|
|
|
typedef mozilla::MozPromise<nsAutoString, nsresult, /* IsExclusive */ false>
|
|
|
|
CountryCodePromise;
|
|
|
|
|
2019-09-20 23:52:32 +03:00
|
|
|
typedef mozilla::MozPromise<OSInfo, nsresult, /* IsExclusive */ false>
|
|
|
|
OSInfoPromise;
|
|
|
|
|
|
|
|
typedef mozilla::MozPromise<ProcessInfo, nsresult, /* IsExclusive */ false>
|
|
|
|
ProcessInfoPromise;
|
|
|
|
|
2020-04-09 01:35:54 +03:00
|
|
|
// Synchronous info collection, avoid calling it from the main thread, consider
|
|
|
|
// using the promise-based `nsISystemInfo::GetProcessInfo()` instead.
|
|
|
|
// Note that only known fields will be written.
|
|
|
|
nsresult CollectProcessInfo(ProcessInfo& info);
|
|
|
|
|
2019-06-12 18:56:59 +03:00
|
|
|
class nsSystemInfo final : public nsISystemInfo, public nsHashPropertyBag {
|
2006-07-06 10:32:03 +04:00
|
|
|
public:
|
2014-07-01 07:48:57 +04:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2019-06-12 18:56:59 +03:00
|
|
|
NS_DECL_NSISYSTEMINFO
|
2014-07-01 07:48:57 +04:00
|
|
|
|
2014-05-05 21:30:39 +04:00
|
|
|
nsSystemInfo();
|
2000-01-27 12:40:17 +03:00
|
|
|
|
2014-05-05 21:30:39 +04:00
|
|
|
nsresult Init();
|
2000-01-27 12:40:17 +03:00
|
|
|
|
2019-03-15 09:38:09 +03:00
|
|
|
// Slot for NS_InitXPCOM to pass information to nsSystemInfo::Init.
|
|
|
|
// See comments above the variable definition and in NS_InitXPCOM.
|
2014-05-05 21:30:39 +04:00
|
|
|
static uint32_t gUserUmask;
|
2014-04-26 18:56:54 +04:00
|
|
|
|
2015-11-04 22:08:14 +03:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
static void GetAndroidSystemInfo(mozilla::dom::AndroidSystemInfo* aInfo);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-11-04 22:08:14 +03:00
|
|
|
protected:
|
|
|
|
void SetupAndroidInfo(const mozilla::dom::AndroidSystemInfo&);
|
|
|
|
#endif
|
|
|
|
|
2009-11-04 17:41:37 +03:00
|
|
|
protected:
|
2014-05-13 21:41:38 +04:00
|
|
|
void SetInt32Property(const nsAString& aPropertyName, const int32_t aValue);
|
|
|
|
void SetUint32Property(const nsAString& aPropertyName, const uint32_t aValue);
|
|
|
|
void SetUint64Property(const nsAString& aPropertyName, const uint64_t aValue);
|
2009-11-04 17:41:37 +03:00
|
|
|
|
2006-07-06 10:32:03 +04:00
|
|
|
private:
|
2014-05-05 21:30:39 +04:00
|
|
|
~nsSystemInfo();
|
2014-07-01 07:48:57 +04:00
|
|
|
|
2019-06-12 18:56:59 +03:00
|
|
|
RefPtr<DiskInfoPromise> mDiskInfoPromise;
|
2019-08-02 15:55:38 +03:00
|
|
|
RefPtr<CountryCodePromise> mCountryCodePromise;
|
2019-09-20 23:52:32 +03:00
|
|
|
RefPtr<OSInfoPromise> mOSInfoPromise;
|
|
|
|
RefPtr<ProcessInfoPromise> mProcessInfoPromise;
|
2020-01-28 18:06:17 +03:00
|
|
|
RefPtr<nsISerialEventTarget> mBackgroundET;
|
|
|
|
RefPtr<nsISerialEventTarget> GetBackgroundTarget();
|
2000-01-27 12:40:17 +03:00
|
|
|
};
|
|
|
|
|
2006-07-06 10:32:03 +04:00
|
|
|
#define NS_SYSTEMINFO_CONTRACTID "@mozilla.org/system-info;1"
|
|
|
|
#define NS_SYSTEMINFO_CID \
|
2018-11-30 13:46:48 +03:00
|
|
|
{ \
|
2006-07-06 10:32:03 +04:00
|
|
|
0xd962398a, 0x99e5, 0x49b2, { \
|
|
|
|
0x85, 0x7a, 0xc1, 0x59, 0x04, 0x9c, 0x7f, 0x6c \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* _NSSYSTEMINFO_H_ */
|