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/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/power_monitor/power_observer.h" | 12 #include "base/power_monitor/power_observer.h" |
13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "gpu/ipc/service/gpu_watchdog.h" | 16 #include "content/common/gpu/gpu_watchdog.h" |
17 #include "ui/gfx/native_widget_types.h" | 17 #include "ui/gfx/native_widget_types.h" |
18 | 18 |
19 #if defined(USE_X11) | 19 #if defined(USE_X11) |
20 extern "C" { | 20 extern "C" { |
21 #include <X11/Xlib.h> | 21 #include <X11/Xlib.h> |
22 #include <X11/Xatom.h> | 22 #include <X11/Xatom.h> |
23 } | 23 } |
24 #include <sys/poll.h> | 24 #include <sys/poll.h> |
25 #include "ui/base/x/x11_util.h" | 25 #include "ui/base/x/x11_util.h" |
26 #include "ui/gfx/x/x11_types.h" | 26 #include "ui/gfx/x/x11_types.h" |
27 | 27 |
28 #endif | 28 #endif |
29 | 29 |
30 namespace content { | 30 namespace content { |
31 | 31 |
32 // A thread that intermitently sends tasks to a group of watched message loops | 32 // A thread that intermitently sends tasks to a group of watched message loops |
33 // and deliberately crashes if one of them does not respond after a timeout. | 33 // and deliberately crashes if one of them does not respond after a timeout. |
34 class GpuWatchdogThread : public base::Thread, | 34 class GpuWatchdogThread : public base::Thread, |
35 public gpu::GpuWatchdog, | 35 public GpuWatchdog, |
36 public base::PowerObserver, | 36 public base::PowerObserver, |
37 public base::RefCountedThreadSafe<GpuWatchdogThread> { | 37 public base::RefCountedThreadSafe<GpuWatchdogThread> { |
38 public: | 38 public: |
39 explicit GpuWatchdogThread(int timeout); | 39 explicit GpuWatchdogThread(int timeout); |
40 | 40 |
41 // Accessible on watched thread but only modified by watchdog thread. | 41 // Accessible on watched thread but only modified by watchdog thread. |
42 bool armed() const { return armed_; } | 42 bool armed() const { return armed_; } |
43 void PostAcknowledge(); | 43 void PostAcknowledge(); |
44 | 44 |
45 // Implement gpu::GpuWatchdog. | 45 // Implement GpuWatchdog. |
46 void CheckArmed() override; | 46 void CheckArmed() override; |
47 | 47 |
48 // Must be called after a PowerMonitor has been created. Can be called from | 48 // Must be called after a PowerMonitor has been created. Can be called from |
49 // any thread. | 49 // any thread. |
50 void AddPowerObserver(); | 50 void AddPowerObserver(); |
51 | 51 |
52 protected: | 52 protected: |
53 void Init() override; | 53 void Init() override; |
54 void CleanUp() override; | 54 void CleanUp() override; |
55 | 55 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 #endif | 135 #endif |
136 | 136 |
137 base::WeakPtrFactory<GpuWatchdogThread> weak_factory_; | 137 base::WeakPtrFactory<GpuWatchdogThread> weak_factory_; |
138 | 138 |
139 DISALLOW_COPY_AND_ASSIGN(GpuWatchdogThread); | 139 DISALLOW_COPY_AND_ASSIGN(GpuWatchdogThread); |
140 }; | 140 }; |
141 | 141 |
142 } // namespace content | 142 } // namespace content |
143 | 143 |
144 #endif // CONTENT_GPU_GPU_WATCHDOG_THREAD_H_ | 144 #endif // CONTENT_GPU_GPU_WATCHDOG_THREAD_H_ |
OLD | NEW |