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.h" | 10 #include "base/message_loop.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 protected: | 32 protected: |
33 virtual void Init() OVERRIDE; | 33 virtual void Init() OVERRIDE; |
34 virtual void CleanUp() OVERRIDE; | 34 virtual void CleanUp() OVERRIDE; |
35 | 35 |
36 private: | 36 private: |
37 friend class base::RefCountedThreadSafe<GpuWatchdogThread>; | 37 friend class base::RefCountedThreadSafe<GpuWatchdogThread>; |
38 | 38 |
39 // An object of this type intercepts the reception and completion of all tasks | 39 // An object of this type intercepts the reception and completion of all tasks |
40 // on the watched thread and checks whether the watchdog is armed. | 40 // on the watched thread and checks whether the watchdog is armed. |
41 class GpuWatchdogTaskObserver : public MessageLoop::TaskObserver { | 41 class GpuWatchdogTaskObserver : public base::MessageLoop::TaskObserver { |
42 public: | 42 public: |
43 explicit GpuWatchdogTaskObserver(GpuWatchdogThread* watchdog); | 43 explicit GpuWatchdogTaskObserver(GpuWatchdogThread* watchdog); |
44 virtual ~GpuWatchdogTaskObserver(); | 44 virtual ~GpuWatchdogTaskObserver(); |
45 | 45 |
46 // Implements MessageLoop::TaskObserver. | 46 // Implements MessageLoop::TaskObserver. |
47 virtual void WillProcessTask( | 47 virtual void WillProcessTask( |
48 const base::PendingTask& pending_task) OVERRIDE; | 48 const base::PendingTask& pending_task) OVERRIDE; |
49 virtual void DidProcessTask(const base::PendingTask& pending_task) OVERRIDE; | 49 virtual void DidProcessTask(const base::PendingTask& pending_task) OVERRIDE; |
50 | 50 |
51 private: | 51 private: |
52 GpuWatchdogThread* watchdog_; | 52 GpuWatchdogThread* watchdog_; |
53 }; | 53 }; |
54 | 54 |
55 virtual ~GpuWatchdogThread(); | 55 virtual ~GpuWatchdogThread(); |
56 | 56 |
57 void OnAcknowledge(); | 57 void OnAcknowledge(); |
58 void OnCheck(bool after_suspend); | 58 void OnCheck(bool after_suspend); |
59 void DeliberatelyTerminateToRecoverFromHang(); | 59 void DeliberatelyTerminateToRecoverFromHang(); |
60 | 60 |
61 #if defined(OS_WIN) | 61 #if defined(OS_WIN) |
62 base::TimeDelta GetWatchedThreadTime(); | 62 base::TimeDelta GetWatchedThreadTime(); |
63 #endif | 63 #endif |
64 | 64 |
65 MessageLoop* watched_message_loop_; | 65 base::MessageLoop* watched_message_loop_; |
66 base::TimeDelta timeout_; | 66 base::TimeDelta timeout_; |
67 volatile bool armed_; | 67 volatile bool armed_; |
68 GpuWatchdogTaskObserver task_observer_; | 68 GpuWatchdogTaskObserver task_observer_; |
69 | 69 |
70 #if defined(OS_WIN) | 70 #if defined(OS_WIN) |
71 void* watched_thread_handle_; | 71 void* watched_thread_handle_; |
72 base::TimeDelta arm_cpu_time_; | 72 base::TimeDelta arm_cpu_time_; |
73 #endif | 73 #endif |
74 | 74 |
75 // Time after which it's assumed that the computer has been suspended since | 75 // Time after which it's assumed that the computer has been suspended since |
76 // the task was posted. | 76 // the task was posted. |
77 base::Time suspension_timeout_; | 77 base::Time suspension_timeout_; |
78 | 78 |
79 base::WeakPtrFactory<GpuWatchdogThread> weak_factory_; | 79 base::WeakPtrFactory<GpuWatchdogThread> weak_factory_; |
80 | 80 |
81 DISALLOW_COPY_AND_ASSIGN(GpuWatchdogThread); | 81 DISALLOW_COPY_AND_ASSIGN(GpuWatchdogThread); |
82 }; | 82 }; |
83 | 83 |
84 } // namespace content | 84 } // namespace content |
85 | 85 |
86 #endif // CONTENT_GPU_GPU_WATCHDOG_THREAD_H_ | 86 #endif // CONTENT_GPU_GPU_WATCHDOG_THREAD_H_ |
OLD | NEW |