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::RemoveObserver(this); | 117 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); |
| 118 if (power_monitor) |
| 119 power_monitor->RemoveObserver(this); |
118 | 120 |
119 #if defined(OS_CHROMEOS) | 121 #if defined(OS_CHROMEOS) |
120 if (tty_file_) | 122 if (tty_file_) |
121 fclose(tty_file_); | 123 fclose(tty_file_); |
122 #endif | 124 #endif |
123 | 125 |
124 watched_message_loop_->RemoveTaskObserver(&task_observer_); | 126 watched_message_loop_->RemoveTaskObserver(&task_observer_); |
125 } | 127 } |
126 | 128 |
127 void GpuWatchdogThread::OnAcknowledge() { | 129 void GpuWatchdogThread::OnAcknowledge() { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 terminated = true; | 259 terminated = true; |
258 } | 260 } |
259 | 261 |
260 void GpuWatchdogThread::AddPowerObserver() { | 262 void GpuWatchdogThread::AddPowerObserver() { |
261 message_loop()->PostTask( | 263 message_loop()->PostTask( |
262 FROM_HERE, | 264 FROM_HERE, |
263 base::Bind(&GpuWatchdogThread::OnAddPowerObserver, this)); | 265 base::Bind(&GpuWatchdogThread::OnAddPowerObserver, this)); |
264 } | 266 } |
265 | 267 |
266 void GpuWatchdogThread::OnAddPowerObserver() { | 268 void GpuWatchdogThread::OnAddPowerObserver() { |
267 DCHECK(base::PowerMonitor::AddObserver(this)); | 269 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); |
| 270 DCHECK(power_monitor); |
| 271 power_monitor->AddObserver(this); |
268 } | 272 } |
269 | 273 |
270 void GpuWatchdogThread::OnSuspend() { | 274 void GpuWatchdogThread::OnSuspend() { |
271 suspended_ = true; | 275 suspended_ = true; |
272 | 276 |
273 // When suspending force an acknowledgement to cancel any pending termination | 277 // When suspending force an acknowledgement to cancel any pending termination |
274 // tasks. | 278 // tasks. |
275 OnAcknowledge(); | 279 OnAcknowledge(); |
276 } | 280 } |
277 | 281 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 // not increasing. The other is where either the kernel hangs and never | 314 // not increasing. The other is where either the kernel hangs and never |
311 // returns to user level or where user level code | 315 // returns to user level or where user level code |
312 // calls into kernel level repeatedly, giving up its quanta before it is | 316 // calls into kernel level repeatedly, giving up its quanta before it is |
313 // tracked, for example a loop that repeatedly Sleeps. | 317 // tracked, for example a loop that repeatedly Sleeps. |
314 return base::TimeDelta::FromMilliseconds(static_cast<int64>( | 318 return base::TimeDelta::FromMilliseconds(static_cast<int64>( |
315 (user_time64.QuadPart + kernel_time64.QuadPart) / 10000)); | 319 (user_time64.QuadPart + kernel_time64.QuadPart) / 10000)); |
316 } | 320 } |
317 #endif | 321 #endif |
318 | 322 |
319 } // namespace content | 323 } // namespace content |
OLD | NEW |