#include "components/viz/client/frame_eviction_manager.h"
#include <algorithm>
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/memory_pressure_listener.h"
#include "base/memory/memory_pressure_monitor.h"
#include "base/system/sys_info.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/trace_event/memory_dump_manager.h"
#include "build/build_config.h"
namespace viz {
namespace {
const int kModeratePressurePercentage = …;
const int kCriticalPressurePercentage = …;
}
FrameEvictionManager::ScopedPause::ScopedPause() { … }
FrameEvictionManager::ScopedPause::~ScopedPause() { … }
FrameEvictionManager* FrameEvictionManager::GetInstance() { … }
FrameEvictionManager::~FrameEvictionManager() = default;
void FrameEvictionManager::AddFrame(FrameEvictionManagerClient* frame,
bool locked) { … }
void FrameEvictionManager::RemoveFrame(FrameEvictionManagerClient* frame) { … }
void FrameEvictionManager::LockFrame(FrameEvictionManagerClient* frame) { … }
void FrameEvictionManager::UnlockFrame(FrameEvictionManagerClient* frame) { … }
void FrameEvictionManager::StartFrameCullingTimer() { … }
void FrameEvictionManager::RegisterUnlockedFrame(
FrameEvictionManagerClient* frame) { … }
size_t FrameEvictionManager::GetMaxNumberOfSavedFrames() const { … }
FrameEvictionManager::FrameEvictionManager()
: … { … }
void FrameEvictionManager::CullUnlockedFrames(size_t saved_frame_limit) { … }
#if BUILDFLAG(IS_ANDROID)
void FrameEvictionManager::CullOldUnlockedFrames(
base::MemoryReductionTaskContext task_type) {
const bool should_cull_all =
task_type == base::MemoryReductionTaskContext::kProactive;
#else
void FrameEvictionManager::CullOldUnlockedFrames() { … }
void FrameEvictionManager::OnMemoryPressure(
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) { … }
void FrameEvictionManager::PurgeMemory(int percentage) { … }
void FrameEvictionManager::PurgeAllUnlockedFrames() { … }
void FrameEvictionManager::SetOverridesForTesting(
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
const base::TickClock* clock) { … }
void FrameEvictionManager::Pause() { … }
void FrameEvictionManager::Unpause() { … }
bool FrameEvictionManager::OnMemoryDump(
const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) { … }
}