[email protected] | 2a758d61 | 2008-09-17 10:09:39 | [diff] [blame] | 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 | |
[email protected] | d632798e | 2008-09-17 13:10:45 | [diff] [blame] | 8 | #include "base/basictypes.h" |
| 9 | |
[email protected] | 0e91dd2 | 2008-09-18 12:34:24 | [diff] [blame] | 10 | #include <string> |
| 11 | |
[email protected] | 2a758d61 | 2008-09-17 10:09:39 | [diff] [blame] | 12 | namespace base { |
| 13 | |
| 14 | class SysInfo { |
| 15 | public: |
| 16 | // Return the number of logical processors/cores on the current machine. |
| 17 | static int NumberOfProcessors(); |
[email protected] | d632798e | 2008-09-17 13:10:45 | [diff] [blame] | 18 | |
| 19 | // Return the number of bytes of physical memory on the current machine. |
| 20 | static int64 AmountOfPhysicalMemory(); |
[email protected] | fadf97f | 2008-09-18 12:18:14 | [diff] [blame] | 21 | |
| 22 | // Return the number of megabytes of physical memory on the current machine. |
| 23 | static int AmountOfPhysicalMemoryMB() { |
| 24 | return static_cast<int>(AmountOfPhysicalMemory() / 1024 / 1024); |
| 25 | } |
[email protected] | 0e91dd2 | 2008-09-18 12:34:24 | [diff] [blame] | 26 | |
[email protected] | 02ee34a | 2008-09-20 01:16:23 | [diff] [blame] | 27 | // Return the available disk space in bytes on the volume containing |path|, |
| 28 | // or -1 on failure. |
[email protected] | 0e91dd2 | 2008-09-18 12:34:24 | [diff] [blame] | 29 | static int64 AmountOfFreeDiskSpace(const std::wstring& path); |
| 30 | |
[email protected] | 05f9b68 | 2008-09-29 22:18:01 | [diff] [blame] | 31 | // Return true if the given environment variable is defined. |
| 32 | // TODO: find a better place for HasEnvVar. |
| 33 | static bool HasEnvVar(const wchar_t* var); |
| 34 | |
| 35 | // Return the value of the given environment variable |
| 36 | // or an empty string if not defined. |
| 37 | // TODO: find a better place for GetEnvVar. |
| 38 | static std::wstring GetEnvVar(const wchar_t* var); |
| 39 | |
| 40 | // Returns the name of the host operating system. |
| 41 | static std::string OperatingSystemName(); |
| 42 | |
| 43 | // Returns the version of the host operating system. |
| 44 | static std::string OperatingSystemVersion(); |
| 45 | |
| 46 | // Returns the CPU architecture of the system. Exact return value may differ |
| 47 | // across platforms. |
| 48 | static std::string CPUArchitecture(); |
| 49 | |
| 50 | // Returns the pixel dimensions of the primary display via the |
| 51 | // width and height parameters. |
| 52 | static void GetPrimaryDisplayDimensions(int* width, int* height); |
| 53 | |
| 54 | // Return the number of displays. |
| 55 | static int DisplayCount(); |
[email protected] | 2a758d61 | 2008-09-17 10:09:39 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | } // namespace base |
| 59 | |
| 60 | #endif // BASE_SYS_INFO_H_ |