blob: 89bd1931eb2f721d0acd158e02e023d025f3976d [file] [log] [blame]
[email protected]26fbf802011-03-25 18:48:031// Copyright (c) 2011 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]26fbf802011-03-25 18:48:039#include "base/base_api.h"
[email protected]d632798e2008-09-17 13:10:4510#include "base/basictypes.h"
11
[email protected]0e91dd22008-09-18 12:34:2412#include <string>
13
[email protected]13326bb2009-10-14 00:41:5614class FilePath;
15
[email protected]2a758d612008-09-17 10:09:3916namespace base {
17
[email protected]26fbf802011-03-25 18:48:0318class BASE_API SysInfo {
[email protected]2a758d612008-09-17 10:09:3919 public:
20 // Return the number of logical processors/cores on the current machine.
21 static int NumberOfProcessors();
[email protected]59658422009-02-11 02:01:5122
[email protected]d632798e2008-09-17 13:10:4523 // Return the number of bytes of physical memory on the current machine.
24 static int64 AmountOfPhysicalMemory();
[email protected]fadf97f2008-09-18 12:18:1425
26 // Return the number of megabytes of physical memory on the current machine.
27 static int AmountOfPhysicalMemoryMB() {
28 return static_cast<int>(AmountOfPhysicalMemory() / 1024 / 1024);
29 }
[email protected]0e91dd22008-09-18 12:34:2430
[email protected]02ee34a2008-09-20 01:16:2331 // Return the available disk space in bytes on the volume containing |path|,
32 // or -1 on failure.
[email protected]13326bb2009-10-14 00:41:5633 static int64 AmountOfFreeDiskSpace(const FilePath& path);
[email protected]0e91dd22008-09-18 12:34:2434
[email protected]05f9b682008-09-29 22:18:0135 // Returns the name of the host operating system.
36 static std::string OperatingSystemName();
37
38 // Returns the version of the host operating system.
39 static std::string OperatingSystemVersion();
40
[email protected]71aa16c2009-02-24 16:37:1341 // Retrieves detailed numeric values for the OS version.
[email protected]71aa16c2009-02-24 16:37:1342 // TODO(port): Implement a Linux version of this method and enable the
43 // corresponding unit test.
[email protected]ba64e2b2011-06-14 18:18:3844 // DON'T USE THIS ON THE MAC OR WINDOWS to determine the current OS release
45 // for OS version-specific feature checks and workarounds. If you must use
46 // an OS version check instead of a feature check, use the base::mac::IsOS*
47 // family from base/mac/mac_util.h, or base::win::GetVersion from
48 // base/win/windows_version.h.
[email protected]f481221192011-04-07 22:15:3449 static void OperatingSystemVersionNumbers(int32* major_version,
50 int32* minor_version,
51 int32* bugfix_version);
[email protected]71aa16c2009-02-24 16:37:1352
[email protected]05f9b682008-09-29 22:18:0153 // Returns the CPU architecture of the system. Exact return value may differ
54 // across platforms.
55 static std::string CPUArchitecture();
56
57 // Returns the pixel dimensions of the primary display via the
58 // width and height parameters.
59 static void GetPrimaryDisplayDimensions(int* width, int* height);
60
61 // Return the number of displays.
62 static int DisplayCount();
[email protected]037fce02009-01-22 01:42:1563
64 // Return the smallest amount of memory (in bytes) which the VM system will
65 // allocate.
66 static size_t VMAllocationGranularity();
[email protected]61b8ad72009-07-22 00:35:1867
[email protected]e43eddf12009-12-29 00:32:5268#if defined(OS_POSIX) && !defined(OS_MACOSX)
[email protected]80a086c52009-08-04 17:52:0469 // Returns the maximum SysV shared memory segment size.
70 static size_t MaxSharedMemorySize();
71#endif
72
[email protected]61b8ad72009-07-22 00:35:1873#if defined(OS_CHROMEOS)
74 // Returns the name of the version entry we wish to look up in the
75 // Linux Standard Base release information file.
76 static std::string GetLinuxStandardBaseVersionKey();
77
78 // Parses /etc/lsb-release to get version information for Google Chrome OS.
79 // Declared here so it can be exposed for unit testing.
80 static void ParseLsbRelease(const std::string& lsb_release,
[email protected]f481221192011-04-07 22:15:3481 int32* major_version,
82 int32* minor_version,
83 int32* bugfix_version);
[email protected]61b8ad72009-07-22 00:35:1884#endif
[email protected]2a758d612008-09-17 10:09:3985};
86
87} // namespace base
88
89#endif // BASE_SYS_INFO_H_