Move SystemInfo to rtc_base_approved and delete unused code.

This cl removes a lot of unused functionality in SystemInfo and reduces dependencies.
There's duplicate functionality in this class and WebRTC's CpuInfo class, so I'm consolidating the two implementations.
The CpuInfo interface will still exist since it's being used from Chrome to initialize the core count before the sandbox is engaged.
With this change, the SystemInfo class will get the benefit too of this initialization.

NOTRY=true
(using no try due to a dead android try bot)

Review URL: https://codereview.webrtc.org/1286163003

Cr-Commit-Position: refs/heads/master@{#9743}
diff --git a/webrtc/base/BUILD.gn b/webrtc/base/BUILD.gn
index 573de14..fbe5dd5 100644
--- a/webrtc/base/BUILD.gn
+++ b/webrtc/base/BUILD.gn
@@ -146,6 +146,8 @@
     "stringencode.h",
     "stringutils.cc",
     "stringutils.h",
+    "systeminfo.cc",
+    "systeminfo.h",
     "template_util.h",
     "thread_annotations.h",
     "thread_checker.h",
@@ -312,8 +314,6 @@
     "sslstreamadapterhelper.h",
     "stream.cc",
     "stream.h",
-    "systeminfo.cc",
-    "systeminfo.h",
     "task.cc",
     "task.h",
     "taskparent.cc",
diff --git a/webrtc/base/base.gyp b/webrtc/base/base.gyp
index 780ae7f..37646a8 100644
--- a/webrtc/base/base.gyp
+++ b/webrtc/base/base.gyp
@@ -72,6 +72,8 @@
         'stringencode.h',
         'stringutils.cc',
         'stringutils.h',
+        'systeminfo.cc',
+        'systeminfo.h',
         'template_util.h',
         'thread_annotations.h',
         'thread_checker.h',
@@ -297,8 +299,6 @@
         'sslstreamadapterhelper.h',
         'stream.cc',
         'stream.h',
-        'systeminfo.cc',
-        'systeminfo.h',
         'task.cc',
         'task.h',
         'taskparent.cc',
diff --git a/webrtc/base/systeminfo.cc b/webrtc/base/systeminfo.cc
index 6d8d5ba..1dc6a68 100644
--- a/webrtc/base/systeminfo.cc
+++ b/webrtc/base/systeminfo.cc
@@ -12,6 +12,7 @@
 
 #if defined(WEBRTC_WIN)
 #include <winsock2.h>
+#include <windows.h>
 #ifndef EXCLUDE_D3D9
 #include <d3d9.h>
 #endif
@@ -26,14 +27,6 @@
 #include <sys/sysctl.h>
 #endif
 
-#if defined(WEBRTC_WIN)
-#include "webrtc/base/scoped_ptr.h"
-#include "webrtc/base/win32.h"
-#elif defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
-#include "webrtc/base/macconversion.h"
-#elif defined(WEBRTC_LINUX)
-#include "webrtc/base/linux.h"
-#endif
 #include "webrtc/base/common.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/stringutils.h"
@@ -41,47 +34,7 @@
 namespace rtc {
 
 // See Also: http://msdn.microsoft.com/en-us/library/ms683194(v=vs.85).aspx
-#if defined(WEBRTC_WIN)
-typedef BOOL (WINAPI *LPFN_GLPI)(
-    PSYSTEM_LOGICAL_PROCESSOR_INFORMATION,
-    PDWORD);
-
-static void GetProcessorInformation(int* physical_cpus, int* cache_size) {
-  // GetLogicalProcessorInformation() is available on Windows XP SP3 and beyond.
-  LPFN_GLPI glpi = reinterpret_cast<LPFN_GLPI>(GetProcAddress(
-      GetModuleHandle(L"kernel32"),
-      "GetLogicalProcessorInformation"));
-  if (NULL == glpi) {
-    return;
-  }
-  // Determine buffer size, allocate and get processor information.
-  // Size can change between calls (unlikely), so a loop is done.
-  DWORD return_length = 0;
-  scoped_ptr<SYSTEM_LOGICAL_PROCESSOR_INFORMATION[]> infos;
-  while (!glpi(infos.get(), &return_length)) {
-    if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
-      infos.reset(new SYSTEM_LOGICAL_PROCESSOR_INFORMATION[
-          return_length / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION)]);
-    } else {
-      return;
-    }
-  }
-  *physical_cpus = 0;
-  *cache_size = 0;
-  for (size_t i = 0;
-      i < return_length / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION); ++i) {
-    if (infos[i].Relationship == RelationProcessorCore) {
-      ++*physical_cpus;
-    } else if (infos[i].Relationship == RelationCache) {
-      int next_cache_size = static_cast<int>(infos[i].Cache.Size);
-      if (next_cache_size >= *cache_size) {
-        *cache_size = next_cache_size;
-      }
-    }
-  }
-  return;
-}
-#else
+#if !defined(WEBRTC_WIN)
 // TODO(fbarchard): Use gcc 4.4 provided cpuid intrinsic
 // 32 bit fpic requires ebx be preserved
 #if (defined(__pic__) || defined(__APPLE__)) && defined(__i386__)
@@ -103,134 +56,64 @@
   );  // NOLINT
 }
 #endif
-#endif  // WEBRTC_WIN 
+#endif  // WEBRTC_WIN
 
-// Note(fbarchard):
-// Family and model are extended family and extended model.  8 bits each.
-SystemInfo::SystemInfo()
-    : physical_cpus_(1), logical_cpus_(1), cache_size_(0),
-      cpu_family_(0), cpu_model_(0), cpu_stepping_(0),
-      cpu_speed_(0), memory_(0) {
-  // Initialize the basic information.
-#if defined(__arm__) || defined(_M_ARM)
-  cpu_arch_ = SI_ARCH_ARM;
-#elif defined(__x86_64__) || defined(_M_X64)
-  cpu_arch_ = SI_ARCH_X64;
-#elif defined(__i386__) || defined(_M_IX86)
-  cpu_arch_ = SI_ARCH_X86;
-#else
-  cpu_arch_ = SI_ARCH_UNKNOWN;
-#endif
+static int DetectNumberOfCores() {
+  // We fall back on assuming a single core in case of errors.
+  int number_of_cores = 1;
 
 #if defined(WEBRTC_WIN)
   SYSTEM_INFO si;
   GetSystemInfo(&si);
-  logical_cpus_ = si.dwNumberOfProcessors;
-  GetProcessorInformation(&physical_cpus_, &cache_size_);
-  if (physical_cpus_ <= 0) {
-    physical_cpus_ = logical_cpus_;
-  }
-  cpu_family_ = si.wProcessorLevel;
-  cpu_model_ = si.wProcessorRevision >> 8;
-  cpu_stepping_ = si.wProcessorRevision & 0xFF;
+  number_of_cores = static_cast<int>(si.dwNumberOfProcessors);
+#elif defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID)
+  number_of_cores = static_cast<int>(sysconf(_SC_NPROCESSORS_ONLN));
 #elif defined(WEBRTC_MAC)
-  uint32_t sysctl_value;
-  size_t length = sizeof(sysctl_value);
-  if (!sysctlbyname("hw.physicalcpu_max", &sysctl_value, &length, NULL, 0)) {
-    physical_cpus_ = static_cast<int>(sysctl_value);
+  int name[] = {CTL_HW, HW_AVAILCPU};
+  size_t size = sizeof(number_of_cores);
+  if (0 != sysctl(name, 2, &number_of_cores, &size, NULL, 0)) {
+    LOG(LS_ERROR) << "Failed to get number of cores";
+    number_of_cores = 1;
   }
-  length = sizeof(sysctl_value);
-  if (!sysctlbyname("hw.logicalcpu_max", &sysctl_value, &length, NULL, 0)) {
-    logical_cpus_ = static_cast<int>(sysctl_value);
-  }
-  uint64_t sysctl_value64;
-  length = sizeof(sysctl_value64);
-  if (!sysctlbyname("hw.l3cachesize", &sysctl_value64, &length, NULL, 0)) {
-    cache_size_ = static_cast<int>(sysctl_value64);
-  }
-  if (!cache_size_) {
-    length = sizeof(sysctl_value64);
-    if (!sysctlbyname("hw.l2cachesize", &sysctl_value64, &length, NULL, 0)) {
-      cache_size_ = static_cast<int>(sysctl_value64);
-    }
-  }
-  length = sizeof(sysctl_value);
-  if (!sysctlbyname("machdep.cpu.family", &sysctl_value, &length, NULL, 0)) {
-    cpu_family_ = static_cast<int>(sysctl_value);
-  }
-  length = sizeof(sysctl_value);
-  if (!sysctlbyname("machdep.cpu.model", &sysctl_value, &length, NULL, 0)) {
-    cpu_model_ = static_cast<int>(sysctl_value);
-  }
-  length = sizeof(sysctl_value);
-  if (!sysctlbyname("machdep.cpu.stepping", &sysctl_value, &length, NULL, 0)) {
-    cpu_stepping_ = static_cast<int>(sysctl_value);
-  }
-#elif defined(__native_client__)
-  // TODO(ryanpetrie): Implement this via PPAPI when it's available.
-#else  // WEBRTC_LINUX
-  ProcCpuInfo proc_info;
-  if (proc_info.LoadFromSystem()) {
-    proc_info.GetNumCpus(&logical_cpus_);
-    proc_info.GetNumPhysicalCpus(&physical_cpus_);
-    proc_info.GetCpuFamily(&cpu_family_);
-#if defined(CPU_X86)
-    // These values only apply to x86 systems.
-    proc_info.GetSectionIntValue(0, "model", &cpu_model_);
-    proc_info.GetSectionIntValue(0, "stepping", &cpu_stepping_);
-    proc_info.GetSectionIntValue(0, "cpu MHz", &cpu_speed_);
-    proc_info.GetSectionIntValue(0, "cache size", &cache_size_);
-    cache_size_ *= 1024;
+#else
+  LOG(LS_ERROR) << "No function to get number of cores";
 #endif
-  }
-  // ProcCpuInfo reads cpu speed from "cpu MHz" under /proc/cpuinfo.
-  // But that number is a moving target which can change on-the-fly according to
-  // many factors including system workload.
-  // See /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors.
-  // The one in /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq is more
-  // accurate. We use it as our cpu speed when it is available.
-  // cpuinfo_max_freq is measured in KHz and requires conversion to MHz.
-  int max_freq = rtc::ReadCpuMaxFreq();
-  if (max_freq > 0) {
-    cpu_speed_ = max_freq / 1000;
-  }
-#endif
-// For L2 CacheSize see also
-// http://www.flounder.com/cpuid_explorer2.htm#CPUID(0x800000006)
-#ifdef CPU_X86
-  if (cache_size_ == 0) {
-    int cpu_info[4];
-    __cpuid(cpu_info, 0x80000000);  // query maximum extended cpuid function.
-    if (static_cast<uint32>(cpu_info[0]) >= 0x80000006) {
-      __cpuid(cpu_info, 0x80000006);
-      cache_size_ = (cpu_info[2] >> 16) * 1024;
-    }
-  }
-#endif
+
+  LOG(LS_INFO) << "Available number of cores: " << number_of_cores;
+
+  return number_of_cores;
+}
+
+// Statically cache the number of system cores available since if the process
+// is running in a sandbox, we may only be able to read the value once (before
+// the sandbox is initialized) and not thereafter.
+// For more information see crbug.com/176522.
+int SystemInfo::logical_cpus_ = 0;
+
+SystemInfo::SystemInfo() {
 }
 
 // Return the number of cpu threads available to the system.
+// static
 int SystemInfo::GetMaxCpus() {
+  if (!logical_cpus_)
+    logical_cpus_ = DetectNumberOfCores();
   return logical_cpus_;
 }
 
-// Return the number of cpu cores available to the system.
-int SystemInfo::GetMaxPhysicalCpus() {
-  return physical_cpus_;
-}
-
 // Return the number of cpus available to the process.  Since affinity can be
 // changed on the fly, do not cache this value.
 // Can be affected by heat.
 int SystemInfo::GetCurCpus() {
-  int cur_cpus;
+  int cur_cpus = 0;
 #if defined(WEBRTC_WIN)
-  DWORD_PTR process_mask, system_mask;
+  DWORD_PTR process_mask = 0;
+  DWORD_PTR system_mask = 0;
   ::GetProcessAffinityMask(::GetCurrentProcess(), &process_mask, &system_mask);
-  for (cur_cpus = 0; process_mask; ++cur_cpus) {
-    // Sparse-ones algorithm. There are slightly faster methods out there but
-    // they are unintuitive and won't make a difference on a single dword.
-    process_mask &= (process_mask - 1);
+  for (int i = 0; i < sizeof(DWORD_PTR) * 8; ++i) {
+    if (process_mask & 1)
+      ++cur_cpus;
+    process_mask >>= 1;
   }
 #elif defined(WEBRTC_MAC)
   uint32_t sysctl_value;
@@ -239,285 +122,92 @@
   cur_cpus = !error ? static_cast<int>(sysctl_value) : 1;
 #else
   // Linux, Solaris, WEBRTC_ANDROID
-  cur_cpus = static_cast<int>(sysconf(_SC_NPROCESSORS_ONLN));
+  cur_cpus = GetMaxCpus();
 #endif
   return cur_cpus;
 }
 
 // Return the type of this CPU.
 SystemInfo::Architecture SystemInfo::GetCpuArchitecture() {
-  return cpu_arch_;
+#if defined(__arm__) || defined(_M_ARM)
+  return SI_ARCH_ARM;
+#elif defined(__x86_64__) || defined(_M_X64)
+  return SI_ARCH_X64;
+#elif defined(__i386__) || defined(_M_IX86)
+  return SI_ARCH_X86;
+#else
+  return SI_ARCH_UNKNOWN;
+#endif
 }
 
 // Returns the vendor string from the cpu, e.g. "GenuineIntel", "AuthenticAMD".
 // See "Intel Processor Identification and the CPUID Instruction"
 // (Intel document number: 241618)
 std::string SystemInfo::GetCpuVendor() {
-  if (cpu_vendor_.empty()) {
 #if defined(CPU_X86)
-    int cpu_info[4];
-    __cpuid(cpu_info, 0);
-    cpu_info[0] = cpu_info[1];  // Reorder output
-    cpu_info[1] = cpu_info[3];
-    // cpu_info[2] = cpu_info[2];  // Avoid -Werror=self-assign
-    cpu_info[3] = 0;
-    cpu_vendor_ = std::string(reinterpret_cast<char*>(&cpu_info[0]));
+  int cpu_info[4];
+  __cpuid(cpu_info, 0);
+  cpu_info[0] = cpu_info[1];  // Reorder output
+  cpu_info[1] = cpu_info[3];
+  // cpu_info[2] = cpu_info[2];  // Avoid -Werror=self-assign
+  cpu_info[3] = 0;
+  return std::string(reinterpret_cast<char*>(&cpu_info[0]));
 #elif defined(CPU_ARM)
-    cpu_vendor_ = std::string("ARM");
+  return "ARM";
 #else
-    cpu_vendor_ = std::string("Undefined");
-#endif
-  }
-  return cpu_vendor_;
-}
-
-int SystemInfo::GetCpuCacheSize() {
-  return cache_size_;
-}
-
-// Return the "family" of this CPU.
-int SystemInfo::GetCpuFamily() {
-  return cpu_family_;
-}
-
-// Return the "model" of this CPU.
-int SystemInfo::GetCpuModel() {
-  return cpu_model_;
-}
-
-// Return the "stepping" of this CPU.
-int SystemInfo::GetCpuStepping() {
-  return cpu_stepping_;
-}
-
-// Return the clockrate of the primary processor in Mhz.  This value can be
-// cached.  Returns -1 on error.
-int SystemInfo::GetMaxCpuSpeed() {
-  if (cpu_speed_) {
-    return cpu_speed_;
-  }
-#if defined(WEBRTC_WIN)
-  HKEY key;
-  static const WCHAR keyName[] =
-      L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0";
-
-  if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyName , 0, KEY_QUERY_VALUE, &key)
-      == ERROR_SUCCESS) {
-    DWORD data, len;
-    len = sizeof(data);
-
-    if (RegQueryValueEx(key, L"~Mhz", 0, 0, reinterpret_cast<LPBYTE>(&data),
-                        &len) == ERROR_SUCCESS) {
-      cpu_speed_ = data;
-    } else {
-      LOG(LS_WARNING) << "Failed to query registry value HKLM\\" << keyName
-                      << "\\~Mhz";
-      cpu_speed_ = -1;
-    }
-
-    RegCloseKey(key);
-  } else {
-    LOG(LS_WARNING) << "Failed to open registry key HKLM\\" << keyName;
-    cpu_speed_ = -1;
-  }
-#elif defined(WEBRTC_MAC)
-  uint64_t sysctl_value;
-  size_t length = sizeof(sysctl_value);
-  int error = sysctlbyname("hw.cpufrequency_max", &sysctl_value, &length,
-                           NULL, 0);
-  cpu_speed_ = !error ? static_cast<int>(sysctl_value/1000000) : -1;
-#else
-  // TODO(fbarchard): Implement using proc/cpuinfo
-  cpu_speed_ = 0;
-#endif
-  return cpu_speed_;
-}
-
-// Dynamically check the current clockrate, which could be reduced because of
-// powersaving profiles.  Eventually for windows we want to query WMI for
-// root\WMI::ProcessorPerformance.InstanceName="Processor_Number_0".frequency
-int SystemInfo::GetCurCpuSpeed() {
-#if defined(WEBRTC_WIN)
-  // TODO(fbarchard): Add WMI check, requires COM initialization
-  // NOTE(fbarchard): Testable on Sandy Bridge.
-  return GetMaxCpuSpeed();
-#elif defined(WEBRTC_MAC)
-  uint64_t sysctl_value;
-  size_t length = sizeof(sysctl_value);
-  int error = sysctlbyname("hw.cpufrequency", &sysctl_value, &length, NULL, 0);
-  return !error ? static_cast<int>(sysctl_value/1000000) : GetMaxCpuSpeed();
-#else  // WEBRTC_LINUX
-  // TODO(fbarchard): Use proc/cpuinfo for Cur speed on Linux.
-  return GetMaxCpuSpeed();
+  return "Undefined";
 #endif
 }
 
 // Returns the amount of installed physical memory in Bytes.  Cacheable.
 // Returns -1 on error.
 int64 SystemInfo::GetMemorySize() {
-  if (memory_) {
-    return memory_;
-  }
+  int64 memory = -1;
 
 #if defined(WEBRTC_WIN)
   MEMORYSTATUSEX status = {0};
   status.dwLength = sizeof(status);
 
   if (GlobalMemoryStatusEx(&status)) {
-    memory_ = status.ullTotalPhys;
+    memory = status.ullTotalPhys;
   } else {
     LOG_GLE(LS_WARNING) << "GlobalMemoryStatusEx failed.";
-    memory_ = -1;
   }
 
 #elif defined(WEBRTC_MAC)
-  size_t len = sizeof(memory_);
-  int error = sysctlbyname("hw.memsize", &memory_, &len, NULL, 0);
-  if (error || memory_ == 0) {
-    memory_ = -1;
-  }
+  size_t len = sizeof(memory);
+  int error = sysctlbyname("hw.memsize", &memory, &len, NULL, 0);
+  if (error || memory == 0)
+    memory = -1;
 #else  // WEBRTC_LINUX
-  memory_ = static_cast<int64>(sysconf(_SC_PHYS_PAGES)) *
+  memory = static_cast<int64>(sysconf(_SC_PHYS_PAGES)) *
       static_cast<int64>(sysconf(_SC_PAGESIZE));
-  if (memory_ < 0) {
+  if (memory < 0) {
     LOG(LS_WARNING) << "sysconf(_SC_PHYS_PAGES) failed."
                     << "sysconf(_SC_PHYS_PAGES) " << sysconf(_SC_PHYS_PAGES)
                     << "sysconf(_SC_PAGESIZE) " << sysconf(_SC_PAGESIZE);
-    memory_ = -1;
+    memory = -1;
   }
 #endif
 
-  return memory_;
+  return memory;
 }
 
-
 // Return the name of the machine model we are currently running on.
 // This is a human readable string that consists of the name and version
 // number of the hardware, i.e 'MacBookAir1,1'. Returns an empty string if
-// model can not be determined. The string is cached for subsequent calls.
+// model can not be determined.
 std::string SystemInfo::GetMachineModel() {
-  if (!machine_model_.empty()) {
-    return machine_model_;
-  }
-
 #if defined(WEBRTC_MAC)
   char buffer[128];
   size_t length = sizeof(buffer);
   int error = sysctlbyname("hw.model", buffer, &length, NULL, 0);
-  if (!error) {
-    machine_model_.assign(buffer, length - 1);
-  } else {
-    machine_model_.clear();
-  }
+  if (!error)
+    return std::string(buffer, length - 1);
+  return std::string();
 #else
-  machine_model_ = "Not available";
-#endif
-
-  return machine_model_;
-}
-
-#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
-// Helper functions to query IOKit for video hardware properties.
-static CFTypeRef SearchForProperty(io_service_t port, CFStringRef name) {
-  return IORegistryEntrySearchCFProperty(port, kIOServicePlane,
-      name, kCFAllocatorDefault,
-      kIORegistryIterateRecursively | kIORegistryIterateParents);
-}
-
-static void GetProperty(io_service_t port, CFStringRef name, int* value) {
-  if (!value) return;
-  CFTypeRef ref = SearchForProperty(port, name);
-  if (ref) {
-    CFTypeID refType = CFGetTypeID(ref);
-    if (CFNumberGetTypeID() == refType) {
-      CFNumberRef number = reinterpret_cast<CFNumberRef>(ref);
-      p_convertCFNumberToInt(number, value);
-    } else if (CFDataGetTypeID() == refType) {
-      CFDataRef data = reinterpret_cast<CFDataRef>(ref);
-      if (CFDataGetLength(data) == sizeof(UInt32)) {
-        *value = *reinterpret_cast<const UInt32*>(CFDataGetBytePtr(data));
-      }
-    }
-    CFRelease(ref);
-  }
-}
-
-static void GetProperty(io_service_t port, CFStringRef name,
-                        std::string* value) {
-  if (!value) return;
-  CFTypeRef ref = SearchForProperty(port, name);
-  if (ref) {
-    CFTypeID refType = CFGetTypeID(ref);
-    if (CFStringGetTypeID() == refType) {
-      CFStringRef stringRef = reinterpret_cast<CFStringRef>(ref);
-      p_convertHostCFStringRefToCPPString(stringRef, *value);
-    } else if (CFDataGetTypeID() == refType) {
-      CFDataRef dataRef = reinterpret_cast<CFDataRef>(ref);
-      *value = std::string(reinterpret_cast<const char*>(
-          CFDataGetBytePtr(dataRef)), CFDataGetLength(dataRef));
-    }
-    CFRelease(ref);
-  }
-}
-#endif
-
-SystemInfo::GpuInfo::GpuInfo() : vendor_id(0), device_id(0) {
-}
-
-SystemInfo::GpuInfo::~GpuInfo() = default;
-
-// Fills a struct with information on the graphics adapater and returns true
-// iff successful.
-bool SystemInfo::GetGpuInfo(GpuInfo *info) {
-  if (!info) return false;
-#if defined(WEBRTC_WIN) && !defined(EXCLUDE_D3D9)
-  D3DADAPTER_IDENTIFIER9 identifier;
-  HRESULT hr = E_FAIL;
-  HINSTANCE d3d_lib = LoadLibrary(L"d3d9.dll");
-
-  if (d3d_lib) {
-    typedef IDirect3D9* (WINAPI *D3DCreate9Proc)(UINT);
-    D3DCreate9Proc d3d_create_proc = reinterpret_cast<D3DCreate9Proc>(
-        GetProcAddress(d3d_lib, "Direct3DCreate9"));
-    if (d3d_create_proc) {
-      IDirect3D9* d3d = d3d_create_proc(D3D_SDK_VERSION);
-      if (d3d) {
-        hr = d3d->GetAdapterIdentifier(D3DADAPTER_DEFAULT, 0, &identifier);
-        d3d->Release();
-      }
-    }
-    FreeLibrary(d3d_lib);
-  }
-
-  if (hr != D3D_OK) {
-    LOG(LS_ERROR) << "Failed to access Direct3D9 information.";
-    return false;
-  }
-
-  info->device_name = identifier.DeviceName;
-  info->description = identifier.Description;
-  info->vendor_id = identifier.VendorId;
-  info->device_id = identifier.DeviceId;
-  info->driver = identifier.Driver;
-  // driver_version format: product.version.subversion.build
-  std::stringstream ss;
-  ss << HIWORD(identifier.DriverVersion.HighPart) << "."
-     << LOWORD(identifier.DriverVersion.HighPart) << "."
-     << HIWORD(identifier.DriverVersion.LowPart) << "."
-     << LOWORD(identifier.DriverVersion.LowPart);
-  info->driver_version = ss.str();
-  return true;
-#elif defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
-  // We'll query the IOKit for the gpu of the main display.
-  io_service_t display_service_port = CGDisplayIOServicePort(
-      kCGDirectMainDisplay);
-  GetProperty(display_service_port, CFSTR("vendor-id"), &info->vendor_id);
-  GetProperty(display_service_port, CFSTR("device-id"), &info->device_id);
-  GetProperty(display_service_port, CFSTR("model"), &info->description);
-  return true;
-#else  // WEBRTC_LINUX
-  // TODO(fbarchard): Implement this on Linux
-  return false;
+  return "Not available";
 #endif
 }
+
 }  // namespace rtc
diff --git a/webrtc/base/systeminfo.h b/webrtc/base/systeminfo.h
index 47b93f6..e223702 100644
--- a/webrtc/base/systeminfo.h
+++ b/webrtc/base/systeminfo.h
@@ -28,53 +28,20 @@
 
   SystemInfo();
 
-  // The number of CPU Cores in the system.
-  int GetMaxPhysicalCpus();
   // The number of CPU Threads in the system.
-  int GetMaxCpus();
+  static int GetMaxCpus();
   // The number of CPU Threads currently available to this process.
-  int GetCurCpus();
+  static int GetCurCpus();
   // Identity of the CPUs.
   Architecture GetCpuArchitecture();
   std::string GetCpuVendor();
-  int GetCpuFamily();
-  int GetCpuModel();
-  int GetCpuStepping();
-  // Return size of CPU cache in bytes.  Uses largest available cache (L3).
-  int GetCpuCacheSize();
-  // Estimated speed of the CPUs, in MHz.  e.g. 2400 for 2.4 GHz
-  int GetMaxCpuSpeed();
-  int GetCurCpuSpeed();
   // Total amount of physical memory, in bytes.
   int64 GetMemorySize();
   // The model name of the machine, e.g. "MacBookAir1,1"
   std::string GetMachineModel();
 
-  // The gpu identifier
-  struct GpuInfo {
-    GpuInfo();
-    ~GpuInfo();
-    std::string device_name;
-    std::string description;
-    int vendor_id;
-    int device_id;
-    std::string driver;
-    std::string driver_version;
-  };
-  bool GetGpuInfo(GpuInfo *info);
-
  private:
-  int physical_cpus_;
-  int logical_cpus_;
-  int cache_size_;
-  Architecture cpu_arch_;
-  std::string cpu_vendor_;
-  int cpu_family_;
-  int cpu_model_;
-  int cpu_stepping_;
-  int cpu_speed_;
-  int64 memory_;
-  std::string machine_model_;
+  static int logical_cpus_;
 };
 
 }  // namespace rtc
