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

Unified Diff: content/gpu/gpu_watchdog_thread.cc

Issue 22289002: Added suspend/resume detection to the GpuWatchdogThread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 | « content/gpu/gpu_watchdog_thread.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/gpu/gpu_watchdog_thread.cc
diff --git a/content/gpu/gpu_watchdog_thread.cc b/content/gpu/gpu_watchdog_thread.cc
index e823eddabb99215e949d9e6ea9264c2d811edf5f..ed9828287fe1bc56c625b852211c6ea70316f8ec 100644
--- a/content/gpu/gpu_watchdog_thread.cc
+++ b/content/gpu/gpu_watchdog_thread.cc
@@ -12,6 +12,7 @@
#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
+#include "base/power_monitor/power_monitor.h"
#include "base/process/process.h"
#include "build/build_config.h"
#include "content/public/common/content_switches.h"
@@ -32,7 +33,8 @@ GpuWatchdogThread::GpuWatchdogThread(int timeout)
arm_cpu_time_(),
#endif
task_observer_(this),
- weak_factory_(this) {
+ weak_factory_(this),
+ suspended_(false) {
DCHECK(timeout >= 0);
#if defined(OS_WIN)
@@ -104,6 +106,10 @@ GpuWatchdogThread::~GpuWatchdogThread() {
CloseHandle(watched_thread_handle_);
#endif
+ base::PowerMonitor* power_monitor = base::PowerMonitor::Get();
+ if (power_monitor)
+ power_monitor->RemoveObserver(this);
+
watched_message_loop_->RemoveTaskObserver(&task_observer_);
}
@@ -132,7 +138,9 @@ void GpuWatchdogThread::OnAcknowledge() {
}
void GpuWatchdogThread::OnCheck(bool after_suspend) {
- if (armed_)
+ // Do not create any new termination tasks if one has already been created
+ // or the system is suspended.
+ if (armed_ || suspended_)
return;
// Must set armed before posting the task. This task might be the only task
@@ -168,6 +176,9 @@ void GpuWatchdogThread::OnCheck(bool after_suspend) {
// Use the --disable-gpu-watchdog command line switch to disable this.
void GpuWatchdogThread::DeliberatelyTerminateToRecoverFromHang() {
+ // Should not get here while system is suspended
Ken Russell (switch to Gerrit) 2013/08/05 22:08:01 Please complete the sentence: "while the system is
+ DCHECK(!suspended_);
+
#if defined(OS_WIN)
// Defer termination until a certain amount of CPU time has elapsed on the
// watched thread.
@@ -214,6 +225,34 @@ void GpuWatchdogThread::DeliberatelyTerminateToRecoverFromHang() {
terminated = true;
}
+void GpuWatchdogThread::AddPowerObserver() {
+ message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(&GpuWatchdogThread::OnAddPowerObserver, this));
+}
+
+void GpuWatchdogThread::OnAddPowerObserver() {
+ base::PowerMonitor* power_monitor = base::PowerMonitor::Get();
+ DCHECK(power_monitor);
+ power_monitor->AddObserver(this);
+}
+
+void GpuWatchdogThread::OnSuspend() {
+ suspended_ = true;
+
+ // When suspending force an acknowledgement to cancel any pending termination
+ // tasks.
+ OnAcknowledge();
Ken Russell (switch to Gerrit) 2013/08/05 22:08:01 Is this correct and sufficient? The situation I'm
+}
+
+void GpuWatchdogThread::OnResume() {
+ suspended_ = false;
+
+ // After resuming jump-start the watchdog again
+ armed_ = false;
+ OnCheck(true);
Ken Russell (switch to Gerrit) 2013/08/05 22:08:01 Similarly for OnCheck. Per discussion with apatric
+}
+
#if defined(OS_WIN)
base::TimeDelta GpuWatchdogThread::GetWatchedThreadTime() {
FILETIME creation_time;
« no previous file with comments | « content/gpu/gpu_watchdog_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698