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 ShutdownCrash() { |
| 55 NullPointerCrash(__LINE__); |
| 56 } |
| 57 |
54 NOINLINE void ThreadUnresponsive_UI() { | 58 NOINLINE void ThreadUnresponsive_UI() { |
55 NullPointerCrash(__LINE__); | 59 NullPointerCrash(__LINE__); |
56 } | 60 } |
57 | 61 |
58 NOINLINE void ThreadUnresponsive_DB() { | 62 NOINLINE void ThreadUnresponsive_DB() { |
59 NullPointerCrash(__LINE__); | 63 NullPointerCrash(__LINE__); |
60 } | 64 } |
61 | 65 |
62 NOINLINE void ThreadUnresponsive_WEBKIT() { | 66 NOINLINE void ThreadUnresponsive_WEBKIT() { |
63 NullPointerCrash(__LINE__); | 67 NullPointerCrash(__LINE__); |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |