khorimoto@chromium.org | c7e4e00 | 2012-04-25 10:59:44 +0900 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
deanm@chromium.org | 42a34eb | 2008-09-17 19:09:39 +0900 | [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_ |
| 7 | |
thestig@chromium.org | c913724 | 2012-09-26 11:49:42 +0900 | [diff] [blame] | 8 | #include <string> |
| 9 | |
darin@chromium.org | e585bed | 2011-08-06 00:34:00 +0900 | [diff] [blame] | 10 | #include "base/base_export.h" |
deanm@chromium.org | 319f044 | 2008-09-17 22:10:45 +0900 | [diff] [blame] | 11 | #include "base/basictypes.h" |
brettw@chromium.org | 59eef1f | 2013-02-24 14:40:52 +0900 | [diff] [blame^] | 12 | #include "base/files/file_path.h" |
thestig@chromium.org | c913724 | 2012-09-26 11:49:42 +0900 | [diff] [blame] | 13 | #include "build/build_config.h" |
tony@chromium.org | 1e25e00 | 2009-10-14 09:41:56 +0900 | [diff] [blame] | 14 | |
deanm@chromium.org | 42a34eb | 2008-09-17 19:09:39 +0900 | [diff] [blame] | 15 | namespace base { |
| 16 | |
darin@chromium.org | e585bed | 2011-08-06 00:34:00 +0900 | [diff] [blame] | 17 | class BASE_EXPORT SysInfo { |
deanm@chromium.org | 42a34eb | 2008-09-17 19:09:39 +0900 | [diff] [blame] | 18 | public: |
| 19 | // Return the number of logical processors/cores on the current machine. |
| 20 | static int NumberOfProcessors(); |
jeremy@chromium.org | 0da11fa | 2009-02-11 11:01:51 +0900 | [diff] [blame] | 21 | |
deanm@chromium.org | 319f044 | 2008-09-17 22:10:45 +0900 | [diff] [blame] | 22 | // Return the number of bytes of physical memory on the current machine. |
| 23 | static int64 AmountOfPhysicalMemory(); |
deanm@chromium.org | 530ddd9 | 2008-09-18 21:18:14 +0900 | [diff] [blame] | 24 | |
hongbo.min@intel.com | f6312b1 | 2012-10-27 15:10:37 +0900 | [diff] [blame] | 25 | // Return the number of bytes of current available physical memory on the |
| 26 | // machine. |
| 27 | static int64 AmountOfAvailablePhysicalMemory(); |
| 28 | |
deanm@chromium.org | 530ddd9 | 2008-09-18 21:18:14 +0900 | [diff] [blame] | 29 | // Return the number of megabytes of physical memory on the current machine. |
| 30 | static int AmountOfPhysicalMemoryMB() { |
| 31 | return static_cast<int>(AmountOfPhysicalMemory() / 1024 / 1024); |
| 32 | } |
deanm@chromium.org | ee45e8f | 2008-09-18 21:34:24 +0900 | [diff] [blame] | 33 | |
rvargas@google.com | af00029 | 2008-09-20 10:16:23 +0900 | [diff] [blame] | 34 | // Return the available disk space in bytes on the volume containing |path|, |
| 35 | // or -1 on failure. |
tony@chromium.org | 1e25e00 | 2009-10-14 09:41:56 +0900 | [diff] [blame] | 36 | static int64 AmountOfFreeDiskSpace(const FilePath& path); |
deanm@chromium.org | ee45e8f | 2008-09-18 21:34:24 +0900 | [diff] [blame] | 37 | |
jeremy@chromium.org | de658ed | 2012-10-29 10:04:09 +0900 | [diff] [blame] | 38 | // Returns system uptime in milliseconds. |
| 39 | static int64 Uptime(); |
| 40 | |
mark@chromium.org | b93c054 | 2008-09-30 07:18:01 +0900 | [diff] [blame] | 41 | // Returns the name of the host operating system. |
| 42 | static std::string OperatingSystemName(); |
| 43 | |
| 44 | // Returns the version of the host operating system. |
| 45 | static std::string OperatingSystemVersion(); |
| 46 | |
jeremy@chromium.org | 7730edb | 2009-02-25 01:37:13 +0900 | [diff] [blame] | 47 | // Retrieves detailed numeric values for the OS version. |
jeremy@chromium.org | 7730edb | 2009-02-25 01:37:13 +0900 | [diff] [blame] | 48 | // TODO(port): Implement a Linux version of this method and enable the |
| 49 | // corresponding unit test. |
mark@chromium.org | 71cce47 | 2011-06-15 03:18:38 +0900 | [diff] [blame] | 50 | // DON'T USE THIS ON THE MAC OR WINDOWS to determine the current OS release |
| 51 | // for OS version-specific feature checks and workarounds. If you must use |
| 52 | // an OS version check instead of a feature check, use the base::mac::IsOS* |
| 53 | // family from base/mac/mac_util.h, or base::win::GetVersion from |
| 54 | // base/win/windows_version.h. |
pkasting@chromium.org | 271d9db | 2011-04-08 07:15:34 +0900 | [diff] [blame] | 55 | static void OperatingSystemVersionNumbers(int32* major_version, |
| 56 | int32* minor_version, |
| 57 | int32* bugfix_version); |
jeremy@chromium.org | 7730edb | 2009-02-25 01:37:13 +0900 | [diff] [blame] | 58 | |
thestig@chromium.org | c913724 | 2012-09-26 11:49:42 +0900 | [diff] [blame] | 59 | // Returns the architecture of the running operating system. |
| 60 | // Exact return value may differ across platforms. |
| 61 | // e.g. a 32-bit x86 kernel on a 64-bit capable CPU will return "x86", |
| 62 | // whereas a x86-64 kernel on the same CPU will return "x86_64" |
thestig@chromium.org | e170665 | 2012-10-16 10:58:21 +0900 | [diff] [blame] | 63 | static std::string OperatingSystemArchitecture(); |
mark@chromium.org | b93c054 | 2008-09-30 07:18:01 +0900 | [diff] [blame] | 64 | |
thestig@chromium.org | c913724 | 2012-09-26 11:49:42 +0900 | [diff] [blame] | 65 | // Avoid using this. Use base/cpu.h to get information about the CPU instead. |
| 66 | // http://crbug.com/148884 |
hongbo.min@intel.com | 893f7d6 | 2012-09-08 18:53:01 +0900 | [diff] [blame] | 67 | // Returns the CPU model name of the system. If it can not be figured out, |
| 68 | // an empty string is returned. |
| 69 | static std::string CPUModelName(); |
| 70 | |
agl@chromium.org | 3d71fda | 2009-01-22 10:42:15 +0900 | [diff] [blame] | 71 | // Return the smallest amount of memory (in bytes) which the VM system will |
| 72 | // allocate. |
| 73 | static size_t VMAllocationGranularity(); |
evan@chromium.org | 54b7210 | 2009-07-22 09:35:18 +0900 | [diff] [blame] | 74 | |
evan@chromium.org | 875bb6e | 2009-12-29 09:32:52 +0900 | [diff] [blame] | 75 | #if defined(OS_POSIX) && !defined(OS_MACOSX) |
agl@chromium.org | 3319f0a | 2009-08-05 02:52:04 +0900 | [diff] [blame] | 76 | // Returns the maximum SysV shared memory segment size. |
| 77 | static size_t MaxSharedMemorySize(); |
thestig@chromium.org | c913724 | 2012-09-26 11:49:42 +0900 | [diff] [blame] | 78 | #endif // defined(OS_POSIX) && !defined(OS_MACOSX) |
agl@chromium.org | 3319f0a | 2009-08-05 02:52:04 +0900 | [diff] [blame] | 79 | |
evan@chromium.org | 54b7210 | 2009-07-22 09:35:18 +0900 | [diff] [blame] | 80 | #if defined(OS_CHROMEOS) |
| 81 | // Returns the name of the version entry we wish to look up in the |
| 82 | // Linux Standard Base release information file. |
| 83 | static std::string GetLinuxStandardBaseVersionKey(); |
| 84 | |
| 85 | // Parses /etc/lsb-release to get version information for Google Chrome OS. |
| 86 | // Declared here so it can be exposed for unit testing. |
| 87 | static void ParseLsbRelease(const std::string& lsb_release, |
pkasting@chromium.org | 271d9db | 2011-04-08 07:15:34 +0900 | [diff] [blame] | 88 | int32* major_version, |
| 89 | int32* minor_version, |
| 90 | int32* bugfix_version); |
khorimoto@chromium.org | c7e4e00 | 2012-04-25 10:59:44 +0900 | [diff] [blame] | 91 | |
| 92 | // Returns the path to the lsb-release file. |
| 93 | static FilePath GetLsbReleaseFilePath(); |
thestig@chromium.org | c913724 | 2012-09-26 11:49:42 +0900 | [diff] [blame] | 94 | #endif // defined(OS_CHROMEOS) |
ulan@chromium.org | 8ac7ea0 | 2012-05-26 00:31:37 +0900 | [diff] [blame] | 95 | |
| 96 | #if defined(OS_ANDROID) |
dfalcantara@chromium.org | 774888d | 2012-08-22 08:55:52 +0900 | [diff] [blame] | 97 | // Returns the Android build's codename. |
| 98 | static std::string GetAndroidBuildCodename(); |
| 99 | |
| 100 | // Returns the Android build ID. |
| 101 | static std::string GetAndroidBuildID(); |
| 102 | |
| 103 | // Returns the device's name. |
| 104 | static std::string GetDeviceName(); |
| 105 | |
ulan@chromium.org | 8ac7ea0 | 2012-05-26 00:31:37 +0900 | [diff] [blame] | 106 | static int DalvikHeapSizeMB(); |
epenner@chromium.org | 066b81b | 2013-02-17 03:15:50 +0900 | [diff] [blame] | 107 | static int DalvikHeapGrowthLimitMB(); |
thestig@chromium.org | c913724 | 2012-09-26 11:49:42 +0900 | [diff] [blame] | 108 | #endif // defined(OS_ANDROID) |
deanm@chromium.org | 42a34eb | 2008-09-17 19:09:39 +0900 | [diff] [blame] | 109 | }; |
| 110 | |
| 111 | } // namespace base |
| 112 | |
| 113 | #endif // BASE_SYS_INFO_H_ |