Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
michael@0 | 2 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 3 | // found in the LICENSE file. |
michael@0 | 4 | |
michael@0 | 5 | #ifndef BASE_SYS_INFO_H_ |
michael@0 | 6 | #define BASE_SYS_INFO_H_ |
michael@0 | 7 | |
michael@0 | 8 | #include <string> |
michael@0 | 9 | |
michael@0 | 10 | #include "base/base_export.h" |
michael@0 | 11 | #include "base/basictypes.h" |
michael@0 | 12 | #include "base/files/file_path.h" |
michael@0 | 13 | #include "build/build_config.h" |
michael@0 | 14 | |
michael@0 | 15 | namespace base { |
michael@0 | 16 | |
michael@0 | 17 | class BASE_EXPORT SysInfo { |
michael@0 | 18 | public: |
michael@0 | 19 | // Return the number of logical processors/cores on the current machine. |
michael@0 | 20 | static int NumberOfProcessors(); |
michael@0 | 21 | |
michael@0 | 22 | // Return the number of bytes of physical memory on the current machine. |
michael@0 | 23 | static int64 AmountOfPhysicalMemory(); |
michael@0 | 24 | |
michael@0 | 25 | // Return the number of bytes of current available physical memory on the |
michael@0 | 26 | // machine. |
michael@0 | 27 | static int64 AmountOfAvailablePhysicalMemory(); |
michael@0 | 28 | |
michael@0 | 29 | // Return the number of megabytes of physical memory on the current machine. |
michael@0 | 30 | static int AmountOfPhysicalMemoryMB() { |
michael@0 | 31 | return static_cast<int>(AmountOfPhysicalMemory() / 1024 / 1024); |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | // Return the available disk space in bytes on the volume containing |path|, |
michael@0 | 35 | // or -1 on failure. |
michael@0 | 36 | static int64 AmountOfFreeDiskSpace(const FilePath& path); |
michael@0 | 37 | |
michael@0 | 38 | // Returns system uptime in milliseconds. |
michael@0 | 39 | static int64 Uptime(); |
michael@0 | 40 | |
michael@0 | 41 | // Returns the name of the host operating system. |
michael@0 | 42 | static std::string OperatingSystemName(); |
michael@0 | 43 | |
michael@0 | 44 | // Returns the version of the host operating system. |
michael@0 | 45 | static std::string OperatingSystemVersion(); |
michael@0 | 46 | |
michael@0 | 47 | // Retrieves detailed numeric values for the OS version. |
michael@0 | 48 | // TODO(port): Implement a Linux version of this method and enable the |
michael@0 | 49 | // corresponding unit test. |
michael@0 | 50 | // DON'T USE THIS ON THE MAC OR WINDOWS to determine the current OS release |
michael@0 | 51 | // for OS version-specific feature checks and workarounds. If you must use |
michael@0 | 52 | // an OS version check instead of a feature check, use the base::mac::IsOS* |
michael@0 | 53 | // family from base/mac/mac_util.h, or base::win::GetVersion from |
michael@0 | 54 | // base/win/windows_version.h. |
michael@0 | 55 | static void OperatingSystemVersionNumbers(int32* major_version, |
michael@0 | 56 | int32* minor_version, |
michael@0 | 57 | int32* bugfix_version); |
michael@0 | 58 | |
michael@0 | 59 | // Returns the architecture of the running operating system. |
michael@0 | 60 | // Exact return value may differ across platforms. |
michael@0 | 61 | // e.g. a 32-bit x86 kernel on a 64-bit capable CPU will return "x86", |
michael@0 | 62 | // whereas a x86-64 kernel on the same CPU will return "x86_64" |
michael@0 | 63 | static std::string OperatingSystemArchitecture(); |
michael@0 | 64 | |
michael@0 | 65 | // Avoid using this. Use base/cpu.h to get information about the CPU instead. |
michael@0 | 66 | // http://crbug.com/148884 |
michael@0 | 67 | // Returns the CPU model name of the system. If it can not be figured out, |
michael@0 | 68 | // an empty string is returned. |
michael@0 | 69 | static std::string CPUModelName(); |
michael@0 | 70 | |
michael@0 | 71 | // Return the smallest amount of memory (in bytes) which the VM system will |
michael@0 | 72 | // allocate. |
michael@0 | 73 | static size_t VMAllocationGranularity(); |
michael@0 | 74 | |
michael@0 | 75 | #if defined(OS_POSIX) && !defined(OS_MACOSX) |
michael@0 | 76 | // Returns the maximum SysV shared memory segment size. |
michael@0 | 77 | static size_t MaxSharedMemorySize(); |
michael@0 | 78 | #endif // defined(OS_POSIX) && !defined(OS_MACOSX) |
michael@0 | 79 | |
michael@0 | 80 | #if defined(OS_CHROMEOS) |
michael@0 | 81 | // Returns the name of the version entry we wish to look up in the |
michael@0 | 82 | // Linux Standard Base release information file. |
michael@0 | 83 | static std::string GetLinuxStandardBaseVersionKey(); |
michael@0 | 84 | |
michael@0 | 85 | // Parses /etc/lsb-release to get version information for Google Chrome OS. |
michael@0 | 86 | // Declared here so it can be exposed for unit testing. |
michael@0 | 87 | static void ParseLsbRelease(const std::string& lsb_release, |
michael@0 | 88 | int32* major_version, |
michael@0 | 89 | int32* minor_version, |
michael@0 | 90 | int32* bugfix_version); |
michael@0 | 91 | |
michael@0 | 92 | // Returns the path to the lsb-release file. |
michael@0 | 93 | static FilePath GetLsbReleaseFilePath(); |
michael@0 | 94 | #endif // defined(OS_CHROMEOS) |
michael@0 | 95 | |
michael@0 | 96 | #if defined(OS_ANDROID) |
michael@0 | 97 | // Returns the Android build's codename. |
michael@0 | 98 | static std::string GetAndroidBuildCodename(); |
michael@0 | 99 | |
michael@0 | 100 | // Returns the Android build ID. |
michael@0 | 101 | static std::string GetAndroidBuildID(); |
michael@0 | 102 | |
michael@0 | 103 | // Returns the device's name. |
michael@0 | 104 | static std::string GetDeviceName(); |
michael@0 | 105 | |
michael@0 | 106 | static int DalvikHeapSizeMB(); |
michael@0 | 107 | static int DalvikHeapGrowthLimitMB(); |
michael@0 | 108 | #endif // defined(OS_ANDROID) |
michael@0 | 109 | }; |
michael@0 | 110 | |
michael@0 | 111 | } // namespace base |
michael@0 | 112 | |
michael@0 | 113 | #endif // BASE_SYS_INFO_H_ |