1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef BASE_SYS_INFO_H_ 6 #define BASE_SYS_INFO_H_ 7 8 #include "base/basictypes.h" 9 10 #include <string> 11 12 class FilePath; 13 14 namespace base { 15 16 class SysInfo { 17 public: 18 // Return the number of logical processors/cores on the current machine. 19 static int NumberOfProcessors(); 20 21 // Return the number of bytes of physical memory on the current machine. 22 static int64 AmountOfPhysicalMemory(); 23 24 // Return the number of megabytes of physical memory on the current machine. 25 static int AmountOfPhysicalMemoryMB() { 26 return static_cast<int>(AmountOfPhysicalMemory() / 1024 / 1024); 27 } 28 29 // Return the available disk space in bytes on the volume containing |path|, 30 // or -1 on failure. 31 static int64 AmountOfFreeDiskSpace(const FilePath& path); 32 33 // Return true if the given environment variable is defined. 34 // TODO: find a better place for HasEnvVar. 35 static bool HasEnvVar(const wchar_t* var); 36 37 // Return the value of the given environment variable 38 // or an empty string if not defined. 39 // TODO: find a better place for GetEnvVar. 40 static std::wstring GetEnvVar(const wchar_t* var); 41 42 // Returns the name of the host operating system. 43 static std::string OperatingSystemName(); 44 45 // Returns the version of the host operating system. 46 static std::string OperatingSystemVersion(); 47 48 // Retrieves detailed numeric values for the OS version. 49 // TODO(port): Implement a Linux version of this method and enable the 50 // corresponding unit test. 51 static void OperatingSystemVersionNumbers(int32 *major_version, 52 int32 *minor_version, 53 int32 *bugfix_version); 54 55 // Returns the CPU architecture of the system. Exact return value may differ 56 // across platforms. 57 static std::string CPUArchitecture(); 58 59 // Returns the pixel dimensions of the primary display via the 60 // width and height parameters. 61 static void GetPrimaryDisplayDimensions(int* width, int* height); 62 63 // Return the number of displays. 64 static int DisplayCount(); 65 66 // Return the smallest amount of memory (in bytes) which the VM system will 67 // allocate. 68 static size_t VMAllocationGranularity(); 69 70 #if defined(OS_POSIX) && !defined(OS_MACOSX) 71 // Returns the maximum SysV shared memory segment size. 72 static size_t MaxSharedMemorySize(); 73 #endif 74 75 #if defined(OS_CHROMEOS) 76 // Returns the name of the version entry we wish to look up in the 77 // Linux Standard Base release information file. 78 static std::string GetLinuxStandardBaseVersionKey(); 79 80 // Parses /etc/lsb-release to get version information for Google Chrome OS. 81 // Declared here so it can be exposed for unit testing. 82 static void ParseLsbRelease(const std::string& lsb_release, 83 int32 *major_version, 84 int32 *minor_version, 85 int32 *bugfix_version); 86 #endif 87 }; 88 89 } // namespace base 90 91 #endif // BASE_SYS_INFO_H_ 92