Bug 1867190 - Add prefs for PHC probablities r=glandium
[gecko.git] / xpcom / base / nsSystemInfo.h
blob9d47b5d4f6308b264de6cae717d475fe3f8a38d6
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 nsCString cpuVendor;
60 nsCString cpuName;
61 int32_t cpuFamily = 0;
62 int32_t cpuModel = 0;
63 int32_t cpuStepping = 0;
64 int32_t l2cacheKB = 0;
65 int32_t l3cacheKB = 0;
66 int32_t cpuSpeed = 0;
69 typedef mozilla::MozPromise<DiskInfo, nsresult, /* IsExclusive */ false>
70 DiskInfoPromise;
72 typedef mozilla::MozPromise<nsAutoString, nsresult, /* IsExclusive */ false>
73 CountryCodePromise;
75 typedef mozilla::MozPromise<OSInfo, nsresult, /* IsExclusive */ false>
76 OSInfoPromise;
78 typedef mozilla::MozPromise<ProcessInfo, nsresult, /* IsExclusive */ false>
79 ProcessInfoPromise;
81 // Synchronous info collection, avoid calling it from the main thread, consider
82 // using the promise-based `nsISystemInfo::GetProcessInfo()` instead.
83 // Note that only known fields will be written.
84 nsresult CollectProcessInfo(ProcessInfo& info);
86 class nsSystemInfo final : public nsISystemInfo, public nsHashPropertyBag {
87 public:
88 NS_DECL_ISUPPORTS_INHERITED
89 NS_DECL_NSISYSTEMINFO
91 nsSystemInfo();
93 nsresult Init();
95 // Slot for NS_InitXPCOM to pass information to nsSystemInfo::Init.
96 // See comments above the variable definition and in NS_InitXPCOM.
97 static uint32_t gUserUmask;
99 #ifdef MOZ_WIDGET_ANDROID
100 static void GetAndroidSystemInfo(mozilla::dom::AndroidSystemInfo* aInfo);
102 protected:
103 void SetupAndroidInfo(const mozilla::dom::AndroidSystemInfo&);
104 #endif
106 protected:
107 void SetInt32Property(const nsAString& aPropertyName, const int32_t aValue);
108 void SetUint32Property(const nsAString& aPropertyName, const uint32_t aValue);
109 void SetUint64Property(const nsAString& aPropertyName, const uint64_t aValue);
111 private:
112 ~nsSystemInfo();
114 RefPtr<DiskInfoPromise> mDiskInfoPromise;
115 RefPtr<CountryCodePromise> mCountryCodePromise;
116 RefPtr<OSInfoPromise> mOSInfoPromise;
117 RefPtr<ProcessInfoPromise> mProcessInfoPromise;
118 RefPtr<nsISerialEventTarget> mBackgroundET;
119 RefPtr<nsISerialEventTarget> GetBackgroundTarget();
122 #define NS_SYSTEMINFO_CONTRACTID "@mozilla.org/system-info;1"
123 #define NS_SYSTEMINFO_CID \
125 0xd962398a, 0x99e5, 0x49b2, { \
126 0x85, 0x7a, 0xc1, 0x59, 0x04, 0x9c, 0x7f, 0x6c \
130 #endif /* _NSSYSTEMINFO_H_ */