Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1476)

Unified Diff: content/gpu/gpu_watchdog_thread.cc

Issue 10071038: RefCounted types should not have public destructors, content/browser part 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Copyright bump Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/gpu/gpu_watchdog_thread.h ('k') | content/renderer/devtools_agent_filter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « content/gpu/gpu_watchdog_thread.h ('k') | content/renderer/devtools_agent_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698