OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #if defined(OS_WIN) | 5 #if defined(OS_WIN) |
6 #include <windows.h> | 6 #include <windows.h> |
7 #endif | 7 #endif |
8 | 8 |
9 #include "content/gpu/gpu_watchdog_thread.h" | 9 #include "content/gpu/gpu_watchdog_thread.h" |
10 | 10 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 GpuWatchdogThread::~GpuWatchdogThread() { | 108 GpuWatchdogThread::~GpuWatchdogThread() { |
109 // Verify that the thread was explicitly stopped. If the thread is stopped | 109 // Verify that the thread was explicitly stopped. If the thread is stopped |
110 // implicitly by the destructor, CleanUp() will not be called. | 110 // implicitly by the destructor, CleanUp() will not be called. |
111 DCHECK(!weak_factory_.HasWeakPtrs()); | 111 DCHECK(!weak_factory_.HasWeakPtrs()); |
112 | 112 |
113 #if defined(OS_WIN) | 113 #if defined(OS_WIN) |
114 CloseHandle(watched_thread_handle_); | 114 CloseHandle(watched_thread_handle_); |
115 #endif | 115 #endif |
116 | 116 |
117 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); | 117 base::PowerMonitor::RemoveObserver(this); |
118 if (power_monitor) | |
119 power_monitor->RemoveObserver(this); | |
120 | 118 |
121 #if defined(OS_CHROMEOS) | 119 #if defined(OS_CHROMEOS) |
122 if (tty_file_) | 120 if (tty_file_) |
123 fclose(tty_file_); | 121 fclose(tty_file_); |
124 #endif | 122 #endif |
125 | 123 |
126 watched_message_loop_->RemoveTaskObserver(&task_observer_); | 124 watched_message_loop_->RemoveTaskObserver(&task_observer_); |
127 } | 125 } |
128 | 126 |
129 void GpuWatchdogThread::OnAcknowledge() { | 127 void GpuWatchdogThread::OnAcknowledge() { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 terminated = true; | 257 terminated = true; |
260 } | 258 } |
261 | 259 |
262 void GpuWatchdogThread::AddPowerObserver() { | 260 void GpuWatchdogThread::AddPowerObserver() { |
263 message_loop()->PostTask( | 261 message_loop()->PostTask( |
264 FROM_HERE, | 262 FROM_HERE, |
265 base::Bind(&GpuWatchdogThread::OnAddPowerObserver, this)); | 263 base::Bind(&GpuWatchdogThread::OnAddPowerObserver, this)); |
266 } | 264 } |
267 | 265 |
268 void GpuWatchdogThread::OnAddPowerObserver() { | 266 void GpuWatchdogThread::OnAddPowerObserver() { |
269 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); | 267 DCHECK(base::PowerMonitor::AddObserver(this)); |
270 DCHECK(power_monitor); | |
271 power_monitor->AddObserver(this); | |
272 } | 268 } |
273 | 269 |
274 void GpuWatchdogThread::OnSuspend() { | 270 void GpuWatchdogThread::OnSuspend() { |
275 suspended_ = true; | 271 suspended_ = true; |
276 | 272 |
277 // When suspending force an acknowledgement to cancel any pending termination | 273 // When suspending force an acknowledgement to cancel any pending termination |
278 // tasks. | 274 // tasks. |
279 OnAcknowledge(); | 275 OnAcknowledge(); |
280 } | 276 } |
281 | 277 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 // not increasing. The other is where either the kernel hangs and never | 310 // not increasing. The other is where either the kernel hangs and never |
315 // returns to user level or where user level code | 311 // returns to user level or where user level code |
316 // calls into kernel level repeatedly, giving up its quanta before it is | 312 // calls into kernel level repeatedly, giving up its quanta before it is |
317 // tracked, for example a loop that repeatedly Sleeps. | 313 // tracked, for example a loop that repeatedly Sleeps. |
318 return base::TimeDelta::FromMilliseconds(static_cast<int64>( | 314 return base::TimeDelta::FromMilliseconds(static_cast<int64>( |
319 (user_time64.QuadPart + kernel_time64.QuadPart) / 10000)); | 315 (user_time64.QuadPart + kernel_time64.QuadPart) / 10000)); |
320 } | 316 } |
321 #endif | 317 #endif |
322 | 318 |
323 } // namespace content | 319 } // namespace content |
OLD | NEW |