Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(683)

Unified Diff: media/audio/audio_manager.cc

Issue 1036933003: Update last audio tick time during suspend and resume. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698