[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] | 13326bb | 2009-10-14 00:41:56 | [diff] [blame] | 12 | class FilePath; |
13 | |||||
[email protected] | 2a758d61 | 2008-09-17 10:09:39 | [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(); | ||||
[email protected] | 5965842 | 2009-02-11 02:01:51 | [diff] [blame] | 20 | |
[email protected] | d632798e | 2008-09-17 13:10:45 | [diff] [blame] | 21 | // Return the number of bytes of physical memory on the current machine. |
22 | static int64 AmountOfPhysicalMemory(); | ||||
[email protected] | fadf97f | 2008-09-18 12:18:14 | [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 | } | ||||
[email protected] | 0e91dd2 | 2008-09-18 12:34:24 | [diff] [blame] | 28 | |
[email protected] | 02ee34a | 2008-09-20 01:16:23 | [diff] [blame] | 29 | // Return the available disk space in bytes on the volume containing |path|, |
30 | // or -1 on failure. | ||||
[email protected] | 13326bb | 2009-10-14 00:41:56 | [diff] [blame] | 31 | static int64 AmountOfFreeDiskSpace(const FilePath& path); |
[email protected] | 0e91dd2 | 2008-09-18 12:34:24 | [diff] [blame] | 32 | |
[email protected] | 05f9b68 | 2008-09-29 22:18:01 | [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 | |||||
[email protected] | 71aa16c | 2009-02-24 16:37:13 | [diff] [blame] | 48 | // Retrieves detailed numeric values for the OS version. |
[email protected] | 71aa16c | 2009-02-24 16:37:13 | [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 | |||||
[email protected] | 05f9b68 | 2008-09-29 22:18:01 | [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(); | ||||
[email protected] | 037fce0 | 2009-01-22 01:42:15 | [diff] [blame] | 65 | |
66 | // Return the smallest amount of memory (in bytes) which the VM system will | ||||
67 | // allocate. | ||||
68 | static size_t VMAllocationGranularity(); | ||||
[email protected] | 61b8ad7 | 2009-07-22 00:35:18 | [diff] [blame] | 69 | |
[email protected] | e43eddf1 | 2009-12-29 00:32:52 | [diff] [blame^] | 70 | #if defined(OS_POSIX) && !defined(OS_MACOSX) |
[email protected] | 80a086c5 | 2009-08-04 17:52:04 | [diff] [blame] | 71 | // Returns the maximum SysV shared memory segment size. |
72 | static size_t MaxSharedMemorySize(); | ||||
73 | #endif | ||||
74 | |||||
[email protected] | 61b8ad7 | 2009-07-22 00:35:18 | [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 | ||||
[email protected] | 2a758d61 | 2008-09-17 10:09:39 | [diff] [blame] | 87 | }; |
88 | |||||
89 | } // namespace base | ||||
90 | |||||
91 | #endif // BASE_SYS_INFO_H_ |