Commit 70128b0e authored by Olivier Li's avatar Olivier Li Committed by Commit Bot

Completely remove StartupTimeBomb

The time bomb is never armed since https://crrev.com/c/2042292 and
even back the the results had been discarded for years.

There is no plan to reactivate it. This is the process of of being
replaced by HangWatcher.

Bug: 1034046
Change-Id: I40d7c874000abc04ba327c0c483733ee4795460f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2054044Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Commit-Queue: Oliver Li <olivierli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741418}
parent 1b31144c
......@@ -99,7 +99,6 @@ class HistogramSynchronizer;
class KeyStorageLinux;
class NativeBackendKWallet;
class NativeDesktopMediaList;
class StartupTimeBomb;
namespace android_webview {
class AwFormDatabaseService;
......@@ -471,7 +470,6 @@ class BASE_EXPORT ScopedAllowBaseSyncPrimitivesOutsideBlockingScope {
friend class ::BrowserProcessImpl; // http://crbug.com/125207
friend class ::KeyStorageLinux;
friend class ::NativeDesktopMediaList;
friend class ::StartupTimeBomb;
friend class android::JavaHandlerThread;
friend class android_webview::
AwFormDatabaseService; // http://crbug.com/904431
......
......@@ -500,7 +500,6 @@ ChromeBrowserMainParts::ChromeBrowserMainParts(
browser_defaults::enable_help_app = false;
#if !defined(OS_ANDROID)
startup_watcher_ = std::make_unique<StartupTimeBomb>();
shutdown_watcher_ = std::make_unique<ShutdownWatcherHelper>();
#endif // !defined(OS_ANDROID)
}
......@@ -1710,9 +1709,6 @@ void ChromeBrowserMainParts::PostMainMessageLoopRun() {
// |shutdown_watcher_| object is destructed.
shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(300));
// Disarm the startup hang detector time bomb if it is still Arm'ed.
startup_watcher_->Disarm();
web_usb_detector_.reset();
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
......
......@@ -29,7 +29,6 @@ class StartupData;
class PrefService;
class Profile;
class StartupBrowserCreator;
class StartupTimeBomb;
class ShutdownWatcherHelper;
class WebUsbDetector;
......@@ -144,9 +143,6 @@ class ChromeBrowserMainParts : public content::BrowserMainParts {
int result_code_;
#if !defined(OS_ANDROID)
// Create StartupTimeBomb object for watching jank during startup.
std::unique_ptr<StartupTimeBomb> startup_watcher_;
// Create ShutdownWatcherHelper object for watching jank during shutdown.
// Please keep |shutdown_watcher| as the first object constructed, and hence
// it is destroyed last.
......
......@@ -473,16 +473,6 @@ bool ThreadWatcher::IsVeryUnresponsive() {
return unresponsive_count_ >= unresponsive_threshold_;
}
namespace {
// StartupTimeBomb::DisarmStartupTimeBomb() proxy, to avoid ifdefing out
// individual calls by ThreadWatcherList methods.
static void DisarmStartupTimeBomb() {
#if !defined(OS_ANDROID)
StartupTimeBomb::DisarmStartupTimeBomb();
#endif
}
} // namespace
// ThreadWatcherList methods and members.
//
// static
......@@ -515,16 +505,11 @@ void ThreadWatcherList::StartWatchingAll(
FROM_HERE,
base::Bind(&ThreadWatcherList::SetStopped, false));
if (!WatchDogThread::PostDelayedTask(
FROM_HERE,
base::Bind(&ThreadWatcherList::InitializeAndStartWatching,
unresponsive_threshold,
crash_on_hang_threads),
base::TimeDelta::FromSeconds(g_initialize_delay_seconds))) {
// Disarm() the startup timebomb, if we couldn't post the task to start the
// ThreadWatcher (becasue WatchDog thread is not running).
DisarmStartupTimeBomb();
}
WatchDogThread::PostDelayedTask(
FROM_HERE,
base::Bind(&ThreadWatcherList::InitializeAndStartWatching,
unresponsive_threshold, crash_on_hang_threads),
base::TimeDelta::FromSeconds(g_initialize_delay_seconds));
}
// static
......@@ -665,10 +650,6 @@ void ThreadWatcherList::InitializeAndStartWatching(
const CrashOnHangThreadMap& crash_on_hang_threads) {
DCHECK(WatchDogThread::CurrentlyOnWatchDogThread());
// Disarm the startup timebomb, even if stop has been called.
base::PostTask(FROM_HERE, {BrowserThread::UI},
base::BindOnce(&DisarmStartupTimeBomb));
// This method is deferred in relationship to its StopWatchingAll()
// counterpart. If a previous initialization has already happened, or if
// stop has been called, there's nothing left to do here.
......@@ -850,7 +831,7 @@ void WatchDogThread::CleanUp() {
g_watchdog_thread = nullptr;
}
// StartupTimeBomb and ShutdownWatcherHelper are not available on Android.
// ShutdownWatcherHelper is not available on Android.
#if !defined(OS_ANDROID)
namespace {
......@@ -902,72 +883,6 @@ class ShutdownWatchDogThread : public base::Watchdog {
} // namespace
// StartupTimeBomb methods and members.
//
// static
StartupTimeBomb* StartupTimeBomb::g_startup_timebomb_ = nullptr;
StartupTimeBomb::StartupTimeBomb()
: startup_watchdog_(nullptr),
thread_id_(base::PlatformThread::CurrentId()) {
CHECK(!g_startup_timebomb_);
g_startup_timebomb_ = this;
}
StartupTimeBomb::~StartupTimeBomb() {
DCHECK(this == g_startup_timebomb_);
DCHECK_EQ(thread_id_, base::PlatformThread::CurrentId());
if (startup_watchdog_)
Disarm();
g_startup_timebomb_ = nullptr;
}
void StartupTimeBomb::Arm(const base::TimeDelta& duration) {
DCHECK_EQ(thread_id_, base::PlatformThread::CurrentId());
DCHECK(!startup_watchdog_);
startup_watchdog_ = new StartupWatchDogThread(duration);
startup_watchdog_->Arm();
return;
}
void StartupTimeBomb::Disarm() {
DCHECK_EQ(thread_id_, base::PlatformThread::CurrentId());
if (startup_watchdog_) {
base::Watchdog* startup_watchdog = startup_watchdog_;
startup_watchdog_ = nullptr;
startup_watchdog->Disarm();
startup_watchdog->Cleanup();
DeleteStartupWatchdog(thread_id_, startup_watchdog);
}
}
// static
void StartupTimeBomb::DeleteStartupWatchdog(
const base::PlatformThreadId thread_id,
base::Watchdog* startup_watchdog) {
DCHECK_EQ(thread_id, base::PlatformThread::CurrentId());
if (startup_watchdog->IsJoinable()) {
// Allow the watchdog thread to shutdown on UI. Watchdog thread shutdowns
// very fast.
base::ScopedAllowBaseSyncPrimitivesOutsideBlockingScope allow_thread_join;
delete startup_watchdog;
return;
}
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::BindOnce(&StartupTimeBomb::DeleteStartupWatchdog, thread_id,
base::Unretained(startup_watchdog)),
base::TimeDelta::FromSeconds(10));
}
// static
void StartupTimeBomb::DisarmStartupTimeBomb() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (g_startup_timebomb_)
g_startup_timebomb_->Disarm();
}
// ShutdownWatcherHelper methods and members.
//
// ShutdownWatcherHelper is a wrapper class for detecting hangs during
......
......@@ -62,7 +62,6 @@
#include "content/public/browser/browser_thread.h"
class CustomThreadWatcher;
class StartupTimeBomb;
class ThreadWatcherList;
namespace base {
......@@ -394,7 +393,7 @@ class ThreadWatcherList {
// This constructs the |ThreadWatcherList| singleton and starts watching
// browser threads by calling StartWatching() on each browser thread that is
// watched. It disarms StartupTimeBomb.
// watched.
static void InitializeAndStartWatching(
uint32_t unresponsive_threshold,
const CrashOnHangThreadMap& crash_on_hang_threads);
......@@ -496,55 +495,10 @@ class WatchDogThread : public base::Thread {
DISALLOW_COPY_AND_ASSIGN(WatchDogThread);
};
// StartupTimeBomb is disabled on Android, see https://crbug.com/366699.
// NOTE: uncomment body of DisarmStartupTimeBomb() global function once
// StartupTimeBomb is enabled on Android.
// ShutdownWatcherHelper is useless on Android because there is no shutdown,
// Chrome is always killed one way or another (swiped away in the task
// switcher, OOM-killed, etc.).
#if !defined(OS_ANDROID)
// This is a wrapper class for getting the crash dumps of the hangs during
// startup.
class StartupTimeBomb {
public:
// This singleton is instantiated when the browser process is launched.
StartupTimeBomb();
// Destructor disarm's startup_watchdog_ (if it is arm'ed) so that alarm
// doesn't go off.
~StartupTimeBomb();
// Constructs |startup_watchdog_| which spawns a thread and starts timer.
// |duration| specifies how long |startup_watchdog_| will wait before it
// calls alarm.
void Arm(const base::TimeDelta& duration);
// Disarms |startup_watchdog_| thread and then deletes it which stops the
// Watchdog thread.
void Disarm();
// Disarms |g_startup_timebomb_|.
static void DisarmStartupTimeBomb();
private:
// Deletes the watchdog thread if it is joinable; otherwise it posts a delayed
// task to try again.
static void DeleteStartupWatchdog(const base::PlatformThreadId thread_id,
base::Watchdog* startup_watchdog);
// The singleton of this class.
static StartupTimeBomb* g_startup_timebomb_;
// Watches for hangs during startup until it is disarm'ed.
base::Watchdog* startup_watchdog_;
// The |thread_id_| on which this object is constructed.
const base::PlatformThreadId thread_id_;
DISALLOW_COPY_AND_ASSIGN(StartupTimeBomb);
};
// This is a wrapper class for detecting hangs during shutdown.
class ShutdownWatcherHelper {
public:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment