Bug 1426513, part 2 - Remove SysInfo. r=jld
☠☠ backed out by 8a45850ffc2e ☠ ☠
authorAndrew McCreight <continuation@gmail.com>
Wed, 20 Dec 2017 13:51:57 -0800
changeset 448941 64021383118d4e301fae210005791996d5e10786
parent 448940 9d80a554866cc8d1b2af88d9a5286bda19e18e66
child 448942 693bb500fc2531d3411dc508dac86ac04af2072f
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjld
bugs1426513
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1426513, part 2 - Remove SysInfo. r=jld MozReview-Commit-ID: AzNOH8mJqEY
ipc/chromium/moz.build
ipc/chromium/src/base/process_util_posix.cc
ipc/chromium/src/base/sys_info.h
ipc/chromium/src/base/sys_info_mac.cc
ipc/chromium/src/base/sys_info_posix.cc
ipc/chromium/src/base/sys_info_win.cc
ipc/chromium/src/chrome/common/process_watcher_win.cc
--- a/ipc/chromium/moz.build
+++ b/ipc/chromium/moz.build
@@ -39,17 +39,16 @@ if os_win:
         'src/base/file_util_win.cc',
         'src/base/lock_impl_win.cc',
         'src/base/message_pump_win.cc',
         'src/base/object_watcher.cc',
         'src/base/platform_thread_win.cc',
         'src/base/process_util_win.cc',
         'src/base/rand_util_win.cc',
         'src/base/shared_memory_win.cc',
-        'src/base/sys_info_win.cc',
         'src/base/sys_string_conversions_win.cc',
         'src/base/thread_local_win.cc',
         'src/base/time_win.cc',
         'src/base/waitable_event_win.cc',
         'src/base/win_util.cc',
         'src/chrome/common/ipc_channel_win.cc',
         'src/chrome/common/process_watcher_win.cc',
     ]
@@ -64,33 +63,31 @@ if os_posix:
         'src/base/file_util_posix.cc',
         'src/base/lock_impl_posix.cc',
         'src/base/message_pump_libevent.cc',
         'src/base/platform_thread_posix.cc',
         'src/base/process_util_posix.cc',
         'src/base/rand_util_posix.cc',
         'src/base/shared_memory_posix.cc',
         'src/base/string16.cc',
