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 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 start_time_clock_= base::Time::Now(); | 925 start_time_clock_= base::Time::Now(); |
926 start_time_monotonic_ = base::TimeTicks::Now(); | 926 start_time_monotonic_ = base::TimeTicks::Now(); |
927 start_time_thread_now_ = base::TimeTicks::IsThreadNowSupported() | 927 start_time_thread_now_ = base::TimeTicks::IsThreadNowSupported() |
928 ? base::TimeTicks::ThreadNow() : base::TimeTicks::Now(); | 928 ? base::TimeTicks::ThreadNow() : base::TimeTicks::Now(); |
929 #endif // OS_ANDROID | 929 #endif // OS_ANDROID |
930 } | 930 } |
931 | 931 |
932 // Alarm is called if the time expires after an Arm() without someone calling | 932 // Alarm is called if the time expires after an Arm() without someone calling |
933 // Disarm(). When Alarm goes off, in release mode we get the crash dump | 933 // Disarm(). When Alarm goes off, in release mode we get the crash dump |
934 // without crashing and in debug mode we break into the debugger. | 934 // without crashing and in debug mode we break into the debugger. |
935 virtual void Alarm() override { | 935 void Alarm() override { |
936 #if !defined(NDEBUG) | 936 #if !defined(NDEBUG) |
937 StartupHang(); | 937 StartupHang(); |
938 return; | 938 return; |
939 #elif !defined(OS_ANDROID) | 939 #elif !defined(OS_ANDROID) |
940 WatchDogThread::PostTask(FROM_HERE, base::Bind(&StartupHang)); | 940 WatchDogThread::PostTask(FROM_HERE, base::Bind(&StartupHang)); |
941 return; | 941 return; |
942 #else // Android release: gather stats to figure out when to crash. | 942 #else // Android release: gather stats to figure out when to crash. |
943 // TODO(rtenneti): Delete this code, after getting data. | 943 // TODO(rtenneti): Delete this code, after getting data. |
944 UMA_HISTOGRAM_TIMES("StartupTimeBomb.Alarm.TimeDuration", | 944 UMA_HISTOGRAM_TIMES("StartupTimeBomb.Alarm.TimeDuration", |
945 base::Time::Now() - start_time_clock_); | 945 base::Time::Now() - start_time_clock_); |
(...skipping 25 matching lines...) Expand all Loading... |
971 class ShutdownWatchDogThread : public base::Watchdog { | 971 class ShutdownWatchDogThread : public base::Watchdog { |
972 public: | 972 public: |
973 // Constructor specifies how long the ShutdownWatchDogThread will wait before | 973 // Constructor specifies how long the ShutdownWatchDogThread will wait before |
974 // alarming. | 974 // alarming. |
975 explicit ShutdownWatchDogThread(const base::TimeDelta& duration) | 975 explicit ShutdownWatchDogThread(const base::TimeDelta& duration) |
976 : base::Watchdog(duration, "Shutdown watchdog thread", true) { | 976 : base::Watchdog(duration, "Shutdown watchdog thread", true) { |
977 } | 977 } |
978 | 978 |
979 // Alarm is called if the time expires after an Arm() without someone calling | 979 // Alarm is called if the time expires after an Arm() without someone calling |
980 // Disarm(). We crash the browser if this method is called. | 980 // Disarm(). We crash the browser if this method is called. |
981 virtual void Alarm() override { | 981 void Alarm() override { ShutdownHang(); } |
982 ShutdownHang(); | |
983 } | |
984 | 982 |
985 private: | 983 private: |
986 DISALLOW_COPY_AND_ASSIGN(ShutdownWatchDogThread); | 984 DISALLOW_COPY_AND_ASSIGN(ShutdownWatchDogThread); |
987 }; | 985 }; |
988 } // namespace | 986 } // namespace |
989 | 987 |
990 // StartupTimeBomb methods and members. | 988 // StartupTimeBomb methods and members. |
991 // | 989 // |
992 // static | 990 // static |
993 StartupTimeBomb* StartupTimeBomb::g_startup_timebomb_ = NULL; | 991 StartupTimeBomb* StartupTimeBomb::g_startup_timebomb_ = NULL; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 | 1079 |
1082 #if defined(OS_WIN) | 1080 #if defined(OS_WIN) |
1083 // On Windows XP, give twice the time for shutdown. | 1081 // On Windows XP, give twice the time for shutdown. |
1084 if (base::win::GetVersion() <= base::win::VERSION_XP) | 1082 if (base::win::GetVersion() <= base::win::VERSION_XP) |
1085 actual_duration *= 2; | 1083 actual_duration *= 2; |
1086 #endif | 1084 #endif |
1087 | 1085 |
1088 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); | 1086 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); |
1089 shutdown_watchdog_->Arm(); | 1087 shutdown_watchdog_->Arm(); |
1090 } | 1088 } |
OLD | NEW |