diff options
author | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-28 06:36:15 +0000 |
---|---|---|
committer | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-28 06:36:15 +0000 |
commit | 69d5c51f4e36b7de5e89a2eab2d1fd179e4f4a27 (patch) | |
tree | 26e7e6c146725e92e66e1226a727add18fa563bc /content/gpu | |
parent | 355b853894c91bc1822d0737d55a5883d865d839 (diff) | |
download | chromium_src-69d5c51f4e36b7de5e89a2eab2d1fd179e4f4a27.zip chromium_src-69d5c51f4e36b7de5e89a2eab2d1fd179e4f4a27.tar.gz chromium_src-69d5c51f4e36b7de5e89a2eab2d1fd179e4f4a27.tar.bz2 |
RefCounted types should not have public destructors, content/browser part 2
BUG=123295
TEST=none
TBR=brettw
Review URL: https://chromiumcodereview.appspot.com/10071038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134446 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/gpu')
-rw-r--r-- | content/gpu/gpu_watchdog_thread.cc | 102 | ||||
-rw-r--r-- | content/gpu/gpu_watchdog_thread.h | 7 |
2 files changed, 56 insertions, 53 deletions
diff --git a/content/gpu/gpu_watchdog_thread.cc b/content/gpu/gpu_watchdog_thread.cc index d3b5c9a..5d6c088 100644 --- a/content/gpu/gpu_watchdog_thread.cc +++ b/content/gpu/gpu_watchdog_thread.cc @@ -50,18 +50,6 @@ GpuWatchdogThread::GpuWatchdogThread(int timeout) watched_message_loop_->AddTaskObserver(&task_observer_); } -GpuWatchdogThread::~GpuWatchdogThread() { - // Verify that the thread was explicitly stopped. If the thread is stopped - // implicitly by the destructor, CleanUp() will not be called. - DCHECK(!weak_factory_.HasWeakPtrs()); - -#if defined(OS_WIN) - CloseHandle(watched_thread_handle_); -#endif - - watched_message_loop_->RemoveTaskObserver(&task_observer_); -} - void GpuWatchdogThread::PostAcknowledge() { // Called on the monitored thread. Responds with OnAcknowledge. Cannot use // the method factory. Rely on reference counting instead. @@ -70,6 +58,14 @@ void GpuWatchdogThread::PostAcknowledge() { base::Bind(&GpuWatchdogThread::OnAcknowledge, this)); } +void GpuWatchdogThread::CheckArmed() { + // Acknowledge the watchdog if it has armed itself. The watchdog will not + // change its armed state until it is acknowledged. + if (armed()) { + PostAcknowledge(); + } +} + void GpuWatchdogThread::Init() { // Schedule the first check. OnCheck(); @@ -97,12 +93,16 @@ void GpuWatchdogThread::GpuWatchdogTaskObserver::DidProcessTask( watchdog_->CheckArmed(); } -void GpuWatchdogThread::CheckArmed() { - // Acknowledge the watchdog if it has armed itself. The watchdog will not - // change its armed state until it is acknowledged. - if (armed()) { - PostAcknowledge(); - } +GpuWatchdogThread::~GpuWatchdogThread() { + // Verify that the thread was explicitly stopped. If the thread is stopped + // implicitly by the destructor, CleanUp() will not be called. + DCHECK(!weak_factory_.HasWeakPtrs()); + +#if defined(OS_WIN) + CloseHandle(watched_thread_handle_); +#endif + + watched_message_loop_->RemoveTaskObserver(&task_observer_); } void GpuWatchdogThread::OnAcknowledge() { @@ -124,39 +124,6 @@ void GpuWatchdogThread::OnAcknowledge() { base::TimeDelta::FromMilliseconds(kCheckPeriodMs)); } -#if defined(OS_WIN) -base::TimeDelta GpuWatchdogThread::GetWatchedThreadTime() { - FILETIME creation_time; - FILETIME exit_time; - FILETIME user_time; - FILETIME kernel_time; - BOOL result = GetThreadTimes(watched_thread_handle_, - &creation_time, - &exit_time, - &kernel_time, - &user_time); - DCHECK(result); - - ULARGE_INTEGER user_time64; - user_time64.HighPart = user_time.dwHighDateTime; - user_time64.LowPart = user_time.dwLowDateTime; - - ULARGE_INTEGER kernel_time64; - kernel_time64.HighPart = kernel_time.dwHighDateTime; - kernel_time64.LowPart = kernel_time.dwLowDateTime; - - // Time is reported in units of 100 nanoseconds. Kernel and user time are - // summed to deal with to kinds of hangs. One is where the GPU process is - // stuck in user level, never calling into the kernel and kernel time is - // not increasing. The other is where either the kernel hangs and never - // returns to user level or where user level code - // calls into kernel level repeatedly, giving up its quanta before it is - // tracked, for example a loop that repeatedly Sleeps. - return base::TimeDelta::FromMilliseconds(static_cast<int64>( - (user_time64.QuadPart + kernel_time64.QuadPart) / 10000)); -} -#endif - void GpuWatchdogThread::OnCheck() { if (armed_) return; @@ -236,3 +203,36 @@ void GpuWatchdogThread::DeliberatelyTerminateToRecoverFromHang() { terminated = true; } + +#if defined(OS_WIN) +base::TimeDelta GpuWatchdogThread::GetWatchedThreadTime() { + FILETIME creation_time; + FILETIME exit_time; + FILETIME user_time; + FILETIME kernel_time; + BOOL result = GetThreadTimes(watched_thread_handle_, + &creation_time, + &exit_time, + &kernel_time, + &user_time); + DCHECK(result); + + ULARGE_INTEGER user_time64; + user_time64.HighPart = user_time.dwHighDateTime; + user_time64.LowPart = user_time.dwLowDateTime; + + ULARGE_INTEGER kernel_time64; + kernel_time64.HighPart = kernel_time.dwHighDateTime; + kernel_time64.LowPart = kernel_time.dwLowDateTime; + + // Time is reported in units of 100 nanoseconds. Kernel and user time are + // summed to deal with to kinds of hangs. One is where the GPU process is + // stuck in user level, never calling into the kernel and kernel time is + // not increasing. The other is where either the kernel hangs and never + // returns to user level or where user level code + // calls into kernel level repeatedly, giving up its quanta before it is + // tracked, for example a loop that repeatedly Sleeps. + return base::TimeDelta::FromMilliseconds(static_cast<int64>( + (user_time64.QuadPart + kernel_time64.QuadPart) / 10000)); +} +#endif diff --git a/content/gpu/gpu_watchdog_thread.h b/content/gpu/gpu_watchdog_thread.h index 8f3ee90..66a7d67 100644 --- a/content/gpu/gpu_watchdog_thread.h +++ b/content/gpu/gpu_watchdog_thread.h @@ -20,7 +20,6 @@ class GpuWatchdogThread : public base::Thread, public base::RefCountedThreadSafe<GpuWatchdogThread> { public: explicit GpuWatchdogThread(int timeout); - virtual ~GpuWatchdogThread(); // Accessible on watched thread but only modified by watchdog thread. bool armed() const { return armed_; } @@ -34,6 +33,7 @@ class GpuWatchdogThread : public base::Thread, virtual void CleanUp() OVERRIDE; private: + friend class base::RefCountedThreadSafe<GpuWatchdogThread>; // An object of this type intercepts the reception and completion of all tasks // on the watched thread and checks whether the watchdog is armed. @@ -50,12 +50,15 @@ class GpuWatchdogThread : public base::Thread, GpuWatchdogThread* watchdog_; }; + virtual ~GpuWatchdogThread(); + void OnAcknowledge(); void OnCheck(); void DeliberatelyTerminateToRecoverFromHang(); - void Disable(); +#if defined(OS_WIN) base::TimeDelta GetWatchedThreadTime(); +#endif MessageLoop* watched_message_loop_; base::TimeDelta timeout_; |