| 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 #include "chrome/browser/metrics/thread_watcher.h" | 5 #include "chrome/browser/metrics/thread_watcher.h" |
| 6 | 6 |
| 7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // Send a ping message to the watched thread. Callback will be called on | 144 // Send a ping message to the watched thread. Callback will be called on |
| 145 // the WatchDogThread. | 145 // the WatchDogThread. |
| 146 base::Closure callback( | 146 base::Closure callback( |
| 147 base::Bind(&ThreadWatcher::OnPongMessage, weak_ptr_factory_.GetWeakPtr(), | 147 base::Bind(&ThreadWatcher::OnPongMessage, weak_ptr_factory_.GetWeakPtr(), |
| 148 ping_sequence_number_)); | 148 ping_sequence_number_)); |
| 149 if (watched_runner_->PostTask( | 149 if (watched_runner_->PostTask( |
| 150 FROM_HERE, | 150 FROM_HERE, |
| 151 base::Bind(&ThreadWatcher::OnPingMessage, thread_id_, | 151 base::Bind(&ThreadWatcher::OnPingMessage, thread_id_, |
| 152 callback))) { | 152 callback))) { |
| 153 // Post a task to check the responsiveness of watched thread. | 153 // Post a task to check the responsiveness of watched thread. |
| 154 base::MessageLoop::current()->PostDelayedTask( | 154 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 155 FROM_HERE, | 155 FROM_HERE, |
| 156 base::Bind(&ThreadWatcher::OnCheckResponsiveness, | 156 base::Bind(&ThreadWatcher::OnCheckResponsiveness, |
| 157 weak_ptr_factory_.GetWeakPtr(), ping_sequence_number_), | 157 weak_ptr_factory_.GetWeakPtr(), ping_sequence_number_), |
| 158 unresponsive_time_); | 158 unresponsive_time_); |
| 159 } else { | 159 } else { |
| 160 // Watched thread might have gone away, stop watching it. | 160 // Watched thread might have gone away, stop watching it. |
| 161 DeActivateThreadWatching(); | 161 DeActivateThreadWatching(); |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 | 164 |
| (...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 | 1000 |
| 1001 #if defined(OS_WIN) | 1001 #if defined(OS_WIN) |
| 1002 // On Windows XP, give twice the time for shutdown. | 1002 // On Windows XP, give twice the time for shutdown. |
| 1003 if (base::win::GetVersion() <= base::win::VERSION_XP) | 1003 if (base::win::GetVersion() <= base::win::VERSION_XP) |
| 1004 actual_duration *= 2; | 1004 actual_duration *= 2; |
| 1005 #endif | 1005 #endif |
| 1006 | 1006 |
| 1007 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); | 1007 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); |
| 1008 shutdown_watchdog_->Arm(); | 1008 shutdown_watchdog_->Arm(); |
| 1009 } | 1009 } |
| OLD | NEW |