-        'src/base/sys_info_posix.cc',
         'src/base/thread_local_posix.cc',
         'src/base/waitable_event_posix.cc',
         'src/chrome/common/file_descriptor_set_posix.cc',
         'src/chrome/common/ipc_channel_posix.cc',
         'src/chrome/common/process_watcher_posix_sigchld.cc',
     ]
 
 if os_macosx:
     UNIFIED_SOURCES += [
         'src/base/chrome_application_mac.mm',
         'src/base/file_util_mac.mm',
         'src/base/mac_util.mm',
         'src/base/message_pump_mac.mm',
         'src/base/process_util_mac.mm',
         'src/base/scoped_nsautorelease_pool.mm',
-        'src/base/sys_info_mac.cc',
         'src/base/sys_string_conversions_mac.mm',
         'src/base/time_mac.cc',
         'src/chrome/common/mach_ipc_mac.mm',
         'src/chrome/common/mach_message_source_mac.cc',
     ]
     SOURCES += [
         # This file cannot be built in unified mode because of the redefinition
         # of NoOp.
--- a/ipc/chromium/src/base/process_util_posix.cc
+++ b/ipc/chromium/src/base/process_util_posix.cc
@@ -18,17 +18,16 @@
 #include <limits>
 #include <set>
 
 #include "base/basictypes.h"
 #include "base/eintr_wrapper.h"
 #include "base/logging.h"
 #include "base/platform_thread.h"
 #include "base/process_util.h"
-#include "base/sys_info.h"
 #include "base/time.h"
 #include "base/waitable_event.h"
 #include "base/dir_reader_posix.h"
 
 #include "mozilla/UniquePtr.h"
 // For PR_DuplicateEnvironment:
 #include "prenv.h"
 #include "prmem.h"
deleted file mode 100644
--- a/ipc/chromium/src/base/sys_info.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-// Copyright (c) 2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_SYS_INFO_H_
-#define BASE_SYS_INFO_H_
-
-#include "base/basictypes.h"
-
-#include <string>
-
-namespace base {
-
-class SysInfo {
- public:
-  // Return the number of logical processors/cores on the current machine.
-  // WARNING: On POSIX, this method uses static variables and is not threadsafe
-  // until it's been initialized by being called once without a race.
-  static int NumberOfProcessors();
-
-  // Return the number of bytes of physical memory on the current machine.
-  static int64_t AmountOfPhysicalMemory();
-
-  // Return the number of megabytes of physical memory on the current machine.
-  static int AmountOfPhysicalMemoryMB() {
-    return static_cast<int>(AmountOfPhysicalMemory() / 1024 / 1024);
-  }
-
-  // Return the available disk space in bytes on the volume containing |path|,
-  // or -1 on failure.
-  static int64_t AmountOfFreeDiskSpace(const std::wstring& path);
-
-  // Return true if the given environment variable is defined.
-  // TODO: find a better place for HasEnvVar.
-  static bool HasEnvVar(const wchar_t* var);
-
-  // Return the value of the given environment variable
-  // or an empty string if not defined.
-  // TODO: find a better place for GetEnvVar.
-  static std::wstring GetEnvVar(const wchar_t* var);
-
-  // Returns the name of the host operating system.
-  static std::string OperatingSystemName();
-
-  // Returns the CPU architecture of the system. Exact return value may differ
-  // across platforms.
-  static std::string CPUArchitecture();
-
-  // Returns the pixel dimensions of the primary display via the
-  // width and height parameters.
-  static void GetPrimaryDisplayDimensions(int* width, int* height);
-
-  // Return the number of displays.
-  static int DisplayCount();
-
-  // Return the smallest amount of memory (in bytes) which the VM system will
-  // allocate.
-  static size_t VMAllocationGranularity();
-};
-
-}  // namespace base
-
-#endif  // BASE_SYS_INFO_H_
deleted file mode 100644
--- a/ipc/chromium/src/base/sys_info_mac.cc
+++ /dev/null
@@ -1,13 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/sys_info.h"
-
-#include <CoreServices/CoreServices.h>
-
-namespace base {
-
-}  // namespace base
deleted file mode 100644
--- a/ipc/chromium/src/base/sys_info_posix.cc
+++ /dev/null
@@ -1,158 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-// Copyright (c) 2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/sys_info.h"
-#include "base/basictypes.h"
-
-#include <errno.h>
-#include <string.h>
-#ifndef ANDROID
-#include <sys/statvfs.h>
-#endif
-#include <sys/utsname.h>
-#include <unistd.h>
-
-#if defined(OS_MACOSX)
-#include <mach/mach_host.h>
-#include <mach/mach_init.h>
-#endif
-
-#if defined(OS_NETBSD)
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#endif
-
-#include "base/logging.h"
-#include "base/string_util.h"
-
-namespace base {
-
-int SysInfo::NumberOfProcessors() {
-  // It seems that sysconf returns the number of "logical" processors on both
-  // mac and linux.  So we get the number of "online logical" processors.
-#ifdef _SC_NPROCESSORS_ONLN
-  static long res = sysconf(_SC_NPROCESSORS_ONLN);
-#else
-  static long res = 1;
-#endif
-  if (res == -1) {
-    NOTREACHED();
-    return 1;
-  }
-
-  return static_cast<int>(res);
-}
-
-// static
-int64_t SysInfo::AmountOfPhysicalMemory() {
-  // _SC_PHYS_PAGES is not part of POSIX and not available on OS X
-#if defined(OS_MACOSX)
-  struct host_basic_info hostinfo;
-  mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT;
-  int result = host_info(mach_host_self(),
-                         HOST_BASIC_INFO,
-                         reinterpret_cast<host_info_t>(&hostinfo),
-                         &count);
-  DCHECK_EQ(HOST_BASIC_INFO_COUNT, count);
-  if (result != KERN_SUCCESS) {
-    NOTREACHED();
-    return 0;
-  }
-
-  return static_cast<int64_t>(hostinfo.max_mem);
-#elif defined(OS_NETBSD)
-  int mib[2];
-  int rc;
-  int64_t memSize;
-  size_t len = sizeof(memSize);
-
-  mib[0] = CTL_HW;
-  mib[1] = HW_PHYSMEM64;
-  rc = sysctl( mib, 2, &memSize, &len, NULL, 0 );
-  if (-1 != rc)  {
-    return memSize;
-  }
-  return 0;
-
-#else
-  long pages = sysconf(_SC_PHYS_PAGES);
-  long page_size = sysconf(_SC_PAGE_SIZE);
-  if (pages == -1 || page_size == -1) {
-    NOTREACHED();
-    return 0;
-  }
-
-  return static_cast<int64_t>(pages) * page_size;
-#endif
-}
-
-// static
-int64_t SysInfo::AmountOfFreeDiskSpace(const std::wstring& path) {
-#ifndef ANDROID
-  struct statvfs stats;
-  if (statvfs(WideToUTF8(path).c_str(), &stats) != 0) {
-    return -1;
-  }
-  return static_cast<int64_t>(stats.f_bavail) * stats.f_frsize;
-#else
-  return -1;
-#endif
-}
-
-// static
-bool SysInfo::HasEnvVar(const wchar_t* var) {
-  std::string var_utf8 = WideToUTF8(std::wstring(var));
-  return getenv(var_utf8.c_str()) != NULL;
-}
-
-// static
-std::wstring SysInfo::GetEnvVar(const wchar_t* var) {
-  std::string var_utf8 = WideToUTF8(std::wstring(var));
-  char* value = getenv(var_utf8.c_str());
-  if (!value) {
-    return L"";
-  } else {
-    return UTF8ToWide(value);
-  }
-}
-
-// static
-std::string SysInfo::OperatingSystemName() {
-  struct utsname info;
-  if (uname(&info) < 0) {
-    NOTREACHED();
-    return "";
-  }
-  return std::string(info.sysname);
-}
-
-// static
-std::string SysInfo::CPUArchitecture() {
-  struct utsname info;
-  if (uname(&info) < 0) {
-    NOTREACHED();
-    return "";
-  }
-  return std::string(info.machine);
-}
-
-// static
-void SysInfo::GetPrimaryDisplayDimensions(int* width, int* height) {
-  NOTIMPLEMENTED();
-}
-
-// static
-int SysInfo::DisplayCount() {
-  NOTIMPLEMENTED();
-  return 1;
-}
-
-// static
-size_t SysInfo::VMAllocationGranularity() {
-  return getpagesize();
-}
-
-}  // namespace base
deleted file mode 100644
--- a/ipc/chromium/src/base/sys_info_win.cc
+++ /dev/null
@@ -1,100 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-// Copyright (c) 2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/sys_info.h"
-
-#include <windows.h>
-
-#include "base/logging.h"
-#include "base/string_util.h"
-#include "mozilla/UniquePtr.h"
-
-namespace base {
-
-// static
-int SysInfo::NumberOfProcessors() {
-  SYSTEM_INFO info;
-  GetSystemInfo(&info);
-  return static_cast<int>(info.dwNumberOfProcessors);
-}
-
-// static
-int64_t SysInfo::AmountOfPhysicalMemory() {
-  MEMORYSTATUSEX memory_info;
-  memory_info.dwLength = sizeof(memory_info);
-  if (!GlobalMemoryStatusEx(&memory_info)) {
-    NOTREACHED();
-    return 0;
-  }
-
-  int64_t rv = static_cast<int64_t>(memory_info.ullTotalPhys);
-  if (rv < 0)
-    rv = kint64max;
-  return rv;
-}
-
-// static
-int64_t SysInfo::AmountOfFreeDiskSpace(const std::wstring& path) {
-  ULARGE_INTEGER available, total, free;
-  if (!GetDiskFreeSpaceExW(path.c_str(), &available, &total, &free)) {
-    return -1;
-  }
-  int64_t rv = static_cast<int64_t>(available.QuadPart);
-  if (rv < 0)
-    rv = kint64max;
-  return rv;
-}
-
-// static
-bool SysInfo::HasEnvVar(const wchar_t* var) {
-  return GetEnvironmentVariable(var, NULL, 0) != 0;
-}
-
-// static
-std::wstring SysInfo::GetEnvVar(const wchar_t* var) {
-  DWORD value_length = GetEnvironmentVariable(var, NULL, 0);
-  if (value_length == 0) {
-    return L"";
-  }
-  mozilla::UniquePtr<wchar_t[]> value(new wchar_t[value_length]);
-  GetEnvironmentVariable(var, value.get(), value_length);
-  return std::wstring(value.get());
-}
-
-// static
-std::string SysInfo::OperatingSystemName() {
-  return "Windows NT";
-}
-
-// static
-std::string SysInfo::CPUArchitecture() {
-  // TODO: Make this vary when we support any other architectures.
-  return "x86";
-}
-
-// static
-void SysInfo::GetPrimaryDisplayDimensions(int* width, int* height) {
-  if (width)
-    *width = GetSystemMetrics(SM_CXSCREEN);
-
-  if (height)
-    *height = GetSystemMetrics(SM_CYSCREEN);
-}
-
-// static
-int SysInfo::DisplayCount() {
-  return GetSystemMetrics(SM_CMONITORS);
-}
-
-// static
-size_t SysInfo::VMAllocationGranularity() {
-  SYSTEM_INFO sysinfo;
-  GetSystemInfo(&sysinfo);
-
-  return sysinfo.dwAllocationGranularity;
-}
-
-}  // namespace base
--- a/ipc/chromium/src/chrome/common/process_watcher_win.cc
+++ b/ipc/chromium/src/chrome/common/process_watcher_win.cc
@@ -3,17 +3,16 @@
 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 #include "chrome/common/process_watcher.h"
 
 #include "base/message_loop.h"
 #include "base/object_watcher.h"
-#include "base/sys_info.h"
 
 // Maximum amount of time (in milliseconds) to wait for the process to exit.
 static const int kWaitInterval = 2000;
 
 namespace {
 
 class ChildReaper : public mozilla::Runnable,
                     public base::ObjectWatcher::Delegate,