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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 } | 44 } |
45 | 45 |
46 void NullPointerCrash(int line_number) { | 46 void NullPointerCrash(int line_number) { |
47 #ifndef NDEBUG | 47 #ifndef NDEBUG |
48 *NullPointer() = line_number; // Crash. | 48 *NullPointer() = line_number; // Crash. |
49 #else | 49 #else |
50 logging::DumpWithoutCrashing(); | 50 logging::DumpWithoutCrashing(); |
51 #endif | 51 #endif |
52 } | 52 } |
53 | 53 |
54 NOINLINE void StartupCrash() { | |
55 NullPointerCrash(__LINE__); | |
56 } | |
57 | |
58 NOINLINE void ShutdownCrash() { | |
59 NullPointerCrash(__LINE__); | |
60 } | |
61 | |
54 NOINLINE void ThreadUnresponsive_UI() { | 62 NOINLINE void ThreadUnresponsive_UI() { |
55 NullPointerCrash(__LINE__); | 63 NullPointerCrash(__LINE__); |
56 } | 64 } |
57 | 65 |
58 NOINLINE void ThreadUnresponsive_DB() { | 66 NOINLINE void ThreadUnresponsive_DB() { |
59 NullPointerCrash(__LINE__); | 67 NullPointerCrash(__LINE__); |
60 } | 68 } |
61 | 69 |
62 NOINLINE void ThreadUnresponsive_WEBKIT() { | 70 NOINLINE void ThreadUnresponsive_WEBKIT() { |
63 NullPointerCrash(__LINE__); | 71 NullPointerCrash(__LINE__); |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
839 // Class for detecting hangs during startup. | 847 // Class for detecting hangs during startup. |
840 class StartupWatchDogThread : public base::Watchdog { | 848 class StartupWatchDogThread : public base::Watchdog { |
841 public: | 849 public: |
842 // Constructor specifies how long the StartupWatchDogThread will wait before | 850 // Constructor specifies how long the StartupWatchDogThread will wait before |
843 // alarming. | 851 // alarming. |
844 explicit StartupWatchDogThread(const base::TimeDelta& duration) | 852 explicit StartupWatchDogThread(const base::TimeDelta& duration) |
845 : base::Watchdog(duration, "Startup watchdog thread", true) { | 853 : base::Watchdog(duration, "Startup watchdog thread", true) { |
846 } | 854 } |
847 | 855 |
848 // Alarm is called if the time expires after an Arm() without someone calling | 856 // Alarm is called if the time expires after an Arm() without someone calling |
849 // Disarm(). When Alarm goes off, in release mode we get the crash dump | 857 // Disarm(). When Alarm goes off, in release mode we get the crash dump |
eroman
2013/04/16 22:53:12
This comment no longer matches the code.
ramant (doing other things)
2013/04/16 23:00:40
Reverted this change. Shouldn't have changed the b
| |
850 // without crashing and in debug mode we break into the debugger. | 858 // without crashing and in debug mode we break into the debugger. |
851 virtual void Alarm() OVERRIDE { | 859 virtual void Alarm() OVERRIDE { |
852 #ifndef NDEBUG | 860 StartupCrash(); |
eroman
2013/04/16 22:53:12
Is this behavior change intentional? before it wou
ramant (doing other things)
2013/04/16 23:00:40
Reverted the change.
| |
853 DCHECK(false); | |
854 #else | |
855 logging::DumpWithoutCrashing(); | |
856 #endif | |
857 } | 861 } |
858 | 862 |
859 DISALLOW_COPY_AND_ASSIGN(StartupWatchDogThread); | 863 DISALLOW_COPY_AND_ASSIGN(StartupWatchDogThread); |
860 }; | 864 }; |
861 | 865 |
862 // ShutdownWatchDogThread methods and members. | 866 // ShutdownWatchDogThread methods and members. |
863 // | 867 // |
864 // Class for detecting hangs during shutdown. | 868 // Class for detecting hangs during shutdown. |
865 class ShutdownWatchDogThread : public base::Watchdog { | 869 class ShutdownWatchDogThread : public base::Watchdog { |
866 public: | 870 public: |
867 // Constructor specifies how long the ShutdownWatchDogThread will wait before | 871 // Constructor specifies how long the ShutdownWatchDogThread will wait before |
868 // alarming. | 872 // alarming. |
869 explicit ShutdownWatchDogThread(const base::TimeDelta& duration) | 873 explicit ShutdownWatchDogThread(const base::TimeDelta& duration) |
870 : base::Watchdog(duration, "Shutdown watchdog thread", true) { | 874 : base::Watchdog(duration, "Shutdown watchdog thread", true) { |
871 } | 875 } |
872 | 876 |
873 // Alarm is called if the time expires after an Arm() without someone calling | 877 // Alarm is called if the time expires after an Arm() without someone calling |
874 // Disarm(). We crash the browser if this method is called. | 878 // Disarm(). We crash the browser if this method is called. |
875 virtual void Alarm() OVERRIDE { | 879 virtual void Alarm() OVERRIDE { |
876 CHECK(false); | 880 ShutdownCrash(); |
877 } | 881 } |
878 | 882 |
879 DISALLOW_COPY_AND_ASSIGN(ShutdownWatchDogThread); | 883 DISALLOW_COPY_AND_ASSIGN(ShutdownWatchDogThread); |
880 }; | 884 }; |
881 } // namespace | 885 } // namespace |
882 | 886 |
883 // StartupTimeBomb methods and members. | 887 // StartupTimeBomb methods and members. |
884 // | 888 // |
885 // static | 889 // static |
886 StartupTimeBomb* StartupTimeBomb::g_startup_timebomb_ = NULL; | 890 StartupTimeBomb* StartupTimeBomb::g_startup_timebomb_ = NULL; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
976 | 980 |
977 #if defined(OS_WIN) | 981 #if defined(OS_WIN) |
978 // On Windows XP, give twice the time for shutdown. | 982 // On Windows XP, give twice the time for shutdown. |
979 if (base::win::GetVersion() <= base::win::VERSION_XP) | 983 if (base::win::GetVersion() <= base::win::VERSION_XP) |
980 actual_duration *= 2; | 984 actual_duration *= 2; |
981 #endif | 985 #endif |
982 | 986 |
983 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); | 987 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); |
984 shutdown_watchdog_->Arm(); | 988 shutdown_watchdog_->Arm(); |
985 } | 989 } |
OLD | NEW |