blob: 242f4fbf5f7218aef41812c94d4fc38c17f2f1bb [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_
[email protected]32b76ef2010-07-26 23:08:247#pragma once
[email protected]2a758d612008-09-17 10:09:398
[email protected]0bea7252011-08-05 15:34:009#include "base/base_export.h"
[email protected]d632798e2008-09-17 13:10:4510#include "base/basictypes.h"
[email protected]af25b472012-04-25 01:59:4411#include "base/file_path.h"
12#include "base/time.h"
[email protected]d632798e2008-09-17 13:10:4513
[email protected]0e91dd22008-09-18 12:34:2414#include <string>
15
[email protected]13326bb2009-10-14 00:41:5616class FilePath;
17
[email protected]2a758d612008-09-17 10:09:3918namespace base {
19
[email protected]0bea7252011-08-05 15:34:0020class BASE_EXPORT SysInfo {
[email protected]2a758d612008-09-17 10:09:3921 public:
22 // Return the number of logical processors/cores on the current machine.
23 static int NumberOfProcessors();
[email protected]59658422009-02-11 02:01:5124
[email protected]d632798e2008-09-17 13:10:4525 // Return the number of bytes of physical memory on the current machine.
26 static int64 AmountOfPhysicalMemory();
[email protected]fadf97f2008-09-18 12:18:1427
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]0e91dd22008-09-18 12:34:2432
[email protected]02ee34a2008-09-20 01:16:2333 // Return the available disk space in bytes on the volume containing |path|,
34 // or -1 on failure.
[email protected]13326bb2009-10-14 00:41:5635 static int64 AmountOfFreeDiskSpace(const FilePath& path);
[email protected]0e91dd22008-09-18 12:34:2436
[email protected]05f9b682008-09-29 22:18:0137 // 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]71aa16c2009-02-24 16:37:1343 // Retrieves detailed numeric values for the OS version.
[email protected]71aa16c2009-02-24 16:37:1344 // TODO(port): Implement a Linux version of this method and enable the
45 // corresponding unit test.
[email protected]ba64e2b2011-06-14 18:18:3846 // 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]f481221192011-04-07 22:15:3451 static void OperatingSystemVersionNumbers(int32* major_version,
52 int32* minor_version,
53 int32* bugfix_version);
[email protected]71aa16c2009-02-24 16:37:1354
[email protected]05f9b682008-09-29 22:18:0155 // Returns the CPU architecture of the system. Exact return value may differ
56 // across platforms.
57 static std::string CPUArchitecture();
58
[email protected]037fce02009-01-22 01:42:1559 // Return the smallest amount of memory (in bytes) which the VM system will
60 // allocate.
61 static size_t VMAllocationGranularity();
[email protected]61b8ad72009-07-22 00:35:1862
[email protected]e43eddf12009-12-29 00:32:5263#if defined(OS_POSIX) && !defined(OS_MACOSX)
[email protected]80a086c52009-08-04 17:52:0464 // Returns the maximum SysV shared memory segment size.
65 static size_t MaxSharedMemorySize();
[email protected]af25b472012-04-25 01:59:4466#endif // defined(OS_POSIX) && !defined(OS_MACOSX)
[email protected]80a086c52009-08-04 17:52:0467
[email protected]61b8ad72009-07-22 00:35:1868#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]f481221192011-04-07 22:15:3476 int32* major_version,
77 int32* minor_version,
78 int32* bugfix_version);
[email protected]af25b472012-04-25 01:59:4479
80 // Returns the path to the lsb-release file.
81 static FilePath GetLsbReleaseFilePath();
82#endif // defined(OS_CHROMEOS)
[email protected]5702108f2012-05-25 15:31:3783
84#if defined(OS_ANDROID)
85 static int DalvikHeapSizeMB();
86#endif // defined(OS_ANDROID)
[email protected]2a758d612008-09-17 10:09:3987};
88
89} // namespace base
90
91#endif // BASE_SYS_INFO_H_