ipc/chromium/src/base/sys_info.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ipc/chromium/src/base/sys_info.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,83 @@
     1.4 +// Copyright (c) 2008 The Chromium Authors. All rights reserved.
     1.5 +// Use of this source code is governed by a BSD-style license that can be
     1.6 +// found in the LICENSE file.
     1.7 +
     1.8 +#ifndef BASE_SYS_INFO_H_
     1.9 +#define BASE_SYS_INFO_H_
    1.10 +
    1.11 +#include "base/basictypes.h"
    1.12 +
    1.13 +#include <string>
    1.14 +
    1.15 +namespace base {
    1.16 +
    1.17 +class SysInfo {
    1.18 + public:
    1.19 +  // Return the number of logical processors/cores on the current machine.
    1.20 +  // WARNING: On POSIX, this method uses static variables and is not threadsafe
    1.21 +  // until it's been initialized by being called once without a race.
    1.22 +  static int NumberOfProcessors();
    1.23 +
    1.24 +  // Return the number of bytes of physical memory on the current machine.
    1.25 +  static int64_t AmountOfPhysicalMemory();
    1.26 +
    1.27 +  // Return the number of megabytes of physical memory on the current machine.
    1.28 +  static int AmountOfPhysicalMemoryMB() {
    1.29 +    return static_cast<int>(AmountOfPhysicalMemory() / 1024 / 1024);
    1.30 +  }
    1.31 +
    1.32 +  // Return the available disk space in bytes on the volume containing |path|,
    1.33 +  // or -1 on failure.
    1.34 +  static int64_t AmountOfFreeDiskSpace(const std::wstring& path);
    1.35 +
    1.36 +  // Return true if the given environment variable is defined.
    1.37 +  // TODO: find a better place for HasEnvVar.
    1.38 +  static bool HasEnvVar(const wchar_t* var);
    1.39 +
    1.40 +  // Return the value of the given environment variable
    1.41 +  // or an empty string if not defined.
    1.42 +  // TODO: find a better place for GetEnvVar.
    1.43 +  static std::wstring GetEnvVar(const wchar_t* var);
    1.44 +
    1.45 +  // Returns the name of the host operating system.
    1.46 +  static std::string OperatingSystemName();
    1.47 +
    1.48 +  // Returns the version of the host operating system.
    1.49 +  static std::string OperatingSystemVersion();
    1.50 +
    1.51 +  // Retrieves detailed numeric values for the OS version.
    1.52 +  // WARNING: On OS X, this method uses static variables and is not threadsafe
    1.53 +  // until it's been initialized by being called once without a race.
    1.54 +  // TODO(port): Implement a Linux version of this method and enable the
    1.55 +  // corresponding unit test.
    1.56 +  static void OperatingSystemVersionNumbers(int32_t *major_version,
    1.57 +                                            int32_t *minor_version,
    1.58 +                                            int32_t *bugfix_version);
    1.59 +
    1.60 +  // Returns the CPU architecture of the system. Exact return value may differ
    1.61 +  // across platforms.
    1.62 +  static std::string CPUArchitecture();
    1.63 +
    1.64 +  // Returns the pixel dimensions of the primary display via the
    1.65 +  // width and height parameters.
    1.66 +  static void GetPrimaryDisplayDimensions(int* width, int* height);
    1.67 +
    1.68 +  // Return the number of displays.
    1.69 +  static int DisplayCount();
    1.70 +
    1.71 +  // Return the smallest amount of memory (in bytes) which the VM system will
    1.72 +  // allocate.
    1.73 +  static size_t VMAllocationGranularity();
    1.74 +
    1.75 +#if defined(OS_MACOSX)
    1.76 +  // Under the OS X Sandbox, our access to the system is limited, this call
    1.77 +  // caches the system info on startup before we turn the Sandbox on.
    1.78 +  // The above functions are all wired up to return the cached value so the rest
    1.79 +  // of the code can call them in the Sandbox without worrying.
    1.80 +  static void CacheSysInfo();
    1.81 +#endif
    1.82 +};
    1.83 +
    1.84 +}  // namespace base
    1.85 +
    1.86 +#endif  // BASE_SYS_INFO_H_

mercurial