Add creis, davidben, and mmenke to content/browser/loader/OWNERs.
[chromium-blink-merge.git] / base / sys_info.h
blobaa40cadfbc93791dc57b9513554bea33d4b05c3b
1 // Copyright (c) 2012 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.
5 #ifndef BASE_SYS_INFO_H_
6 #define BASE_SYS_INFO_H_
8 #include <map>
9 #include <string>
11 #include "base/base_export.h"
12 #include "base/basictypes.h"
13 #include "base/files/file_path.h"
14 #include "base/time/time.h"
15 #include "build/build_config.h"
17 namespace base {
19 class BASE_EXPORT SysInfo {
20 public:
21 // Return the number of logical processors/cores on the current machine.
22 static int NumberOfProcessors();
24 // Return the number of bytes of physical memory on the current machine.
25 static int64 AmountOfPhysicalMemory();
27 // Return the number of bytes of current available physical memory on the
28 // machine.
29 static int64 AmountOfAvailablePhysicalMemory();
31 // Return the number of megabytes of physical memory on the current machine.
32 static int AmountOfPhysicalMemoryMB() {
33 return static_cast<int>(AmountOfPhysicalMemory() / 1024 / 1024);
36 // Return the available disk space in bytes on the volume containing |path|,
37 // or -1 on failure.
38 static int64 AmountOfFreeDiskSpace(const FilePath& path);
40 // Returns system uptime in milliseconds.
41 static int64 Uptime();
43 // Returns the name of the host operating system.
44 static std::string OperatingSystemName();
46 // Returns the version of the host operating system.
47 static std::string OperatingSystemVersion();
49 // Retrieves detailed numeric values for the OS version.
50 // TODO(port): Implement a Linux version of this method and enable the
51 // corresponding unit test.
52 // DON'T USE THIS ON THE MAC OR WINDOWS to determine the current OS release
53 // for OS version-specific feature checks and workarounds. If you must use
54 // an OS version check instead of a feature check, use the base::mac::IsOS*
55 // family from base/mac/mac_util.h, or base::win::GetVersion from
56 // base/win/windows_version.h.
57 static void OperatingSystemVersionNumbers(int32* major_version,
58 int32* minor_version,
59 int32* bugfix_version);
61 // Returns the architecture of the running operating system.
62 // Exact return value may differ across platforms.
63 // e.g. a 32-bit x86 kernel on a 64-bit capable CPU will return "x86",
64 // whereas a x86-64 kernel on the same CPU will return "x86_64"
65 static std::string OperatingSystemArchitecture();
67 // Avoid using this. Use base/cpu.h to get information about the CPU instead.
68 // http://crbug.com/148884
69 // Returns the CPU model name of the system. If it can not be figured out,
70 // an empty string is returned.
71 static std::string CPUModelName();
73 // Return the smallest amount of memory (in bytes) which the VM system will
74 // allocate.
75 static size_t VMAllocationGranularity();
77 #if defined(OS_POSIX) && !defined(OS_MACOSX)
78 // Returns the maximum SysV shared memory segment size, or zero if there is no
79 // limit.
80 static size_t MaxSharedMemorySize();
81 #endif // defined(OS_POSIX) && !defined(OS_MACOSX)
83 #if defined(OS_CHROMEOS)
84 typedef std::map<std::string, std::string> LsbReleaseMap;
86 // Returns the contents of /etc/lsb-release as a map.
87 static const LsbReleaseMap& GetLsbReleaseMap();
89 // If |key| is present in the LsbReleaseMap, sets |value| and returns true.
90 static bool GetLsbReleaseValue(const std::string& key, std::string* value);
92 // Convenience function for GetLsbReleaseValue("CHROMEOS_RELEASE_BOARD",...).
93 // Returns "unknown" if CHROMEOS_RELEASE_BOARD is not set.
94 static std::string GetLsbReleaseBoard();
96 // Returns the creation time of /etc/lsb-release. (Used to get the date and
97 // time of the Chrome OS build).
98 static Time GetLsbReleaseTime();
100 // Returns true when actually running in a Chrome OS environment.
101 static bool IsRunningOnChromeOS();
103 // Test method to force re-parsing of lsb-release.
104 static void SetChromeOSVersionInfoForTest(const std::string& lsb_release,
105 const Time& lsb_release_time);
106 #endif // defined(OS_CHROMEOS)
108 #if defined(OS_ANDROID)
109 // Returns the Android build's codename.
110 static std::string GetAndroidBuildCodename();
112 // Returns the Android build ID.
113 static std::string GetAndroidBuildID();
115 // Returns the device's name.
116 static std::string GetDeviceName();
118 static int DalvikHeapSizeMB();
119 static int DalvikHeapGrowthLimitMB();
120 #endif // defined(OS_ANDROID)
123 } // namespace base
125 #endif // BASE_SYS_INFO_H_