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