[email protected] | 26fbf80 | 2011-03-25 18:48:03 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | 2a758d61 | 2008-09-17 10:09:39 | [diff] [blame] | 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_ | ||||
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame] | 7 | #pragma once |
[email protected] | 2a758d61 | 2008-09-17 10:09:39 | [diff] [blame] | 8 | |
[email protected] | 26fbf80 | 2011-03-25 18:48:03 | [diff] [blame] | 9 | #include "base/base_api.h" |
[email protected] | d632798e | 2008-09-17 13:10:45 | [diff] [blame] | 10 | #include "base/basictypes.h" |
11 | |||||
[email protected] | 0e91dd2 | 2008-09-18 12:34:24 | [diff] [blame] | 12 | #include <string> |
13 | |||||
[email protected] | 13326bb | 2009-10-14 00:41:56 | [diff] [blame] | 14 | class FilePath; |
15 | |||||
[email protected] | 2a758d61 | 2008-09-17 10:09:39 | [diff] [blame] | 16 | namespace base { |
17 | |||||
[email protected] | 26fbf80 | 2011-03-25 18:48:03 | [diff] [blame] | 18 | class BASE_API SysInfo { |
[email protected] | 2a758d61 | 2008-09-17 10:09:39 | [diff] [blame] | 19 | public: |
20 | // Return the number of logical processors/cores on the current machine. | ||||
21 | static int NumberOfProcessors(); | ||||
[email protected] | 5965842 | 2009-02-11 02:01:51 | [diff] [blame] | 22 | |
[email protected] | d632798e | 2008-09-17 13:10:45 | [diff] [blame] | 23 | // Return the number of bytes of physical memory on the current machine. |
24 | static int64 AmountOfPhysicalMemory(); | ||||
[email protected] | fadf97f | 2008-09-18 12:18:14 | [diff] [blame] | 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 | } | ||||
[email protected] | 0e91dd2 | 2008-09-18 12:34:24 | [diff] [blame] | 30 | |
[email protected] | 02ee34a | 2008-09-20 01:16:23 | [diff] [blame] | 31 | // Return the available disk space in bytes on the volume containing |path|, |
32 | // or -1 on failure. | ||||
[email protected] | 13326bb | 2009-10-14 00:41:56 | [diff] [blame] | 33 | static int64 AmountOfFreeDiskSpace(const FilePath& path); |
[email protected] | 0e91dd2 | 2008-09-18 12:34:24 | [diff] [blame] | 34 | |
[email protected] | 05f9b68 | 2008-09-29 22:18:01 | [diff] [blame] | 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 | |||||
[email protected] | 71aa16c | 2009-02-24 16:37:13 | [diff] [blame] | 41 | // Retrieves detailed numeric values for the OS version. |
[email protected] | 71aa16c | 2009-02-24 16:37:13 | [diff] [blame] | 42 | // TODO(port): Implement a Linux version of this method and enable the |
43 | // corresponding unit test. | ||||
[email protected] | ba64e2b | 2011-06-14 18:18:38 | [diff] [blame^] | 44 | // DON'T USE THIS ON THE MAC OR WINDOWS to determine the current OS release |
45 | // for OS version-specific feature checks and workarounds. If you must use | ||||
46 | // an OS version check instead of a feature check, use the base::mac::IsOS* | ||||
47 | // family from base/mac/mac_util.h, or base::win::GetVersion from | ||||
48 | // base/win/windows_version.h. | ||||
[email protected] | f48122119 | 2011-04-07 22:15:34 | [diff] [blame] | 49 | static void OperatingSystemVersionNumbers(int32* major_version, |
50 | int32* minor_version, | ||||
51 | int32* bugfix_version); | ||||
[email protected] | 71aa16c | 2009-02-24 16:37:13 | [diff] [blame] | 52 | |
[email protected] | 05f9b68 | 2008-09-29 22:18:01 | [diff] [blame] | 53 | // Returns the CPU architecture of the system. Exact return value may differ |
54 | // across platforms. | ||||
55 | static std::string CPUArchitecture(); | ||||
56 | |||||
57 | // Returns the pixel dimensions of the primary display via the | ||||
58 | // width and height parameters. | ||||
59 | static void GetPrimaryDisplayDimensions(int* width, int* height); | ||||
60 | |||||
61 | // Return the number of displays. | ||||
62 | static int DisplayCount(); | ||||
[email protected] | 037fce0 | 2009-01-22 01:42:15 | [diff] [blame] | 63 | |
64 | // Return the smallest amount of memory (in bytes) which the VM system will | ||||
65 | // allocate. | ||||
66 | static size_t VMAllocationGranularity(); | ||||
[email protected] | 61b8ad7 | 2009-07-22 00:35:18 | [diff] [blame] | 67 | |
[email protected] | e43eddf1 | 2009-12-29 00:32:52 | [diff] [blame] | 68 | #if defined(OS_POSIX) && !defined(OS_MACOSX) |
[email protected] | 80a086c5 | 2009-08-04 17:52:04 | [diff] [blame] | 69 | // Returns the maximum SysV shared memory segment size. |
70 | static size_t MaxSharedMemorySize(); | ||||
71 | #endif | ||||
72 | |||||
[email protected] | 61b8ad7 | 2009-07-22 00:35:18 | [diff] [blame] | 73 | #if defined(OS_CHROMEOS) |
74 | // Returns the name of the version entry we wish to look up in the | ||||
75 | // Linux Standard Base release information file. | ||||
76 | static std::string GetLinuxStandardBaseVersionKey(); | ||||
77 | |||||
78 | // Parses /etc/lsb-release to get version information for Google Chrome OS. | ||||
79 | // Declared here so it can be exposed for unit testing. | ||||
80 | static void ParseLsbRelease(const std::string& lsb_release, | ||||
[email protected] | f48122119 | 2011-04-07 22:15:34 | [diff] [blame] | 81 | int32* major_version, |
82 | int32* minor_version, | ||||
83 | int32* bugfix_version); | ||||
[email protected] | 61b8ad7 | 2009-07-22 00:35:18 | [diff] [blame] | 84 | #endif |
[email protected] | 2a758d61 | 2008-09-17 10:09:39 | [diff] [blame] | 85 | }; |
86 | |||||
87 | } // namespace base | ||||
88 | |||||
89 | #endif // BASE_SYS_INFO_H_ |