| 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 #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/debug/alias.h" | 10 #include "base/debug/alias.h" |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 WatchDogThread* WatchDogThread::watchdog_thread_ = NULL; | 623 WatchDogThread* WatchDogThread::watchdog_thread_ = NULL; |
| 624 | 624 |
| 625 // The WatchDogThread object must outlive any tasks posted to the IO thread | 625 // The WatchDogThread object must outlive any tasks posted to the IO thread |
| 626 // before the Quit task. | 626 // before the Quit task. |
| 627 DISABLE_RUNNABLE_METHOD_REFCOUNT(WatchDogThread); | 627 DISABLE_RUNNABLE_METHOD_REFCOUNT(WatchDogThread); |
| 628 | 628 |
| 629 WatchDogThread::WatchDogThread() : Thread("BrowserWatchdog") { | 629 WatchDogThread::WatchDogThread() : Thread("BrowserWatchdog") { |
| 630 } | 630 } |
| 631 | 631 |
| 632 WatchDogThread::~WatchDogThread() { | 632 WatchDogThread::~WatchDogThread() { |
| 633 // We cannot rely on our base class to stop the thread since we want our | |
| 634 // CleanUp function to run. | |
| 635 Stop(); | 633 Stop(); |
| 636 } | 634 } |
| 637 | 635 |
| 638 // static | 636 // static |
| 639 bool WatchDogThread::CurrentlyOnWatchDogThread() { | 637 bool WatchDogThread::CurrentlyOnWatchDogThread() { |
| 640 base::AutoLock lock(lock_); | 638 base::AutoLock lock(lock_); |
| 641 return watchdog_thread_ && | 639 return watchdog_thread_ && |
| 642 watchdog_thread_->message_loop() == MessageLoop::current(); | 640 watchdog_thread_->message_loop() == MessageLoop::current(); |
| 643 } | 641 } |
| 644 | 642 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 | 789 |
| 792 #if defined(OS_WIN) | 790 #if defined(OS_WIN) |
| 793 // On Windows XP, give twice the time for shutdown. | 791 // On Windows XP, give twice the time for shutdown. |
| 794 if (base::win::GetVersion() <= base::win::VERSION_XP) | 792 if (base::win::GetVersion() <= base::win::VERSION_XP) |
| 795 actual_duration *= 2; | 793 actual_duration *= 2; |
| 796 #endif | 794 #endif |
| 797 | 795 |
| 798 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); | 796 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); |
| 799 shutdown_watchdog_->Arm(); | 797 shutdown_watchdog_->Arm(); |
| 800 } | 798 } |
| OLD | NEW |