| 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 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 public: | 805 public: |
| 806 // Constructor specifies how long the StartupWatchDogThread will wait before | 806 // Constructor specifies how long the StartupWatchDogThread will wait before |
| 807 // alarming. | 807 // alarming. |
| 808 explicit StartupWatchDogThread(const base::TimeDelta& duration) | 808 explicit StartupWatchDogThread(const base::TimeDelta& duration) |
| 809 : base::Watchdog(duration, "Startup watchdog thread", true) { | 809 : base::Watchdog(duration, "Startup watchdog thread", true) { |
| 810 } | 810 } |
| 811 | 811 |
| 812 // Alarm is called if the time expires after an Arm() without someone calling | 812 // Alarm is called if the time expires after an Arm() without someone calling |
| 813 // Disarm(). When Alarm goes off, in release mode we get the crash dump | 813 // Disarm(). When Alarm goes off, in release mode we get the crash dump |
| 814 // without crashing and in debug mode we break into the debugger. | 814 // without crashing and in debug mode we break into the debugger. |
| 815 virtual void Alarm() { | 815 virtual void Alarm() OVERRIDE { |
| 816 #ifndef NDEBUG | 816 #ifndef NDEBUG |
| 817 DCHECK(false); | 817 DCHECK(false); |
| 818 #else | 818 #else |
| 819 logging::DumpWithoutCrashing(); | 819 logging::DumpWithoutCrashing(); |
| 820 #endif | 820 #endif |
| 821 } | 821 } |
| 822 | 822 |
| 823 DISALLOW_COPY_AND_ASSIGN(StartupWatchDogThread); | 823 DISALLOW_COPY_AND_ASSIGN(StartupWatchDogThread); |
| 824 }; | 824 }; |
| 825 | 825 |
| 826 // ShutdownWatchDogThread methods and members. | 826 // ShutdownWatchDogThread methods and members. |
| 827 // | 827 // |
| 828 // Class for detecting hangs during shutdown. | 828 // Class for detecting hangs during shutdown. |
| 829 class ShutdownWatchDogThread : public base::Watchdog { | 829 class ShutdownWatchDogThread : public base::Watchdog { |
| 830 public: | 830 public: |
| 831 // Constructor specifies how long the ShutdownWatchDogThread will wait before | 831 // Constructor specifies how long the ShutdownWatchDogThread will wait before |
| 832 // alarming. | 832 // alarming. |
| 833 explicit ShutdownWatchDogThread(const base::TimeDelta& duration) | 833 explicit ShutdownWatchDogThread(const base::TimeDelta& duration) |
| 834 : base::Watchdog(duration, "Shutdown watchdog thread", true) { | 834 : base::Watchdog(duration, "Shutdown watchdog thread", true) { |
| 835 } | 835 } |
| 836 | 836 |
| 837 // Alarm is called if the time expires after an Arm() without someone calling | 837 // Alarm is called if the time expires after an Arm() without someone calling |
| 838 // Disarm(). We crash the browser if this method is called. | 838 // Disarm(). We crash the browser if this method is called. |
| 839 virtual void Alarm() { | 839 virtual void Alarm() OVERRIDE { |
| 840 CHECK(false); | 840 CHECK(false); |
| 841 } | 841 } |
| 842 | 842 |
| 843 DISALLOW_COPY_AND_ASSIGN(ShutdownWatchDogThread); | 843 DISALLOW_COPY_AND_ASSIGN(ShutdownWatchDogThread); |
| 844 }; | 844 }; |
| 845 } // namespace | 845 } // namespace |
| 846 | 846 |
| 847 // StartupTimeBomb methods and members. | 847 // StartupTimeBomb methods and members. |
| 848 // | 848 // |
| 849 // static | 849 // static |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 | 940 |
| 941 #if defined(OS_WIN) | 941 #if defined(OS_WIN) |
| 942 // On Windows XP, give twice the time for shutdown. | 942 // On Windows XP, give twice the time for shutdown. |
| 943 if (base::win::GetVersion() <= base::win::VERSION_XP) | 943 if (base::win::GetVersion() <= base::win::VERSION_XP) |
| 944 actual_duration *= 2; | 944 actual_duration *= 2; |
| 945 #endif | 945 #endif |
| 946 | 946 |
| 947 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); | 947 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); |
| 948 shutdown_watchdog_->Arm(); | 948 shutdown_watchdog_->Arm(); |
| 949 } | 949 } |
| OLD | NEW |