ipc/chromium/src/base/sys_info.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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

mercurial