diff --git a/webrtc/base/systeminfo_unittest.cc b/webrtc/base/systeminfo_unittest.cc
index fec5535..b1fc65e 100644
--- a/webrtc/base/systeminfo_unittest.cc
+++ b/webrtc/base/systeminfo_unittest.cc
@@ -52,14 +52,6 @@
 #endif
 }
 
-// Tests Cpu Cache Size
-TEST(SystemInfoTest, CpuCacheSize) {
-  rtc::SystemInfo info;
-  LOG(LS_INFO) << "CpuCacheSize: " << info.GetCpuCacheSize();
-  EXPECT_GE(info.GetCpuCacheSize(), 8192);  // 8 KB min cache
-  EXPECT_LE(info.GetCpuCacheSize(), 1024 * 1024 * 1024);  // 1 GB max cache
-}
-
 // Tests MachineModel is set.  On Mac test machine model is known.
 TEST(SystemInfoTest, MachineModelKnown) {
   rtc::SystemInfo info;
@@ -86,22 +78,6 @@
   }
 }
 
-// Tests maximum cpu clockrate.
-TEST(SystemInfoTest, CpuMaxCpuSpeed) {
-  rtc::SystemInfo info;
-  LOG(LS_INFO) << "MaxCpuSpeed: " << info.GetMaxCpuSpeed();
-  EXPECT_GT(info.GetMaxCpuSpeed(), 0);
-  EXPECT_LT(info.GetMaxCpuSpeed(), 100000);  // 100 Ghz
-}
-
-// Tests current cpu clockrate.
-TEST(SystemInfoTest, CpuCurCpuSpeed) {
-  rtc::SystemInfo info;
-  LOG(LS_INFO) << "MaxCurSpeed: " << info.GetCurCpuSpeed();
-  EXPECT_GT(info.GetCurCpuSpeed(), 0);
-  EXPECT_LT(info.GetMaxCpuSpeed(), 100000);
-}
-
 // Tests physical memory size.
 TEST(SystemInfoTest, MemorySize) {
   rtc::SystemInfo info;
@@ -116,14 +92,6 @@
   EXPECT_GT(info.GetMaxCpus(), 0);
 }
 
