blob: 38462ed11105c655bd3797ec4485bb59ee69dc0e [file] [log] [blame]
[email protected]af25b472012-04-25 01:59:441// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]2a758d612008-09-17 10:09:392// 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]56d0cef2012-09-26 02:49:428#include <string>
9
[email protected]0bea7252011-08-05 15:34:0010#include "base/base_export.h"
[email protected]d632798e2008-09-17 13:10:4511#include "base/basictypes.h"
[email protected]57999812013-02-24 05:40:5212#include "base/files/file_path.h"
[email protected]56d0cef2012-09-26 02:49:4213#include "build/build_config.h"
[email protected]13326bb2009-10-14 00:41:5614
[email protected]2a758d612008-09-17 10:09:3915namespace base {
16
[email protected]0bea7252011-08-05 15:34:0017class BASE_EXPORT SysInfo {
[email protected]2a758d612008-09-17 10:09:3918 public:
19 // Return the number of logical processors/cores on the current machine.
20 static int NumberOfProcessors();
[email protected]59658422009-02-11 02:01:5121
[email protected]d632798e2008-09-17 13:10:4522 // Return the number of bytes of physical memory on the current machine.
23 static int64 AmountOfPhysicalMemory();
[email protected]fadf97f2008-09-18 12:18:1424
[email protected]52bdcda2012-10-27 06:10:3725 // Return the number of bytes of current available physical memory on the
26 // machine.
27 static int64 AmountOfAvailablePhysicalMemory();
28
[email protected]fadf97f2008-09-18 12:18:1429 // 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 }
[email protected]0e91dd22008-09-18 12:34:2433
[email protected]02ee34a2008-09-20 01:16:2334 // Return the available disk space in bytes on the volume containing |path|,
35 // or -1 on failure.
[email protected]13326bb2009-10-14 00:41:5636 static int64 AmountOfFreeDiskSpace(const FilePath& path);
[email protected]0e91dd22008-09-18 12:34:2437
[email protected]0f24e53e2012-10-29 01:04:0938 // Returns system uptime in milliseconds.
39 static int64 Uptime();
40
[email protected]05f9b682008-09-29 22:18:0141 // 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
[email protected]71aa16c2009-02-24 16:37:1347 // Retrieves detailed numeric values for the OS version.
[email protected]71aa16c2009-02-24 16:37:1348 // TODO(port): Implement a Linux version of this method and enable the
49 // corresponding unit test.
[email protected]ba64e2b2011-06-14 18:18:3850 // 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.
[email protected]f481221192011-04-07 22:15:3455 static void OperatingSystemVersionNumbers(int32* major_version,
56 int32* minor_version,
57 int32* bugfix_version);
[email protected]71aa16c2009-02-24 16:37:1358
[email protected]56d0cef2012-09-26 02:49:4259 // 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"
[email protected]0b6a4fb2012-10-16 01:58:2163 static std::string OperatingSystemArchitecture();
[email protected]05f9b682008-09-29 22:18:0164
[email protected]56d0cef2012-09-26 02:49:4265 // Avoid using this. Use base/cpu.h to get information about the CPU instead.
66 // http://crbug.com/148884
[email protected]d5df0c8c2012-09-08 09:53:0167 // 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
[email protected]037fce02009-01-22 01:42:1571 // Return the smallest amount of memory (in bytes) which the VM system will
72 // allocate.
73 static size_t VMAllocationGranularity();
[email protected]61b8ad72009-07-22 00:35:1874
[email protected]e43eddf12009-12-29 00:32:5275#if defined(OS_POSIX) && !defined(OS_MACOSX)
[email protected]80a086c52009-08-04 17:52:0476 // Returns the maximum SysV shared memory segment size.
77 static size_t MaxSharedMemorySize();
[email protected]56d0cef2012-09-26 02:49:4278#endif // defined(OS_POSIX) && !defined(OS_MACOSX)
[email protected]80a086c52009-08-04 17:52:0479
[email protected]61b8ad72009-07-22 00:35:1880#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,
[email protected]f481221192011-04-07 22:15:3488 int32* major_version,
89 int32* minor_version,
90 int32* bugfix_version);
[email protected]af25b472012-04-25 01:59:4491
92 // Returns the path to the lsb-release file.
93 static FilePath GetLsbReleaseFilePath();
[email protected]56d0cef2012-09-26 02:49:4294#endif // defined(OS_CHROMEOS)
[email protected]5702108f2012-05-25 15:31:3795
96#if defined(OS_ANDROID)
[email protected]abef4b332012-08-21 23:55:5297 // 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
[email protected]5702108f2012-05-25 15:31:37106 static int DalvikHeapSizeMB();
[email protected]0cea3552013-02-16 18:15:50107 static int DalvikHeapGrowthLimitMB();
[email protected]56d0cef2012-09-26 02:49:42108#endif // defined(OS_ANDROID)
[email protected]2a758d612008-09-17 10:09:39109};
110
111} // namespace base
112
113#endif // BASE_SYS_INFO_H_