blob: de761a7b05a966c0c5ac8a31a3b1a9e93548c518 [file] [log] [blame]
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/macros.h"
#include "build/build_config.h"
namespace memory {
enum class SwapThrashingLevel {
// There's no thrashing happening on the system or the state is undetermined.
// There's no possible transition from this state to the confirmed one, the
// system always go through the suspected state before confirming thrashing.
// Indicates that there's a suspicion of swap-thrashing but the swapping
// activity is not sustained.
// Swap-thrashing is confirmed to affect the system.
// Dummy definition of a SwapThrashingMonitorDelegate, the platforms interested
// in monitoring the swap thrashing state should implement this class. They
// should also ensure that the SampleAndCalculateSwapThrashingLevel function
// gets called periodically as it is responsible for querying the state of the
// system. It is recommended to use a frequency around 0.5 and 1Hz.
class SwapThrashingMonitorDelegate {
SwapThrashingMonitorDelegate() {}
virtual ~SwapThrashingMonitorDelegate() {}
// Calculates the swap-thrashing level over the interval between now and the
// last time this function was called. This function will always return
// SWAP_THRASHING_LEVEL_NONE when it gets called for the first time.
// This function requires sequence-affinity, through use of ThreadChecker. It
// is also blocking and should be run on a blocking sequenced task runner.
virtual SwapThrashingLevel SampleAndCalculateSwapThrashingLevel();
} // namespace memory