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

Unified Diff: base/memory/memory_pressure_monitor_chromeos.cc

Issue 1250093006: Added memory pressure monitor for linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Uncomment ::Get functionality Created 5 years, 5 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: base/memory/memory_pressure_monitor_chromeos.cc
diff --git a/base/memory/memory_pressure_monitor_chromeos.cc b/base/memory/memory_pressure_monitor_chromeos.cc
index 640e4633fd51c7cb9d3e820af18c62a17ea14f0b..ccf7957d19849baca65b764de4f93132b0df951a 100644
--- a/base/memory/memory_pressure_monitor_chromeos.cc
+++ b/base/memory/memory_pressure_monitor_chromeos.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/memory/memory_pressure_monitor_chromeos.h"
+#include "base/memory/memory_pressure_monitor.h"
#include <fcntl.h>
#include <sys/select.h>
@@ -15,7 +15,6 @@
#include "base/time/time.h"
namespace base {
-namespace chromeos {
namespace {
@@ -113,11 +112,17 @@ MemoryPressureMonitor::MemoryPressureMonitor(
GetCriticalMemoryThresholdInPercent(thresholds)),
low_mem_file_(HANDLE_EINTR(::open(kLowMemFile, O_RDONLY))),
weak_ptr_factory_(this) {
+ DCHECK(!g_monitor);
+ g_monitor = this;
+
StartObserving();
LOG_IF(ERROR, !low_mem_file_.is_valid()) << "Cannot open kernel listener";
}
MemoryPressureMonitor::~MemoryPressureMonitor() {
+ DCHECK(g_monitor);
+ g_monitor = nullptr;
+
StopObserving();
}
@@ -132,12 +137,6 @@ MemoryPressureMonitor::GetCurrentPressureLevel() const {
return current_memory_pressure_level_;
}
-// static
-MemoryPressureMonitor* MemoryPressureMonitor::Get() {
- return static_cast<MemoryPressureMonitor*>(
- base::MemoryPressureMonitor::Get());
-}
-
void MemoryPressureMonitor::StartObserving() {
timer_.Start(FROM_HERE,
TimeDelta::FromMilliseconds(kMemoryPressureIntervalMs),
@@ -268,5 +267,4 @@ int MemoryPressureMonitor::GetUsedMemoryInPercent() {
return percentage;
}
-} // namespace chromeos
} // namespace base
« no previous file with comments | « base/memory/memory_pressure_monitor_chromeos.h ('k') | base/memory/memory_pressure_monitor_chromeos_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698