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.
1 // 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.
5 #ifndef BASE_SYS_INFO_H_
6 #define BASE_SYS_INFO_H_
8 #include "base/basictypes.h"
10 #include <string>
12 namespace base {
14 class SysInfo {
15 public:
16 // Return the number of logical processors/cores on the current machine.
17 // WARNING: On POSIX, this method uses static variables and is not threadsafe
18 // until it's been initialized by being called once without a race.
19 static int NumberOfProcessors();
21 // Return the number of bytes of physical memory on the current machine.
22 static int64_t AmountOfPhysicalMemory();
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 }
29 // Return the available disk space in bytes on the volume containing |path|,
30 // or -1 on failure.
31 static int64_t AmountOfFreeDiskSpace(const std::wstring& path);
33 // 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);
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);
42 // Returns the name of the host operating system.
43 static std::string OperatingSystemName();
45 // Returns the version of the host operating system.
46 static std::string OperatingSystemVersion();
48 // Retrieves detailed numeric values for the OS version.
49 // WARNING: On OS X, this method uses static variables and is not threadsafe
50 // until it's been initialized by being called once without a race.
51 // TODO(port): Implement a Linux version of this method and enable the
52 // corresponding unit test.
53 static void OperatingSystemVersionNumbers(int32_t *major_version,
54 int32_t *minor_version,
55 int32_t *bugfix_version);
57 // Returns the CPU architecture of the system. Exact return value may differ
58 // across platforms.
59 static std::string CPUArchitecture();
61 // Returns the pixel dimensions of the primary display via the
62 // width and height parameters.
63 static void GetPrimaryDisplayDimensions(int* width, int* height);
65 // Return the number of displays.
66 static int DisplayCount();
68 // Return the smallest amount of memory (in bytes) which the VM system will
69 // allocate.
70 static size_t VMAllocationGranularity();
72 #if defined(OS_MACOSX)
73 // Under the OS X Sandbox, our access to the system is limited, this call
74 // caches the system info on startup before we turn the Sandbox on.
75 // The above functions are all wired up to return the cached value so the rest
76 // of the code can call them in the Sandbox without worrying.
77 static void CacheSysInfo();
78 #endif
79 };
81 } // namespace base
83 #endif // BASE_SYS_INFO_H_