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 GPU_IPC_SERVICE_GPU_WATCHDOG_THREAD_H_ | 5 #ifndef GPU_IPC_SERVICE_GPU_WATCHDOG_THREAD_H_ |
6 #define GPU_IPC_SERVICE_GPU_WATCHDOG_THREAD_H_ | 6 #define GPU_IPC_SERVICE_GPU_WATCHDOG_THREAD_H_ |
7 | 7 |
8 #include "base/atomicops.h" | 8 #include "base/atomicops.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/power_monitor/power_observer.h" | 13 #include "base/power_monitor/power_observer.h" |
14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "gpu/command_buffer/service/progress_reporter.h" |
17 #include "gpu/gpu_export.h" | 18 #include "gpu/gpu_export.h" |
18 #include "ui/gfx/native_widget_types.h" | 19 #include "ui/gfx/native_widget_types.h" |
19 | 20 |
20 #if defined(USE_X11) | 21 #if defined(USE_X11) |
21 extern "C" { | 22 extern "C" { |
22 #include <X11/Xlib.h> | 23 #include <X11/Xlib.h> |
23 #include <X11/Xatom.h> | 24 #include <X11/Xatom.h> |
24 } | 25 } |
25 #include <sys/poll.h> | 26 #include <sys/poll.h> |
26 #include "ui/base/x/x11_util.h" // nogncheck | 27 #include "ui/base/x/x11_util.h" // nogncheck |
27 #include "ui/gfx/x/x11_types.h" // nogncheck | 28 #include "ui/gfx/x/x11_types.h" // nogncheck |
28 #endif // defined(USE_X11) | 29 #endif // defined(USE_X11) |
29 | 30 |
30 namespace gpu { | 31 namespace gpu { |
31 | 32 |
32 // A thread that intermitently sends tasks to a group of watched message loops | 33 // 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. | 34 // and deliberately crashes if one of them does not respond after a timeout. |
34 class GPU_EXPORT GpuWatchdogThread | 35 class GPU_EXPORT GpuWatchdogThread |
35 : public base::Thread, | 36 : public base::Thread, |
36 public base::PowerObserver, | 37 public base::PowerObserver, |
| 38 public gles2::ProgressReporter, |
37 public base::RefCountedThreadSafe<GpuWatchdogThread> { | 39 public base::RefCountedThreadSafe<GpuWatchdogThread> { |
38 public: | 40 public: |
39 static scoped_refptr<GpuWatchdogThread> Create(); | 41 static scoped_refptr<GpuWatchdogThread> Create(); |
40 | 42 |
41 void PostAcknowledge(); | 43 void PostAcknowledge(); |
42 void CheckArmed(); | 44 void CheckArmed(); |
43 | 45 |
44 // Must be called after a PowerMonitor has been created. Can be called from | 46 // Must be called after a PowerMonitor has been created. Can be called from |
45 // any thread. | 47 // any thread. |
46 void AddPowerObserver(); | 48 void AddPowerObserver(); |
47 | 49 |
| 50 // gles2::ProgressReporter implementation: |
| 51 void ReportProgress() override; |
| 52 |
48 protected: | 53 protected: |
49 void Init() override; | 54 void Init() override; |
50 void CleanUp() override; | 55 void CleanUp() override; |
51 | 56 |
52 private: | 57 private: |
53 friend class base::RefCountedThreadSafe<GpuWatchdogThread>; | 58 friend class base::RefCountedThreadSafe<GpuWatchdogThread>; |
54 | 59 |
55 // An object of this type intercepts the reception and completion of all tasks | 60 // An object of this type intercepts the reception and completion of all tasks |
56 // on the watched thread and checks whether the watchdog is armed. | 61 // on the watched thread and checks whether the watchdog is armed. |
57 class GpuWatchdogTaskObserver : public base::MessageLoop::TaskObserver { | 62 class GpuWatchdogTaskObserver : public base::MessageLoop::TaskObserver { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 #endif | 148 #endif |
144 | 149 |
145 base::WeakPtrFactory<GpuWatchdogThread> weak_factory_; | 150 base::WeakPtrFactory<GpuWatchdogThread> weak_factory_; |
146 | 151 |
147 DISALLOW_COPY_AND_ASSIGN(GpuWatchdogThread); | 152 DISALLOW_COPY_AND_ASSIGN(GpuWatchdogThread); |
148 }; | 153 }; |
149 | 154 |
150 } // namespace gpu | 155 } // namespace gpu |
151 | 156 |
152 #endif // GPU_IPC_SERVICE_GPU_WATCHDOG_THREAD_H_ | 157 #endif // GPU_IPC_SERVICE_GPU_WATCHDOG_THREAD_H_ |
OLD | NEW |