OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" |
12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
13 #include "base/process_util.h" | 14 #include "base/process_util.h" |
14 #include "base/process.h" | 15 #include "base/process.h" |
15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
16 #include "content/public/common/result_codes.h" | 17 #include "content/public/common/result_codes.h" |
17 | 18 |
18 namespace { | 19 namespace { |
19 const int64 kCheckPeriod = 2000; | 20 const int64 kCheckPeriod = 2000; |
20 | 21 } // namespace |
21 void DoNothing() { | |
22 } | |
23 } | |
24 | 22 |
25 GpuWatchdogThread::GpuWatchdogThread(int timeout) | 23 GpuWatchdogThread::GpuWatchdogThread(int timeout) |
26 : base::Thread("Watchdog"), | 24 : base::Thread("Watchdog"), |
27 watched_message_loop_(MessageLoop::current()), | 25 watched_message_loop_(MessageLoop::current()), |
28 timeout_(timeout), | 26 timeout_(timeout), |
29 armed_(false), | 27 armed_(false), |
30 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
31 watched_thread_handle_(0), | 29 watched_thread_handle_(0), |
32 arm_cpu_time_(0), | 30 arm_cpu_time_(0), |
33 #endif | 31 #endif |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 arm_cpu_time_ = GetWatchedThreadTime(); | 170 arm_cpu_time_ = GetWatchedThreadTime(); |
173 #endif | 171 #endif |
174 | 172 |
175 arm_absolute_time_ = base::Time::Now(); | 173 arm_absolute_time_ = base::Time::Now(); |
176 | 174 |
177 // Post a task to the monitored thread that does nothing but wake up the | 175 // Post a task to the monitored thread that does nothing but wake up the |
178 // TaskObserver. Any other tasks that are pending on the watched thread will | 176 // TaskObserver. Any other tasks that are pending on the watched thread will |
179 // also wake up the observer. This simply ensures there is at least one. | 177 // also wake up the observer. This simply ensures there is at least one. |
180 watched_message_loop_->PostTask( | 178 watched_message_loop_->PostTask( |
181 FROM_HERE, | 179 FROM_HERE, |
182 base::Bind(&DoNothing)); | 180 base::Bind(&base::DoNothing)); |
183 | 181 |
184 // Post a task to the watchdog thread to exit if the monitored thread does | 182 // Post a task to the watchdog thread to exit if the monitored thread does |
185 // not respond in time. | 183 // not respond in time. |
186 message_loop()->PostDelayedTask( | 184 message_loop()->PostDelayedTask( |
187 FROM_HERE, | 185 FROM_HERE, |
188 base::Bind( | 186 base::Bind( |
189 &GpuWatchdogThread::DeliberatelyTerminateToRecoverFromHang, | 187 &GpuWatchdogThread::DeliberatelyTerminateToRecoverFromHang, |
190 weak_factory_.GetWeakPtr()), | 188 weak_factory_.GetWeakPtr()), |
191 timeout_); | 189 timeout_); |
192 } | 190 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 #endif | 230 #endif |
233 | 231 |
234 LOG(ERROR) << "The GPU process hung. Terminating after " | 232 LOG(ERROR) << "The GPU process hung. Terminating after " |
235 << timeout_ << " ms."; | 233 << timeout_ << " ms."; |
236 | 234 |
237 base::Process current_process(base::GetCurrentProcessHandle()); | 235 base::Process current_process(base::GetCurrentProcessHandle()); |
238 current_process.Terminate(content::RESULT_CODE_HUNG); | 236 current_process.Terminate(content::RESULT_CODE_HUNG); |
239 | 237 |
240 terminated = true; | 238 terminated = true; |
241 } | 239 } |
OLD | NEW |