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 |