| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_GPU_GPU_WATCHDOG_THREAD_H_ | 5 #ifndef CONTENT_GPU_GPU_WATCHDOG_THREAD_H_ |
| 6 #define CONTENT_GPU_GPU_WATCHDOG_THREAD_H_ | 6 #define CONTENT_GPU_GPU_WATCHDOG_THREAD_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/power_monitor/power_observer.h" | 11 #include "base/power_monitor/power_observer.h" |
| 12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "content/common/gpu/gpu_watchdog.h" | 14 #include "content/common/gpu/gpu_watchdog.h" |
| 15 #include "ui/gfx/native_widget_types.h" |
| 16 |
| 17 #if defined(USE_X11) |
| 18 extern "C" { |
| 19 #include <X11/Xlib.h> |
| 20 #include <X11/Xatom.h> |
| 21 } |
| 22 #include "ui/base/x/x11_util.h" |
| 23 #include "ui/gfx/x/x11_types.h" |
| 24 #endif |
| 15 | 25 |
| 16 namespace content { | 26 namespace content { |
| 17 | 27 |
| 18 // A thread that intermitently sends tasks to a group of watched message loops | 28 // A thread that intermitently sends tasks to a group of watched message loops |
| 19 // and deliberately crashes if one of them does not respond after a timeout. | 29 // and deliberately crashes if one of them does not respond after a timeout. |
| 20 class GpuWatchdogThread : public base::Thread, | 30 class GpuWatchdogThread : public base::Thread, |
| 21 public GpuWatchdog, | 31 public GpuWatchdog, |
| 22 public base::PowerObserver, | 32 public base::PowerObserver, |
| 23 public base::RefCountedThreadSafe<GpuWatchdogThread> { | 33 public base::RefCountedThreadSafe<GpuWatchdogThread> { |
| 24 public: | 34 public: |
| (...skipping 30 matching lines...) Expand all Loading... |
| 55 | 65 |
| 56 private: | 66 private: |
| 57 GpuWatchdogThread* watchdog_; | 67 GpuWatchdogThread* watchdog_; |
| 58 }; | 68 }; |
| 59 | 69 |
| 60 ~GpuWatchdogThread() override; | 70 ~GpuWatchdogThread() override; |
| 61 | 71 |
| 62 void OnAcknowledge(); | 72 void OnAcknowledge(); |
| 63 void OnCheck(bool after_suspend); | 73 void OnCheck(bool after_suspend); |
| 64 void DeliberatelyTerminateToRecoverFromHang(); | 74 void DeliberatelyTerminateToRecoverFromHang(); |
| 75 #if defined(USE_X11) |
| 76 void CheckXServerActive(); |
| 77 void SetupXServer(); |
| 78 void SetupXChangeProp(); |
| 79 #endif |
| 65 | 80 |
| 66 void OnAddPowerObserver(); | 81 void OnAddPowerObserver(); |
| 67 | 82 |
| 68 // Implement PowerObserver. | 83 // Implement PowerObserver. |
| 69 void OnSuspend() override; | 84 void OnSuspend() override; |
| 70 void OnResume() override; | 85 void OnResume() override; |
| 71 | 86 |
| 72 #if defined(OS_WIN) | 87 #if defined(OS_WIN) |
| 73 base::TimeDelta GetWatchedThreadTime(); | 88 base::TimeDelta GetWatchedThreadTime(); |
| 74 #endif | 89 #endif |
| (...skipping 11 matching lines...) Expand all Loading... |
| 86 // Time after which it's assumed that the computer has been suspended since | 101 // Time after which it's assumed that the computer has been suspended since |
| 87 // the task was posted. | 102 // the task was posted. |
| 88 base::Time suspension_timeout_; | 103 base::Time suspension_timeout_; |
| 89 | 104 |
| 90 bool suspended_; | 105 bool suspended_; |
| 91 | 106 |
| 92 #if defined(OS_CHROMEOS) | 107 #if defined(OS_CHROMEOS) |
| 93 FILE* tty_file_; | 108 FILE* tty_file_; |
| 94 #endif | 109 #endif |
| 95 | 110 |
| 111 #if defined(USE_X11) |
| 112 bool x_server_active_; |
| 113 XDisplay* display_; |
| 114 gfx::AcceleratedWidget window_; |
| 115 XAtom atom_; |
| 116 #endif |
| 117 |
| 96 base::WeakPtrFactory<GpuWatchdogThread> weak_factory_; | 118 base::WeakPtrFactory<GpuWatchdogThread> weak_factory_; |
| 97 | 119 |
| 98 DISALLOW_COPY_AND_ASSIGN(GpuWatchdogThread); | 120 DISALLOW_COPY_AND_ASSIGN(GpuWatchdogThread); |
| 99 }; | 121 }; |
| 100 | 122 |
| 101 } // namespace content | 123 } // namespace content |
| 102 | 124 |
| 103 #endif // CONTENT_GPU_GPU_WATCHDOG_THREAD_H_ | 125 #endif // CONTENT_GPU_GPU_WATCHDOG_THREAD_H_ |
| OLD | NEW |