Index: content/gpu/gpu_watchdog_thread.cc |
diff --git a/content/gpu/gpu_watchdog_thread.cc b/content/gpu/gpu_watchdog_thread.cc |
index 02b6bff8040e8f6c7c464f309c31761da0f508f9..5c022a7ca6305aa76170d6308825081056a9f683 100644 |
--- a/content/gpu/gpu_watchdog_thread.cc |
+++ b/content/gpu/gpu_watchdog_thread.cc |
@@ -19,6 +19,13 @@ |
#include "content/public/common/content_switches.h" |
#include "content/public/common/result_codes.h" |
+#if defined(USE_X11) |
+extern "C" { |
+#include <X11/Xlib.h> |
+} |
+#include "ui/gfx/x/x11_types.h" |
+#endif |
+ |
namespace content { |
namespace { |
const int64 kCheckPeriodMs = 2000; |
@@ -39,6 +46,9 @@ GpuWatchdogThread::GpuWatchdogThread(int timeout) |
#endif |
task_observer_(this), |
suspended_(false), |
+#if defined(USE_X11) |
+ x_server_active(true), |
+#endif |
weak_factory_(this) { |
DCHECK(timeout >= 0); |
@@ -184,14 +194,25 @@ void GpuWatchdogThread::OnCheck(bool after_suspend) { |
FROM_HERE, |
base::Bind(&base::DoNothing)); |
- // Post a task to the watchdog thread to exit if the monitored thread does |
- // not respond in time. |
- message_loop()->PostDelayedTask( |
- FROM_HERE, |
- base::Bind( |
- &GpuWatchdogThread::DeliberatelyTerminateToRecoverFromHang, |
- weak_factory_.GetWeakPtr()), |
- timeout); |
+#if defined(USE_X11) |
+ // Post a task to the watchdog thread to check XServer is active |
+ // if the monitored thread does not respond in time. |
+ if (x_server_active) { |
+ message_loop()->PostDelayedTask( |
+ FROM_HERE, base::Bind(&GpuWatchdogThread::CheckXServerActive, |
+ weak_factory_.GetWeakPtr()), |
+ timeout); |
+ } else |
+#endif |
+ { |
+ // Post a task to the watchdog thread to exit if the monitored thread does |
+ // not respond in time. |
+ message_loop()->PostDelayedTask( |
+ FROM_HERE, |
+ base::Bind(&GpuWatchdogThread::DeliberatelyTerminateToRecoverFromHang, |
+ weak_factory_.GetWeakPtr()), |
+ timeout); |
+ } |
} |
// Use the --disable-gpu-watchdog command line switch to disable this. |
@@ -259,6 +280,16 @@ void GpuWatchdogThread::DeliberatelyTerminateToRecoverFromHang() { |
terminated = true; |
} |
+#if defined(USE_X11) |
+void GpuWatchdogThread::CheckXServerActive() { |
+ if (!XDisplayString(gfx::GetXDisplay())) { |
danakj
2015/01/06 00:29:19
What does this do if the X server is not the activ
sohanjg
2015/01/06 12:21:45
Hmm..i was assuming this would return NULL in that
|
+ x_server_active = false; |
+ timeout_ /= 2; |
+ } else { |
+ x_server_active = true; |
+ } |
+} |
+#endif |
void GpuWatchdogThread::AddPowerObserver() { |
message_loop()->PostTask( |
FROM_HERE, |