michael@0: // Copyright (c) 2012 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #ifndef BASE_SYS_INFO_H_ michael@0: #define BASE_SYS_INFO_H_ michael@0: michael@0: #include michael@0: michael@0: #include "base/base_export.h" michael@0: #include "base/basictypes.h" michael@0: #include "base/files/file_path.h" michael@0: #include "build/build_config.h" michael@0: michael@0: namespace base { michael@0: michael@0: class BASE_EXPORT SysInfo { michael@0: public: michael@0: // Return the number of logical processors/cores on the current machine. michael@0: static int NumberOfProcessors(); michael@0: michael@0: // Return the number of bytes of physical memory on the current machine. michael@0: static int64 AmountOfPhysicalMemory(); michael@0: michael@0: // Return the number of bytes of current available physical memory on the michael@0: // machine. michael@0: static int64 AmountOfAvailablePhysicalMemory(); michael@0: michael@0: // Return the number of megabytes of physical memory on the current machine. michael@0: static int AmountOfPhysicalMemoryMB() { michael@0: return static_cast(AmountOfPhysicalMemory() / 1024 / 1024); michael@0: } michael@0: michael@0: // Return the available disk space in bytes on the volume containing |path|, michael@0: // or -1 on failure. michael@0: static int64 AmountOfFreeDiskSpace(const FilePath& path); michael@0: michael@0: // Returns system uptime in milliseconds. michael@0: static int64 Uptime(); michael@0: michael@0: // Returns the name of the host operating system. michael@0: static std::string OperatingSystemName(); michael@0: michael@0: // Returns the version of the host operating system. michael@0: static std::string OperatingSystemVersion(); michael@0: michael@0: // Retrieves detailed numeric values for the OS version. michael@0: // TODO(port): Implement a Linux version of this method and enable the michael@0: // corresponding unit test. michael@0: // DON'T USE THIS ON THE MAC OR WINDOWS to determine the current OS release michael@0: // for OS version-specific feature checks and workarounds. If you must use michael@0: // an OS version check instead of a feature check, use the base::mac::IsOS* michael@0: // family from base/mac/mac_util.h, or base::win::GetVersion from michael@0: // base/win/windows_version.h. michael@0: static void OperatingSystemVersionNumbers(int32* major_version, michael@0: int32* minor_version, michael@0: int32* bugfix_version); michael@0: michael@0: // Returns the architecture of the running operating system. michael@0: // Exact return value may differ across platforms. michael@0: // e.g. a 32-bit x86 kernel on a 64-bit capable CPU will return "x86", michael@0: // whereas a x86-64 kernel on the same CPU will return "x86_64" michael@0: static std::string OperatingSystemArchitecture(); michael@0: michael@0: // Avoid using this. Use base/cpu.h to get information about the CPU instead. michael@0: // http://crbug.com/148884 michael@0: // Returns the CPU model name of the system. If it can not be figured out, michael@0: // an empty string is returned. michael@0: static std::string CPUModelName(); michael@0: michael@0: // Return the smallest amount of memory (in bytes) which the VM system will michael@0: // allocate. michael@0: static size_t VMAllocationGranularity(); michael@0: michael@0: #if defined(OS_POSIX) && !defined(OS_MACOSX) michael@0: // Returns the maximum SysV shared memory segment size. michael@0: static size_t MaxSharedMemorySize(); michael@0: #endif // defined(OS_POSIX) && !defined(OS_MACOSX) michael@0: michael@0: #if defined(OS_CHROMEOS) michael@0: // Returns the name of the version entry we wish to look up in the michael@0: // Linux Standard Base release information file. michael@0: static std::string GetLinuxStandardBaseVersionKey(); michael@0: michael@0: // Parses /etc/lsb-release to get version information for Google Chrome OS. michael@0: // Declared here so it can be exposed for unit testing. michael@0: static void ParseLsbRelease(const std::string& lsb_release, michael@0: int32* major_version, michael@0: int32* minor_version, michael@0: int32* bugfix_version); michael@0: michael@0: // Returns the path to the lsb-release file. michael@0: static FilePath GetLsbReleaseFilePath(); michael@0: #endif // defined(OS_CHROMEOS) michael@0: michael@0: #if defined(OS_ANDROID) michael@0: // Returns the Android build's codename. michael@0: static std::string GetAndroidBuildCodename(); michael@0: michael@0: // Returns the Android build ID. michael@0: static std::string GetAndroidBuildID(); michael@0: michael@0: // Returns the device's name. michael@0: static std::string GetDeviceName(); michael@0: michael@0: static int DalvikHeapSizeMB(); michael@0: static int DalvikHeapGrowthLimitMB(); michael@0: #endif // defined(OS_ANDROID) michael@0: }; michael@0: michael@0: } // namespace base michael@0: michael@0: #endif // BASE_SYS_INFO_H_