[email protected] | af25b47 | 2012-04-25 01:59:44 | [diff] [blame] | 1 | // Copyright (c) 2012 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] | 0bea725 | 2011-08-05 15:34:00 | [diff] [blame] | 9 | #include "base/base_export.h" |
[email protected] | d632798e | 2008-09-17 13:10:45 | [diff] [blame] | 10 | #include "base/basictypes.h" |
[email protected] | af25b47 | 2012-04-25 01:59:44 | [diff] [blame] | 11 | #include "base/file_path.h" |
12 | #include "base/time.h" | ||||
[email protected] | d632798e | 2008-09-17 13:10:45 | [diff] [blame] | 13 | |
[email protected] | 0e91dd2 | 2008-09-18 12:34:24 | [diff] [blame] | 14 | #include <string> |
15 | |||||
[email protected] | 13326bb | 2009-10-14 00:41:56 | [diff] [blame] | 16 | class FilePath; |
17 | |||||
[email protected] | 2a758d61 | 2008-09-17 10:09:39 | [diff] [blame] | 18 | namespace base { |
19 | |||||
[email protected] | 0bea725 | 2011-08-05 15:34:00 | [diff] [blame] | 20 | class BASE_EXPORT SysInfo { |
[email protected] | 2a758d61 | 2008-09-17 10:09:39 | [diff] [blame] | 21 | public: |
22 | // Return the number of logical processors/cores on the current machine. | ||||
23 | static int NumberOfProcessors(); | ||||
[email protected] | 5965842 | 2009-02-11 02:01:51 | [diff] [blame] | 24 | |
[email protected] | d632798e | 2008-09-17 13:10:45 | [diff] [blame] | 25 | // Return the number of bytes of physical memory on the current machine. |
26 | static int64 AmountOfPhysicalMemory(); | ||||
[email protected] | fadf97f | 2008-09-18 12:18:14 | [diff] [blame] | 27 | |
28 | // Return the number of megabytes of physical memory on the current machine. | ||||
29 | static int AmountOfPhysicalMemoryMB() { | ||||
30 | return static_cast<int>(AmountOfPhysicalMemory() / 1024 / 1024); | ||||
31 | } | ||||
[email protected] | 0e91dd2 | 2008-09-18 12:34:24 | [diff] [blame] | 32 | |
[email protected] | 02ee34a | 2008-09-20 01:16:23 | [diff] [blame] | 33 | // Return the available disk space in bytes on the volume containing |path|, |
34 | // or -1 on failure. | ||||
[email protected] | 13326bb | 2009-10-14 00:41:56 | [diff] [blame] | 35 | static int64 AmountOfFreeDiskSpace(const FilePath& path); |
[email protected] | 0e91dd2 | 2008-09-18 12:34:24 | [diff] [blame] | 36 | |
[email protected] | 05f9b68 | 2008-09-29 22:18:01 | [diff] [blame] | 37 | // Returns the name of the host operating system. |
38 | static std::string OperatingSystemName(); | ||||
39 | |||||
40 | // Returns the version of the host operating system. | ||||
41 | static std::string OperatingSystemVersion(); | ||||
42 | |||||
[email protected] | 71aa16c | 2009-02-24 16:37:13 | [diff] [blame] | 43 | // Retrieves detailed numeric values for the OS version. |
[email protected] | 71aa16c | 2009-02-24 16:37:13 | [diff] [blame] | 44 | // TODO(port): Implement a Linux version of this method and enable the |
45 | // corresponding unit test. | ||||
[email protected] | ba64e2b | 2011-06-14 18:18:38 | [diff] [blame] | 46 | // DON'T USE THIS ON THE MAC OR WINDOWS to determine the current OS release |
47 | // for OS version-specific feature checks and workarounds. If you must use | ||||
48 | // an OS version check instead of a feature check, use the base::mac::IsOS* | ||||
49 | // family from base/mac/mac_util.h, or base::win::GetVersion from | ||||
50 | // base/win/windows_version.h. | ||||
[email protected] | f48122119 | 2011-04-07 22:15:34 | [diff] [blame] | 51 | static void OperatingSystemVersionNumbers(int32* major_version, |
52 | int32* minor_version, | ||||
53 | int32* bugfix_version); | ||||
[email protected] | 71aa16c | 2009-02-24 16:37:13 | [diff] [blame] | 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 | |||||
[email protected] | 037fce0 | 2009-01-22 01:42:15 | [diff] [blame] | 59 | // Return the smallest amount of memory (in bytes) which the VM system will |
60 | // allocate. | ||||
61 | static size_t VMAllocationGranularity(); | ||||
[email protected] | 61b8ad7 | 2009-07-22 00:35:18 | [diff] [blame] | 62 | |
[email protected] | e43eddf1 | 2009-12-29 00:32:52 | [diff] [blame] | 63 | #if defined(OS_POSIX) && !defined(OS_MACOSX) |
[email protected] | 80a086c5 | 2009-08-04 17:52:04 | [diff] [blame] | 64 | // Returns the maximum SysV shared memory segment size. |
65 | static size_t MaxSharedMemorySize(); | ||||
[email protected] | af25b47 | 2012-04-25 01:59:44 | [diff] [blame] | 66 | #endif // defined(OS_POSIX) && !defined(OS_MACOSX) |
[email protected] | 80a086c5 | 2009-08-04 17:52:04 | [diff] [blame] | 67 | |
[email protected] | 61b8ad7 | 2009-07-22 00:35:18 | [diff] [blame] | 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, | ||||
[email protected] | f48122119 | 2011-04-07 22:15:34 | [diff] [blame] | 76 | int32* major_version, |
77 | int32* minor_version, | ||||
78 | int32* bugfix_version); | ||||
[email protected] | af25b47 | 2012-04-25 01:59:44 | [diff] [blame] | 79 | |
80 | // Returns the path to the lsb-release file. | ||||
81 | static FilePath GetLsbReleaseFilePath(); | ||||
82 | #endif // defined(OS_CHROMEOS) | ||||
[email protected] | 5702108f | 2012-05-25 15:31:37 | [diff] [blame^] | 83 | |
84 | #if defined(OS_ANDROID) | ||||
85 | static int DalvikHeapSizeMB(); | ||||
86 | #endif // defined(OS_ANDROID) | ||||
[email protected] | 2a758d61 | 2008-09-17 10:09:39 | [diff] [blame] | 87 | }; |
88 | |||||
89 | } // namespace base | ||||
90 | |||||
91 | #endif // BASE_SYS_INFO_H_ |