Index: media/audio/audio_manager.cc |
diff --git a/media/audio/audio_manager.cc b/media/audio/audio_manager.cc |
index 70e09512af0962d6604b4700ecc80aa2307e5dfc..75e9a53819d5bca6189f46ec2ebcb9052cb44131 100644 |
--- a/media/audio/audio_manager.cc |
+++ b/media/audio/audio_manager.cc |
@@ -9,6 +9,7 @@ |
#include "base/lazy_instance.h" |
#include "base/logging.h" |
#include "base/message_loop/message_loop.h" |
+#include "base/power_monitor/power_monitor.h" |
#include "build/build_config.h" |
#include "media/audio/fake_audio_log_factory.h" |
@@ -19,19 +20,29 @@ AudioManager* g_last_created = NULL; |
// Helper class for managing global AudioManager data and hang timers. If the |
// audio thread is unresponsive for more than a minute we want to crash the |
// process so we can catch offenders quickly in the field. |
-class AudioManagerHelper { |
+class AudioManagerHelper : public base::PowerObserver { |
public: |
AudioManagerHelper() : max_hung_task_time_(base::TimeDelta::FromMinutes(1)) {} |
- ~AudioManagerHelper() {} |
+ ~AudioManagerHelper() override {} |
void StartHangTimer( |
const scoped_refptr<base::SingleThreadTaskRunner>& monitor_task_runner) { |
CHECK(!monitor_task_runner_); |
monitor_task_runner_ = monitor_task_runner; |
+ base::PowerMonitor::Get()->AddObserver(this); |
UpdateLastAudioThreadTimeTick(); |
CrashOnAudioThreadHang(); |
} |
+ void OnSuspend() override { |
+ base::AutoLock lock(hang_lock_); |
+ last_audio_thread_timer_tick_ = base::TimeTicks::Now(); |
+ } |
+ |
+ void OnResume() override { |
nasko
2015/03/26 23:10:43
Are we guaranteed that there will be no task execu
DaleCurtis
2015/03/26 23:26:45
Ah, I was going to do this, but thought it wasn't
|
+ OnSuspend(); |
nasko
2015/03/26 23:10:44
nit: Why not add a private method that does the wo
DaleCurtis
2015/03/26 23:26:45
No need anymore.
|
+ } |
+ |
// Runs on |monitor_task_runner| typically, but may be started on any thread. |
void CrashOnAudioThreadHang() { |
base::AutoLock lock(hang_lock_); |