-// Tests number of physical cpus available to the system.
-TEST(SystemInfoTest, MaxPhysicalCpus) {
-  rtc::SystemInfo info;
-  LOG(LS_INFO) << "MaxPhysicalCpus: " << info.GetMaxPhysicalCpus();
-  EXPECT_GT(info.GetMaxPhysicalCpus(), 0);
-  EXPECT_LE(info.GetMaxPhysicalCpus(), info.GetMaxCpus());
-}
-
 // Tests number of logical cpus available to the process.
 TEST(SystemInfoTest, CurCpus) {
   rtc::SystemInfo info;
@@ -180,15 +148,3 @@
   EXPECT_EQ(0, info.GetCpuStepping());
 }
 #endif  // CPU_X86
-
-#if WEBRTC_WIN && !defined(EXCLUDE_D3D9)
-TEST(SystemInfoTest, GpuInfo) {
-  rtc::SystemInfo info;
-  rtc::SystemInfo::GpuInfo gi;
-  EXPECT_TRUE(info.GetGpuInfo(&gi));
-  LOG(LS_INFO) << "GpuDriver: " << gi.driver;
-  EXPECT_FALSE(gi.driver.empty());
-  LOG(LS_INFO) << "GpuDriverVersion: " << gi.driver_version;
-  EXPECT_FALSE(gi.driver_version.empty());
-}
-#endif
diff --git a/webrtc/system_wrappers/interface/cpu_info.h b/webrtc/system_wrappers/interface/cpu_info.h
index fa8c388..65888b8 100644
--- a/webrtc/system_wrappers/interface/cpu_info.h
+++ b/webrtc/system_wrappers/interface/cpu_info.h
@@ -21,7 +21,6 @@
 
  private:
   CpuInfo() {}
