| 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/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 // WatchDogThread methods and members. | 715 // WatchDogThread methods and members. |
| 716 | 716 |
| 717 // This lock protects g_watchdog_thread. | 717 // This lock protects g_watchdog_thread. |
| 718 static base::LazyInstance<base::Lock, | 718 static base::LazyInstance<base::Lock, |
| 719 base::LeakyLazyInstanceTraits<base::Lock> > | 719 base::LeakyLazyInstanceTraits<base::Lock> > |
| 720 g_watchdog_lock = LAZY_INSTANCE_INITIALIZER; | 720 g_watchdog_lock = LAZY_INSTANCE_INITIALIZER; |
| 721 | 721 |
| 722 // The singleton of this class. | 722 // The singleton of this class. |
| 723 static WatchDogThread* g_watchdog_thread = NULL; | 723 static WatchDogThread* g_watchdog_thread = NULL; |
| 724 | 724 |
| 725 | |
| 726 // The WatchDogThread object must outlive any tasks posted to the IO thread | |
| 727 // before the Quit task. | |
| 728 DISABLE_RUNNABLE_METHOD_REFCOUNT(WatchDogThread); | |
| 729 | |
| 730 WatchDogThread::WatchDogThread() : Thread("BrowserWatchdog") { | 725 WatchDogThread::WatchDogThread() : Thread("BrowserWatchdog") { |
| 731 } | 726 } |
| 732 | 727 |
| 733 WatchDogThread::~WatchDogThread() { | 728 WatchDogThread::~WatchDogThread() { |
| 734 Stop(); | 729 Stop(); |
| 735 } | 730 } |
| 736 | 731 |
| 737 // static | 732 // static |
| 738 bool WatchDogThread::CurrentlyOnWatchDogThread() { | 733 bool WatchDogThread::CurrentlyOnWatchDogThread() { |
| 739 base::AutoLock lock(g_watchdog_lock.Get()); | 734 base::AutoLock lock(g_watchdog_lock.Get()); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 | 911 |
| 917 #if defined(OS_WIN) | 912 #if defined(OS_WIN) |
| 918 // On Windows XP, give twice the time for shutdown. | 913 // On Windows XP, give twice the time for shutdown. |
| 919 if (base::win::GetVersion() <= base::win::VERSION_XP) | 914 if (base::win::GetVersion() <= base::win::VERSION_XP) |
| 920 actual_duration *= 2; | 915 actual_duration *= 2; |
| 921 #endif | 916 #endif |
| 922 | 917 |
| 923 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); | 918 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); |
| 924 shutdown_watchdog_->Arm(); | 919 shutdown_watchdog_->Arm(); |
| 925 } | 920 } |
| OLD | NEW |