#include "media/audio/audio_thread_hang_monitor.h"
#include <algorithm>
#include <utility>
#include "base/debug/dump_without_crashing.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/power_monitor/power_monitor.h"
#include "base/process/process.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/threading/thread_checker.h"
#include "base/time/tick_clock.h"
namespace media {
namespace {
constexpr int kMaxFailedPingsCount = …;
constexpr base::TimeDelta kDefaultHangDeadline = …;
}
AudioThreadHangMonitor::SharedAtomicFlag::SharedAtomicFlag() { … }
AudioThreadHangMonitor::SharedAtomicFlag::~SharedAtomicFlag() { … }
AudioThreadHangMonitor::Ptr AudioThreadHangMonitor::Create(
HangAction hang_action,
std::optional<base::TimeDelta> hang_deadline,
const base::TickClock* clock,
scoped_refptr<base::SingleThreadTaskRunner> audio_thread_task_runner,
scoped_refptr<base::SequencedTaskRunner> monitor_task_runner) { … }
AudioThreadHangMonitor::~AudioThreadHangMonitor() { … }
bool AudioThreadHangMonitor::IsAudioThreadHung() const { … }
AudioThreadHangMonitor::AudioThreadHangMonitor(
HangAction hang_action,
std::optional<base::TimeDelta> hang_deadline,
const base::TickClock* clock,
scoped_refptr<base::SingleThreadTaskRunner> audio_thread_task_runner)
: … { … }
void AudioThreadHangMonitor::StartTimer() { … }
bool AudioThreadHangMonitor::NeverLoggedThreadHung() const { … }
bool AudioThreadHangMonitor::NeverLoggedThreadRecoveredAfterHung() const { … }
void AudioThreadHangMonitor::CheckIfAudioThreadIsAlive() { … }
void AudioThreadHangMonitor::LogHistogramThreadStatus() { … }
void AudioThreadHangMonitor::SetHangActionCallbacksForTesting(
base::RepeatingClosure dump_callback,
base::RepeatingClosure terminate_process_callback) { … }
void AudioThreadHangMonitor::DumpWithoutCrashing() { … }
void AudioThreadHangMonitor::TerminateCurrentProcess() { … }
}