Chromium Code Reviews| 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 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 845 void StartupTimeBomb::Arm(const base::TimeDelta& duration) { | 845 void StartupTimeBomb::Arm(const base::TimeDelta& duration) { |
| 846 DCHECK_EQ(thread_id_, base::PlatformThread::CurrentId()); | 846 DCHECK_EQ(thread_id_, base::PlatformThread::CurrentId()); |
| 847 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 847 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 848 DCHECK(!startup_watchdog_); | 848 DCHECK(!startup_watchdog_); |
| 849 startup_watchdog_ = new StartupWatchDogThread(duration); | 849 startup_watchdog_ = new StartupWatchDogThread(duration); |
| 850 startup_watchdog_->Arm(); | 850 startup_watchdog_->Arm(); |
| 851 } | 851 } |
| 852 | 852 |
| 853 void StartupTimeBomb::Disarm() { | 853 void StartupTimeBomb::Disarm() { |
| 854 DCHECK_EQ(thread_id_, base::PlatformThread::CurrentId()); | 854 DCHECK_EQ(thread_id_, base::PlatformThread::CurrentId()); |
| 855 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 855 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
|
jar (doing other things)
2012/01/18 17:24:44
FYI: This is an assertion that is failing on the t
ramant (doing other things)
2012/01/18 20:45:30
It was being run on Test thread. The DCHECK was wr
| |
| 856 if (startup_watchdog_) { | 856 if (startup_watchdog_) { |
| 857 startup_watchdog_->Disarm(); | 857 startup_watchdog_->Disarm(); |
| 858 startup_watchdog_->Cleanup(); | |
| 859 DeleteStartupWatchdog(); | |
| 860 } | |
| 861 } | |
| 862 | |
| 863 void StartupTimeBomb::DeleteStartupWatchdog() { | |
| 864 DCHECK_EQ(thread_id_, base::PlatformThread::CurrentId()); | |
| 865 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 866 if (startup_watchdog_->IsJoinable()) { | |
| 858 // Allow the watchdog thread to shutdown on UI. Watchdog thread shutdowns | 867 // Allow the watchdog thread to shutdown on UI. Watchdog thread shutdowns |
| 859 // very fast. | 868 // very fast. |
| 860 base::ThreadRestrictions::SetIOAllowed(true); | 869 base::ThreadRestrictions::SetIOAllowed(true); |
| 861 delete startup_watchdog_; | 870 delete startup_watchdog_; |
| 862 startup_watchdog_ = NULL; | 871 startup_watchdog_ = NULL; |
| 872 return; | |
| 863 } | 873 } |
| 874 MessageLoop::current()->PostDelayedTask( | |
| 875 FROM_HERE, | |
| 876 base::Bind(&StartupTimeBomb::DeleteStartupWatchdog, | |
| 877 base::Unretained(this)), | |
| 878 base::TimeDelta::FromSeconds(10).InMilliseconds()); | |
| 864 } | 879 } |
| 865 | 880 |
| 866 // static | 881 // static |
| 867 void StartupTimeBomb::DisarmStartupTimeBomb() { | 882 void StartupTimeBomb::DisarmStartupTimeBomb() { |
| 868 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 883 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 869 if (g_startup_timebomb_) | 884 if (g_startup_timebomb_) |
| 870 g_startup_timebomb_->Disarm(); | 885 g_startup_timebomb_->Disarm(); |
| 871 } | 886 } |
| 872 | 887 |
| 873 // ShutdownWatcherHelper methods and members. | 888 // ShutdownWatcherHelper methods and members. |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 903 | 918 |
| 904 #if defined(OS_WIN) | 919 #if defined(OS_WIN) |
| 905 // On Windows XP, give twice the time for shutdown. | 920 // On Windows XP, give twice the time for shutdown. |
| 906 if (base::win::GetVersion() <= base::win::VERSION_XP) | 921 if (base::win::GetVersion() <= base::win::VERSION_XP) |
| 907 actual_duration *= 2; | 922 actual_duration *= 2; |
| 908 #endif | 923 #endif |
| 909 | 924 |
| 910 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); | 925 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); |
| 911 shutdown_watchdog_->Arm(); | 926 shutdown_watchdog_->Arm(); |
| 912 } | 927 } |
| OLD | NEW |