-  static uint32_t number_of_cores_;
 };
 
 }  // namespace webrtc
diff --git a/webrtc/system_wrappers/source/cpu_info.cc b/webrtc/system_wrappers/source/cpu_info.cc
index c482d87..ebbb08a 100644
--- a/webrtc/system_wrappers/source/cpu_info.cc
+++ b/webrtc/system_wrappers/source/cpu_info.cc
@@ -10,55 +10,12 @@
 
 #include "webrtc/system_wrappers/interface/cpu_info.h"
 
-#if defined(_WIN32)
-#include <Windows.h>
-#elif defined(WEBRTC_MAC)
-#include <sys/sysctl.h>
-#include <sys/types.h>
-#else // defined(WEBRTC_LINUX) or defined(WEBRTC_ANDROID)
-#include <unistd.h>
-#endif
-
-#include "webrtc/system_wrappers/interface/trace.h"
+#include "webrtc/base/systeminfo.h"
 
 namespace webrtc {
 
-uint32_t CpuInfo::number_of_cores_ = 0;
-
 uint32_t CpuInfo::DetectNumberOfCores() {
-  if (!number_of_cores_) {
-#if defined(_WIN32)
-    SYSTEM_INFO si;
-    GetSystemInfo(&si);
-    number_of_cores_ = static_cast<uint32_t>(si.dwNumberOfProcessors);
-    WEBRTC_TRACE(kTraceStateInfo, kTraceUtility, -1,
-                 "Available number of cores:%d", number_of_cores_);
-
-#elif defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID)
-    number_of_cores_ = static_cast<uint32_t>(sysconf(_SC_NPROCESSORS_ONLN));
-    WEBRTC_TRACE(kTraceStateInfo, kTraceUtility, -1,
-                 "Available number of cores:%d", number_of_cores_);
-
-#elif defined(WEBRTC_MAC)
-    int name[] = {CTL_HW, HW_AVAILCPU};
-    int ncpu;
-    size_t size = sizeof(ncpu);
-    if (0 == sysctl(name, 2, &ncpu, &size, NULL, 0)) {
-      number_of_cores_ = static_cast<uint32_t>(ncpu);
-      WEBRTC_TRACE(kTraceStateInfo, kTraceUtility, -1,
-                   "Available number of cores:%d", number_of_cores_);
-    } else {
-      WEBRTC_TRACE(kTraceError, kTraceUtility, -1,
-                   "Failed to get number of cores");
-      number_of_cores_ = 1;
-    }
-#else
-    WEBRTC_TRACE(kTraceWarning, kTraceUtility, -1,
-                 "No function to get number of cores");
-    number_of_cores_ = 1;
-#endif
-  }
-  return number_of_cores_;
+  return static_cast<uint32_t>(rtc::SystemInfo::GetMaxCpus());
 }
 
 }  // namespace webrtc