blob: 7460fe09a66319242d56bc8a6b328af591f22c99 [file] [log] [blame]
deanm@chromium.org42a34eb2008-09-17 19:09:39 +09001// 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
deanm@chromium.org319f0442008-09-17 22:10:45 +09008#include "base/basictypes.h"
9
deanm@chromium.orgee45e8f2008-09-18 21:34:24 +090010#include <string>
11
tony@chromium.org1e25e002009-10-14 09:41:56 +090012class FilePath;
13
deanm@chromium.org42a34eb2008-09-17 19:09:39 +090014namespace base {
15
16class SysInfo {
17 public:
18 // Return the number of logical processors/cores on the current machine.
19 static int NumberOfProcessors();
jeremy@chromium.org0da11fa2009-02-11 11:01:51 +090020
deanm@chromium.org319f0442008-09-17 22:10:45 +090021 // Return the number of bytes of physical memory on the current machine.
22 static int64 AmountOfPhysicalMemory();
deanm@chromium.org530ddd92008-09-18 21:18:14 +090023
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 }
deanm@chromium.orgee45e8f2008-09-18 21:34:24 +090028
rvargas@google.comaf000292008-09-20 10:16:23 +090029 // Return the available disk space in bytes on the volume containing |path|,
30 // or -1 on failure.
tony@chromium.org1e25e002009-10-14 09:41:56 +090031 static int64 AmountOfFreeDiskSpace(const FilePath& path);
deanm@chromium.orgee45e8f2008-09-18 21:34:24 +090032
mark@chromium.orgb93c0542008-09-30 07:18:01 +090033 // 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
jeremy@chromium.org7730edb2009-02-25 01:37:13 +090048 // Retrieves detailed numeric values for the OS version.
jeremy@chromium.org7730edb2009-02-25 01:37:13 +090049 // 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
mark@chromium.orgb93c0542008-09-30 07:18:01 +090055 // 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();
agl@chromium.org3d71fda2009-01-22 10:42:15 +090065
66 // Return the smallest amount of memory (in bytes) which the VM system will
67 // allocate.
68 static size_t VMAllocationGranularity();
evan@chromium.org54b72102009-07-22 09:35:18 +090069
agl@chromium.org3319f0a2009-08-05 02:52:04 +090070#if defined(OS_LINUX)
71 // Returns the maximum SysV shared memory segment size.
72 static size_t MaxSharedMemorySize();
73#endif
74
evan@chromium.org54b72102009-07-22 09:35:18 +090075#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
deanm@chromium.org42a34eb2008-09-17 19:09:39 +090087};
88
89} // namespace base
90
91#endif // BASE_SYS_INFO_H_