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"
|
2019-08-02 15:55:38 +03:00
|
|
|
#include "mozilla/LazyIdleThread.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
|
|
|
|
|
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 {
|
|
|
|
bool isWow64;
|
|
|
|
bool isWowARM64;
|
2020-04-09 22:33:13 +03:00
|
|
|
int32_t cpuCount;
|
|
|
|
int32_t cpuCores;
|
2019-12-31 19:28:18 +03:00
|
|
|
nsCString cpuVendor;
|
2020-04-09 22:33:13 +03:00
|
|
|
int32_t cpuFamily;
|
|
|
|
int32_t cpuModel;
|
|
|
|
int32_t cpuStepping;
|
|
|
|
int32_t l2cacheKB;
|
|
|
|
int32_t l3cacheKB;
|
|
|
|
int32_t cpuSpeed;
|
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_ */
|