deanm@chromium.org | 42a34eb | 2008-09-17 19:09:39 +0900 | [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 | |
deanm@chromium.org | 319f044 | 2008-09-17 22:10:45 +0900 | [diff] [blame] | 8 | #include "base/basictypes.h" |
| 9 | |
deanm@chromium.org | ee45e8f | 2008-09-18 21:34:24 +0900 | [diff] [blame] | 10 | #include <string> |
| 11 | |
tony@chromium.org | 1e25e00 | 2009-10-14 09:41:56 +0900 | [diff] [blame] | 12 | class FilePath; |
| 13 | |
deanm@chromium.org | 42a34eb | 2008-09-17 19:09:39 +0900 | [diff] [blame] | 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(); |
jeremy@chromium.org | 0da11fa | 2009-02-11 11:01:51 +0900 | [diff] [blame] | 20 | |
deanm@chromium.org | 319f044 | 2008-09-17 22:10:45 +0900 | [diff] [blame] | 21 | // Return the number of bytes of physical memory on the current machine. |
| 22 | static int64 AmountOfPhysicalMemory(); |
deanm@chromium.org | 530ddd9 | 2008-09-18 21:18:14 +0900 | [diff] [blame] | 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 | } |
deanm@chromium.org | ee45e8f | 2008-09-18 21:34:24 +0900 | [diff] [blame] | 28 | |
rvargas@google.com | af00029 | 2008-09-20 10:16:23 +0900 | [diff] [blame] | 29 | // Return the available disk space in bytes on the volume containing |path|, |
| 30 | // or -1 on failure. |
tony@chromium.org | 1e25e00 | 2009-10-14 09:41:56 +0900 | [diff] [blame] | 31 | static int64 AmountOfFreeDiskSpace(const FilePath& path); |
deanm@chromium.org | ee45e8f | 2008-09-18 21:34:24 +0900 | [diff] [blame] | 32 | |
mark@chromium.org | b93c054 | 2008-09-30 07:18:01 +0900 | [diff] [blame] | 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 | |
jeremy@chromium.org | 7730edb | 2009-02-25 01:37:13 +0900 | [diff] [blame] | 48 | // Retrieves detailed numeric values for the OS version. |
jeremy@chromium.org | 7730edb | 2009-02-25 01:37:13 +0900 | [diff] [blame] | 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 | |
mark@chromium.org | b93c054 | 2008-09-30 07:18:01 +0900 | [diff] [blame] | 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(); |
agl@chromium.org | 3d71fda | 2009-01-22 10:42:15 +0900 | [diff] [blame] | 65 | |
| 66 | // Return the smallest amount of memory (in bytes) which the VM system will |
| 67 | // allocate. |
| 68 | static size_t VMAllocationGranularity(); |
evan@chromium.org | 54b7210 | 2009-07-22 09:35:18 +0900 | [diff] [blame] | 69 | |
agl@chromium.org | 3319f0a | 2009-08-05 02:52:04 +0900 | [diff] [blame] | 70 | #if defined(OS_LINUX) |
| 71 | // Returns the maximum SysV shared memory segment size. |
| 72 | static size_t MaxSharedMemorySize(); |
| 73 | #endif |
| 74 | |
evan@chromium.org | 54b7210 | 2009-07-22 09:35:18 +0900 | [diff] [blame] | 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 |
deanm@chromium.org | 42a34eb | 2008-09-17 19:09:39 +0900 | [diff] [blame] | 87 | }; |
| 88 | |
| 89 | } // namespace base |
| 90 | |
| 91 | #endif // BASE_SYS_INFO_H_ |