blob: 415dc811605a1d7fd0a32643d50428bd068d7d8b [file] [log] [blame]
[email protected]2a758d612008-09-17 10:09:391// Copyright (c) 2008 The Chromium Authors. All rights reserved.
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
[email protected]d632798e2008-09-17 13:10:458#include "base/basictypes.h"
9
[email protected]0e91dd22008-09-18 12:34:2410#include <string>
11
[email protected]13326bb2009-10-14 00:41:5612class FilePath;
13
[email protected]2a758d612008-09-17 10:09:3914namespace base {
15
16class SysInfo {
17 public:
18 // Return the number of logical processors/cores on the current machine.
19 static int NumberOfProcessors();
[email protected]59658422009-02-11 02:01:5120
[email protected]d632798e2008-09-17 13:10:4521 // Return the number of bytes of physical memory on the current machine.
22 static int64 AmountOfPhysicalMemory();
[email protected]fadf97f2008-09-18 12:18:1423
24 // Return the number of megabytes of physical memory on the current machine.
25 static int AmountOfPhysicalMemoryMB() {
26 return static_cast<int>(AmountOfPhysicalMemory() / 1024 / 1024);
27 }
[email protected]0e91dd22008-09-18 12:34:2428
[email protected]02ee34a2008-09-20 01:16:2329 // Return the available disk space in bytes on the volume containing |path|,
30 // or -1 on failure.
[email protected]13326bb2009-10-14 00:41:5631 static int64 AmountOfFreeDiskSpace(const FilePath& path);
[email protected]0e91dd22008-09-18 12:34:2432
[email protected]05f9b682008-09-29 22:18:0133 // Return true if the given environment variable is defined.
34 // TODO: find a better place for HasEnvVar.
35 static bool HasEnvVar(const wchar_t* var);
36
37 // Return the value of the given environment variable
38 // or an empty string if not defined.
39 // TODO: find a better place for GetEnvVar.
40 static std::wstring GetEnvVar(const wchar_t* var);
41
42 // Returns the name of the host operating system.
43 static std::string OperatingSystemName();
44
45 // Returns the version of the host operating system.
46 static std::string OperatingSystemVersion();
47
[email protected]71aa16c2009-02-24 16:37:1348 // Retrieves detailed numeric values for the OS version.
[email protected]71aa16c2009-02-24 16:37:1349 // TODO(port): Implement a Linux version of this method and enable the
50 // corresponding unit test.
51 static void OperatingSystemVersionNumbers(int32 *major_version,
52 int32 *minor_version,
53 int32 *bugfix_version);
54
[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
59 // Returns the pixel dimensions of the primary display via the
60 // width and height parameters.
61 static void GetPrimaryDisplayDimensions(int* width, int* height);
62
63 // Return the number of displays.
64 static int DisplayCount();
[email protected]037fce02009-01-22 01:42:1565
66 // Return the smallest amount of memory (in bytes) which the VM system will
67 // allocate.
68 static size_t VMAllocationGranularity();
[email protected]61b8ad72009-07-22 00:35:1869
[email protected]e43eddf12009-12-29 00:32:5270#if defined(OS_POSIX) && !defined(OS_MACOSX)
[email protected]80a086c52009-08-04 17:52:0471 // Returns the maximum SysV shared memory segment size.
72 static size_t MaxSharedMemorySize();
73#endif
74
[email protected]61b8ad72009-07-22 00:35:1875#if defined(OS_CHROMEOS)
76 // Returns the name of the version entry we wish to look up in the
77 // Linux Standard Base release information file.
78 static std::string GetLinuxStandardBaseVersionKey();
79
80 // Parses /etc/lsb-release to get version information for Google Chrome OS.
81 // Declared here so it can be exposed for unit testing.
82 static void ParseLsbRelease(const std::string& lsb_release,
83 int32 *major_version,
84 int32 *minor_version,
85 int32 *bugfix_version);
86#endif
[email protected]2a758d612008-09-17 10:09:3987};
88
89} // namespace base
90
91#endif // BASE_SYS_INFO_H_