#include "base/memory/memory_pressure_listener.h"
#include <atomic>
#include "base/observer_list.h"
#include "base/observer_list_threadsafe.h"
#include "base/task/sequenced_task_runner.h"
#include "base/trace_event/base_tracing.h"
#include "base/tracing_buildflags.h"
#if BUILDFLAG(ENABLE_BASE_TRACING)
#include "base/trace_event/memory_pressure_level_proto.h"
#endif
namespace base {
namespace {
class MemoryPressureObserver { … };
MemoryPressureObserver* GetMemoryPressureObserver() { … }
std::atomic<bool> g_notifications_suppressed;
}
MemoryPressureListener::MemoryPressureListener(
const base::Location& creation_location,
const MemoryPressureListener::MemoryPressureCallback& callback)
: … { … }
MemoryPressureListener::MemoryPressureListener(
const base::Location& creation_location,
const MemoryPressureListener::MemoryPressureCallback& callback,
const MemoryPressureListener::SyncMemoryPressureCallback&
sync_memory_pressure_callback)
: … { … }
MemoryPressureListener::~MemoryPressureListener() { … }
void MemoryPressureListener::Notify(MemoryPressureLevel memory_pressure_level) { … }
void MemoryPressureListener::SyncNotify(
MemoryPressureLevel memory_pressure_level) { … }
void MemoryPressureListener::NotifyMemoryPressure(
MemoryPressureLevel memory_pressure_level) { … }
bool MemoryPressureListener::AreNotificationsSuppressed() { … }
void MemoryPressureListener::SetNotificationsSuppressed(bool suppress) { … }
void MemoryPressureListener::SimulatePressureNotification(
MemoryPressureLevel memory_pressure_level) { … }
void MemoryPressureListener::DoNotifyMemoryPressure(
MemoryPressureLevel memory_pressure_level) { … }
}