| Index: content/gpu/gpu_watchdog_thread.cc
|
| diff --git a/content/gpu/gpu_watchdog_thread.cc b/content/gpu/gpu_watchdog_thread.cc
|
| index d3b5c9a0a23b361b6ca50d3aa4fabdd8cac14088..5d6c0882de2bda28a7a73328aa988a3c41d60b39 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
|
|
|