sys_info
类
- namespace base
- class SysInfo
函数
- 返回当前计算机上的逻辑处理器/内核数
1 |
static int NumberOfProcessors(); |
- 返回当前机器上物理内存的字节数
1 |
static int64_t AmountOfPhysicalMemory(); |
- 返回当前机器可用物理内存的字节数
1 |
static int64_t AmountOfAvailablePhysicalMemory(); |
- 返回此进程的虚拟内存的字节数。 回报零值表示可用虚拟机没有限制记忆
1 |
static int64_t AmountOfVirtualMemory(); |
- 返回当前计算机上的物理内存的兆字节数
1 2 3 |
static int AmountOfPhysicalMemoryMB() { return static_cast<int>(AmountOfPhysicalMemory() / 1024 /1024); } |
- 返回可用虚拟内存的兆字节数;如果为零,则返回零是无限的。
1 2 3 |
static int AmountOfVirtualMemoryMB() { return static_cast<int>(AmountOfVirtualMemory() / 1024 / 1024); } |
- 返回包含| path |的卷上的可用磁盘空间(以字节为单位),或-1(失败)
1 |
static int64_t AmountOfFreeDiskSpace(const FilePath& path); |
- 返回包含| path |或-1的卷上的总磁盘空间(以字节为单位)失败
1 |
static int64_t AmountOfTotalDiskSpace(const FilePath& path); |
- 系统正常运行时间
1 |
static TimeDelta Uptime(); |
- 返回当前机器型号的描述性字符串或为空。如果机器型号未知或发生错误,则为空字符串。
1 |
static std::string HardwareModelName(); |
- 通过| callback |返回 包含当前的机器制造商和型号描述性的UTF-8字符串的结构,
如果信息未知或发生错误则返回空字符串。
1 2 3 4 5 6 7 8 9 10 11 |
struct HardwareInfo { std::string manufacturer; std::string model; std::string serial_number; bool operator==(const HardwareInfo& rhs) const { return manufacturer == rhs.manufacturer && model == rhs.model && serial_number == rhs.serial_number; } }; static void GetHardwareInfo(base::OnceCallback<void(HardwareInfo)> callback); |
- 返回主机操作系统的名称
1 |
static std::string OperatingSystemName(); |
- 返回主机操作系统的版本
1 |
static std::string OperatingSystemVersion(); |
- 检索操作系统版本的详细数值
1 2 3 |
static void OperatingSystemVersionNumbers(int32_t* major_version, int32_t* minor_version, int32_t* bugfix_version); |
- 返回正在运行的操作系统的体系结构
1 |
static std::string OperatingSystemArchiecture(); |
- 返回系统的CPU型号名称,如果无法弄清楚,返回一个空串。
避免使用。使用cpu.h里面的相关接口来获取对应信息。
1 |
static std::string CPUModelName(); |
- 返回VM系统将占用的最小内存量(以字节为单位)分配
1 |
static size_t VMAllocationGranularity(); |
- 如果这是低端设备,则返回true。
低端设备是指设备总量很少的设备系统内存,通常<= 1GB。
1 |
static bool IsLowEndDevice(); |
system_monitor
类
- namespace base
- class SystemMonitor
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
class BASE_EXPORT SystemMonitor { public: enum DeviceType { // 音频设备 DEVTYPE_AUDIO, // 视频捕获设备 DEVTYPE_VIDEO_CAPTURE, // 其他设备 DEVTYPE_UNKNOWN, }; SystemMonitor(); ~SystemMonitor(); static SystemMonitor* Get(); class BASE_EXPORT DevicesChangedObserver{ public: virtual void OnDevicesChanged(DeviceType device_type) {} protected: virtual ~DevicesChangedObserver() = default; }; // 添加一个新的观察者。 // 可以从任何线程调用。 // 不得在通知回调中调用。 void AddDevicesChangedObserver(DevicesChangedObserver* obs); // 删除现有的观察者。 // 可以从任何线程调用。 // 不得在通知回调中调用。 void RemoveDevicesChangedObserver(DevicesChangedObserver* obs); // 跨平台处理设备更改事件。 void ProcessDevicesChanged(DeviceType device_type); private: void NotifyDevicesChanged(DeviceType device_type); scoped_refptr<ObservalListThreadSafe<DevicesChangedObserver>> devices_changed_observer_list_; DISALLOW_COPY_AND_ASSIGN(SystemMonitor); }; |
1 2 3 |
static SystemMonitor* Get() { return g_system_monitor; } |
本文为原创文章,版权归Aet所有,欢迎分享本文,转载请保留出处!
你可能也喜欢
- ♥ Chromium:鼠标事件的生成与处理07/19
- ♥ Chromium编译相关04/18
- ♥ Chromium:学习,框架,一09/02
- ♥ Chromium:智能指针部分07/28
- ♥ base_json&&value05/19
- ♥ cef:任务、IPC、网络相关04/30