Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Unified Diff: components/memory_coordinator/browser/memory_monitor_linux.cc

Issue 2321313002: Move components/memory_coordinator -> content/ (Closed)
Patch Set: rebase etc Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/memory_coordinator/browser/memory_monitor_linux.cc
diff --git a/components/memory_coordinator/browser/memory_monitor_linux.cc b/components/memory_coordinator/browser/memory_monitor_linux.cc
deleted file mode 100644
index bd1cf500dae38fe9b9b3c490cdaef5bdff130379..0000000000000000000000000000000000000000
--- a/components/memory_coordinator/browser/memory_monitor_linux.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) 2016 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 "components/memory_coordinator/browser/memory_monitor_linux.h"
-
-#include "base/memory/ptr_util.h"
-#include "base/process/process_metrics.h"
-
-namespace memory_coordinator {
-
-namespace {
-
-// A global static instance of the default delegate. Used by default by
-// MemoryMonitorLinux.
-MemoryMonitorDelegate g_memory_monitor_delegate;
bashi 2016/09/15 04:44:08 Replaced this with a singleton to fix -Wexit-time-
-
-// The number of bits to shift to convert KiB to MiB.
-const int kShiftKiBtoMiB = 10;
-
-} // namespace
-
-MemoryMonitorLinux::MemoryMonitorLinux(MemoryMonitorDelegate* delegate)
- : delegate_(delegate) {}
-
-int MemoryMonitorLinux::GetFreeMemoryUntilCriticalMB() {
- base::SystemMemoryInfoKB mem_info = {};
- delegate_->GetSystemMemoryInfo(&mem_info);
-
- // According to kernel commit 34e431b0ae398fc54ea69ff85ec700722c9da773,
- // "available" is the "amount of memory that is available for a new workload
- // without pushing the system into swap"; return that value if it is valid.
- // Old linux kernels (before 3.14) don't support "available" and show zero
- // instead.
- if (mem_info.available > 0)
- return mem_info.available >> kShiftKiBtoMiB;
-
- // If there is no "available" value, guess at it based on free memory and
- // what the OS can easily discard.
- return (mem_info.free + mem_info.buffers + mem_info.cached) >> kShiftKiBtoMiB;
-}
-
-// static
-std::unique_ptr<MemoryMonitorLinux> MemoryMonitorLinux::Create(
- MemoryMonitorDelegate* delegate) {
- return base::MakeUnique<MemoryMonitorLinux>(delegate);
-}
-
-// Implementation of factory function defined in memory_monitor.h.
-std::unique_ptr<MemoryMonitor> CreateMemoryMonitor() {
- return MemoryMonitorLinux::Create(&g_memory_monitor_delegate);
-}
-
-} // namespace memory_coordinator

Powered by Google App Engine
This is Rietveld 408576698