Bug 1932613 - temporarily disable browser_ml_end_to_end.js for permanent failures...
[gecko.git] / xpcom / base / nsSystemInfo.h
blob09311908b8d553943e0b81b3ba1cde82f8fdec64
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 _NSSYSTEMINFO_H_
8 #define _NSSYSTEMINFO_H_
10 #include "nsHashPropertyBag.h"
11 #include "nsISystemInfo.h"
12 #include "mozilla/MozPromise.h"
14 #ifdef MOZ_WIDGET_ANDROID
15 # include "mozilla/dom/PContent.h"
16 #endif // MOZ_WIDGET_ANDROID
18 #if defined(XP_WIN)
19 # include <inspectable.h>
21 // The UUID comes from winrt/windows.system.profile.idl
22 // in the Windows SDK
23 MIDL_INTERFACE("7D1D81DB-8D63-4789-9EA5-DDCF65A94F3C")
24 IWindowsIntegrityPolicyStatics : public IInspectable {
25 public:
26 virtual HRESULT STDMETHODCALLTYPE get_IsEnabled(bool* value) = 0;
28 #endif
30 class nsISerialEventTarget;
32 struct FolderDiskInfo {
33 nsCString model;
34 nsCString revision;
35 bool isSSD;
38 struct DiskInfo {
39 FolderDiskInfo binary;
40 FolderDiskInfo profile;
41 FolderDiskInfo system;
44 struct OSInfo {
45 uint32_t installYear;
46 bool hasSuperfetch;
47 bool hasPrefetch;
50 struct ProcessInfo {
51 bool isWow64 = false;
52 bool isWowARM64 = false;
53 // Whether or not the system is Windows 10 or 11 in S Mode.
54 // S Mode existed prior to us being able to query it, so this
55 // is unreliable on Windows versions prior to 1810.
56 bool isWindowsSMode = false;
57 int32_t cpuCount = 0;
58 int32_t cpuCores = 0;
59 int32_t cpuPCount = 0;
60 int32_t cpuMCount = 0;
61 int32_t cpuECount = 0;
62 nsCString cpuVendor;
63 nsCString cpuName;
64 int32_t cpuFamily = 0;
65 int32_t cpuModel = 0;
66 int32_t cpuStepping = 0;
67 int32_t l2cacheKB = 0;
68 int32_t l3cacheKB = 0;
69 int32_t cpuSpeed = 0;
72 typedef mozilla::MozPromise<DiskInfo, nsresult, /* IsExclusive */ false>
73 DiskInfoPromise;
75 typedef mozilla::MozPromise<nsAutoString, nsresult, /* IsExclusive */ false>
76 CountryCodePromise;
78 typedef mozilla::MozPromise<OSInfo, nsresult, /* IsExclusive */ false>
79 OSInfoPromise;
81 typedef mozilla::MozPromise<ProcessInfo, nsresult, /* IsExclusive */ false>
82 ProcessInfoPromise;
84 // Synchronous info collection, avoid calling it from the main thread, consider
85 // using the promise-based `nsISystemInfo::GetProcessInfo()` instead.
86 // Note that only known fields will be written.
87 nsresult CollectProcessInfo(ProcessInfo& info);
89 class nsSystemInfo final : public nsISystemInfo, public nsHashPropertyBag {
90 public:
91 NS_DECL_ISUPPORTS_INHERITED
92 NS_DECL_NSISYSTEMINFO
94 nsSystemInfo();
96 nsresult Init();
98 // Slot for NS_InitXPCOM to pass information to nsSystemInfo::Init.
99 // See comments above the variable definition and in NS_InitXPCOM.
100 static uint32_t gUserUmask;
102 #ifdef MOZ_WIDGET_ANDROID
103 static void GetAndroidSystemInfo(mozilla::dom::AndroidSystemInfo* aInfo);
105 protected:
106 void SetupAndroidInfo(const mozilla::dom::AndroidSystemInfo&);
107 #endif
109 protected:
110 void SetInt32Property(const nsAString& aPropertyName, const int32_t aValue);
111 void SetUint32Property(const nsAString& aPropertyName, const uint32_t aValue);
112 void SetUint64Property(const nsAString& aPropertyName, const uint64_t aValue);
114 private:
115 ~nsSystemInfo();
117 RefPtr<DiskInfoPromise> mDiskInfoPromise;
118 RefPtr<CountryCodePromise> mCountryCodePromise;
119 RefPtr<OSInfoPromise> mOSInfoPromise;
120 RefPtr<ProcessInfoPromise> mProcessInfoPromise;
121 RefPtr<nsISerialEventTarget> mBackgroundET;
122 RefPtr<nsISerialEventTarget> GetBackgroundTarget();
125 #define NS_SYSTEMINFO_CONTRACTID "@mozilla.org/system-info;1"
126 #define NS_SYSTEMINFO_CID \
128 0xd962398a, 0x99e5, 0x49b2, { \
129 0x85, 0x7a, 0xc1, 0x59, 0x04, 0x9c, 0x7f, 0x6c \
133 #endif /* _NSSYSTEMINFO_H_ */