| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 void CheckArmed(); | 26 void CheckArmed(); |
| 27 | 27 |
| 28 protected: | 28 protected: |
| 29 virtual void Init(); | 29 virtual void Init(); |
| 30 virtual void CleanUp(); | 30 virtual void CleanUp(); |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 | 33 |
| 34 // An object of this type intercepts the reception and completion of all tasks | 34 // An object of this type intercepts the reception and completion of all tasks |
| 35 // on the watched thread and checks whether the watchdog is armed. | 35 // on the watched thread and checks whether the watchdog is armed. |
| 36 class GpuWatchdogTaskObserver : public MessageLoop::TaskObserver { | 36 class GpuWatchdogClosureObserver : public MessageLoop::ClosureObserver { |
| 37 public: | 37 public: |
| 38 explicit GpuWatchdogTaskObserver(GpuWatchdogThread* watchdog); | 38 explicit GpuWatchdogClosureObserver(GpuWatchdogThread* watchdog); |
| 39 virtual ~GpuWatchdogTaskObserver(); | 39 virtual ~GpuWatchdogClosureObserver(); |
| 40 | 40 |
| 41 // Implements MessageLoop::TaskObserver. | 41 // Implements MessageLoop::ClosureObserver. |
| 42 virtual void WillProcessTask(const Task* task); | 42 virtual void WillProcessClosure(base::TimeTicks time_posted) OVERRIDE; |
| 43 virtual void DidProcessTask(const Task* task); | 43 virtual void DidProcessClosure(base::TimeTicks time_posted) OVERRIDE; |
| 44 | 44 |
| 45 private: | 45 private: |
| 46 GpuWatchdogThread* watchdog_; | 46 GpuWatchdogThread* watchdog_; |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 void OnAcknowledge(); | 49 void OnAcknowledge(); |
| 50 void OnCheck(); | 50 void OnCheck(); |
| 51 void DeliberatelyCrashingToRecoverFromHang(); | 51 void DeliberatelyCrashingToRecoverFromHang(); |
| 52 void Disable(); | 52 void Disable(); |
| 53 | 53 |
| 54 int64 GetWatchedThreadTime(); | 54 int64 GetWatchedThreadTime(); |
| 55 | 55 |
| 56 MessageLoop* watched_message_loop_; | 56 MessageLoop* watched_message_loop_; |
| 57 int timeout_; | 57 int timeout_; |
| 58 volatile bool armed_; | 58 volatile bool armed_; |
| 59 GpuWatchdogTaskObserver task_observer_; | 59 GpuWatchdogClosureObserver closure_observer_; |
| 60 | 60 |
| 61 #if defined(OS_WIN) | 61 #if defined(OS_WIN) |
| 62 void* watched_thread_handle_; | 62 void* watched_thread_handle_; |
| 63 int64 arm_cpu_time_; | 63 int64 arm_cpu_time_; |
| 64 #endif | 64 #endif |
| 65 | 65 |
| 66 base::Time arm_absolute_time_; | 66 base::Time arm_absolute_time_; |
| 67 | 67 |
| 68 typedef ScopedRunnableMethodFactory<GpuWatchdogThread> MethodFactory; | 68 typedef ScopedRunnableMethodFactory<GpuWatchdogThread> MethodFactory; |
| 69 scoped_ptr<MethodFactory> method_factory_; | 69 scoped_ptr<MethodFactory> method_factory_; |
| 70 | 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(GpuWatchdogThread); | 71 DISALLOW_COPY_AND_ASSIGN(GpuWatchdogThread); |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 #endif // CONTENT_GPU_GPU_WATCHDOG_THREAD_H_ | 74 #endif // CONTENT_GPU_GPU_WATCHDOG_THREAD_H_ |
| OLD | NEW |