| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_GPU_GPU_WATCHDOG_THREAD_H_ | 5 #ifndef CHROME_GPU_GPU_WATCHDOG_THREAD_H_ |
| 6 #define CHROME_GPU_GPU_WATCHDOG_THREAD_H_ | 6 #define CHROME_GPU_GPU_WATCHDOG_THREAD_H_ |
| 7 | 7 |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 11 #include "base/task.h" | 11 #include "base/task.h" |
| 12 #include "base/thread.h" | 12 #include "base/thread.h" |
| 13 | 13 |
| 14 // A thread that intermitently sends tasks to a group of watched message loops | 14 // A thread that intermitently sends tasks to a group of watched message loops |
| 15 // and deliberately crashes if one of them does not respond after a timeout. | 15 // and deliberately crashes if one of them does not respond after a timeout. |
| 16 class GpuWatchdogThread : public base::Thread, | 16 class GpuWatchdogThread : public base::Thread, |
| 17 public base::RefCountedThreadSafe<GpuWatchdogThread> { | 17 public base::RefCountedThreadSafe<GpuWatchdogThread> { |
| 18 public: | 18 public: |
| 19 GpuWatchdogThread(MessageLoop* watched_message_loop, int timeout); | 19 explicit GpuWatchdogThread(int timeout); |
| 20 virtual ~GpuWatchdogThread(); | 20 virtual ~GpuWatchdogThread(); |
| 21 | 21 |
| 22 // Accessible on watched thread but only modified by watchdog thread. | 22 // Accessible on watched thread but only modified by watchdog thread. |
| 23 bool armed() const { return armed_; } | 23 bool armed() const { return armed_; } |
| 24 void PostAcknowledge(); | 24 void PostAcknowledge(); |
| 25 | 25 |
| 26 protected: | 26 protected: |
| 27 virtual void Init(); | 27 virtual void Init(); |
| 28 virtual void CleanUp(); | 28 virtual void CleanUp(); |
| 29 | 29 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 43 private: | 43 private: |
| 44 void CheckArmed(); | 44 void CheckArmed(); |
| 45 GpuWatchdogThread* watchdog_; | 45 GpuWatchdogThread* watchdog_; |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 void OnAcknowledge(); | 48 void OnAcknowledge(); |
| 49 void OnCheck(); | 49 void OnCheck(); |
| 50 void OnExit(); | 50 void OnExit(); |
| 51 void Disable(); | 51 void Disable(); |
| 52 | 52 |
| 53 int64 GetWatchedThreadTime(); |
| 54 |
| 53 MessageLoop* watched_message_loop_; | 55 MessageLoop* watched_message_loop_; |
| 54 int timeout_; | 56 int timeout_; |
| 55 volatile bool armed_; | 57 volatile bool armed_; |
| 56 GpuWatchdogTaskObserver task_observer_; | 58 GpuWatchdogTaskObserver task_observer_; |
| 57 | 59 |
| 60 #if defined(OS_WIN) |
| 61 void* watched_thread_handle_; |
| 62 int64 arm_time_; |
| 63 #endif |
| 64 |
| 58 typedef ScopedRunnableMethodFactory<GpuWatchdogThread> MethodFactory; | 65 typedef ScopedRunnableMethodFactory<GpuWatchdogThread> MethodFactory; |
| 59 scoped_ptr<MethodFactory> method_factory_; | 66 scoped_ptr<MethodFactory> method_factory_; |
| 60 | 67 |
| 61 DISALLOW_COPY_AND_ASSIGN(GpuWatchdogThread); | 68 DISALLOW_COPY_AND_ASSIGN(GpuWatchdogThread); |
| 62 }; | 69 }; |
| 63 | 70 |
| 64 #endif // CHROME_GPU_GPU_WATCHDOG_THREAD_H_ | 71 #endif // CHROME_GPU_GPU_WATCHDOG_THREAD_H_ |
| OLD | NEW |