Avi Drissman | e4622aa | 2022-09-08 20:36:06 | [diff] [blame] | 1 | // Copyright 2015 The Chromium Authors |
dmichael | 87f6aa1c | 2015-04-07 19:13:09 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "base/memory/memory_pressure_monitor.h" |
| 6 | |
Hans Wennborg | c3cffa6 | 2020-04-27 10:09:12 | [diff] [blame] | 7 | #include "base/check.h" |
Sebastien Marchand | aff98f8 | 2020-08-04 21:08:27 | [diff] [blame] | 8 | #include "base/metrics/histogram.h" |
Hans Wennborg | c3cffa6 | 2020-04-27 10:09:12 | [diff] [blame] | 9 | #include "base/notreached.h" |
dmichael | 87f6aa1c | 2015-04-07 19:13:09 | [diff] [blame] | 10 | |
| 11 | namespace base { |
| 12 | namespace { |
| 13 | |
| 14 | MemoryPressureMonitor* g_monitor = nullptr; |
| 15 | |
| 16 | } // namespace |
| 17 | |
| 18 | MemoryPressureMonitor::MemoryPressureMonitor() { |
| 19 | DCHECK(!g_monitor); |
| 20 | g_monitor = this; |
| 21 | } |
| 22 | |
| 23 | MemoryPressureMonitor::~MemoryPressureMonitor() { |
| 24 | DCHECK(g_monitor); |
| 25 | g_monitor = nullptr; |
| 26 | } |
| 27 | |
| 28 | // static |
| 29 | MemoryPressureMonitor* MemoryPressureMonitor::Get() { |
| 30 | return g_monitor; |
| 31 | } |
Sebastien Marchand | aff98f8 | 2020-08-04 21:08:27 | [diff] [blame] | 32 | |
dmichael | 87f6aa1c | 2015-04-07 19:13:09 | [diff] [blame] | 33 | } // namespace base |