OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This file defines a WatchDog thread that monitors the responsiveness of other | 5 // This file defines a WatchDog thread that monitors the responsiveness of other |
6 // browser threads like UI, IO, DB, FILE and CACHED threads. It also defines | 6 // browser threads like UI, IO, DB, FILE and CACHED threads. It also defines |
7 // ThreadWatcher class which performs health check on threads that would like to | 7 // ThreadWatcher class which performs health check on threads that would like to |
8 // be watched. This file also defines ThreadWatcherList class that has list of | 8 // be watched. This file also defines ThreadWatcherList class that has list of |
9 // all active ThreadWatcher objects. | 9 // all active ThreadWatcher objects. |
10 // | 10 // |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 const base::Closure& task, | 486 const base::Closure& task, |
487 int64 delay_ms); | 487 int64 delay_ms); |
488 | 488 |
489 DISALLOW_COPY_AND_ASSIGN(WatchDogThread); | 489 DISALLOW_COPY_AND_ASSIGN(WatchDogThread); |
490 }; | 490 }; |
491 | 491 |
492 // This is a wrapper class for getting the crash dumps of the hangs during | 492 // This is a wrapper class for getting the crash dumps of the hangs during |
493 // startup. | 493 // startup. |
494 class StartupTimeBomb { | 494 class StartupTimeBomb { |
495 public: | 495 public: |
| 496 // This singleton is instantiated when the browser process is launched. |
| 497 StartupTimeBomb(); |
| 498 |
| 499 // Destructor disarm's startup_watchdog_ (if it is arm'ed) so that alarm |
| 500 // doesn't go off. |
| 501 ~StartupTimeBomb(); |
| 502 |
496 // Constructs |startup_watchdog_| which spawns a thread and starts timer. | 503 // Constructs |startup_watchdog_| which spawns a thread and starts timer. |
497 // |duration| specifies how long |startup_watchdog_| will wait before it | 504 // |duration| specifies how long |startup_watchdog_| will wait before it |
498 // calls alarm. | 505 // calls alarm. |
499 static void Arm(const base::TimeDelta& duration); | 506 void Arm(const base::TimeDelta& duration); |
500 | 507 |
501 // Disarms |startup_watchdog_| thread and then deletes it which stops the | 508 // Disarms |startup_watchdog_| thread and then deletes it which stops the |
502 // Watchdog thread. | 509 // Watchdog thread. |
503 static void Disarm(); | 510 void Disarm(); |
| 511 |
| 512 // Disarms |g_startup_timebomb_|. |
| 513 static void DisarmStartupTimeBomb(); |
504 | 514 |
505 private: | 515 private: |
506 // Watches for hangs during startup until it is disarm'ed. | 516 // Watches for hangs during startup until it is disarm'ed. |
507 static base::Watchdog* startup_watchdog_; | 517 base::Watchdog* startup_watchdog_; |
| 518 |
| 519 // The singleton of this class. |
| 520 static StartupTimeBomb* g_startup_timebomb_; |
508 | 521 |
509 DISALLOW_COPY_AND_ASSIGN(StartupTimeBomb); | 522 DISALLOW_COPY_AND_ASSIGN(StartupTimeBomb); |
510 }; | 523 }; |
511 | 524 |
512 // This is a wrapper class for detecting hangs during shutdown. | 525 // This is a wrapper class for detecting hangs during shutdown. |
513 class ShutdownWatcherHelper { | 526 class ShutdownWatcherHelper { |
514 public: | 527 public: |
515 // Create an empty holder for |shutdown_watchdog_|. | 528 // Create an empty holder for |shutdown_watchdog_|. |
516 ShutdownWatcherHelper(); | 529 ShutdownWatcherHelper(); |
517 | 530 |
(...skipping 10 matching lines...) Expand all Loading... |
528 | 541 |
529 DISALLOW_COPY_AND_ASSIGN(ShutdownWatcherHelper); | 542 DISALLOW_COPY_AND_ASSIGN(ShutdownWatcherHelper); |
530 }; | 543 }; |
531 | 544 |
532 // DISABLE_RUNNABLE_METHOD_REFCOUNT is a convenience macro for disabling | 545 // DISABLE_RUNNABLE_METHOD_REFCOUNT is a convenience macro for disabling |
533 // refcounting of ThreadWatcher and ThreadWatcherList classes. | 546 // refcounting of ThreadWatcher and ThreadWatcherList classes. |
534 DISABLE_RUNNABLE_METHOD_REFCOUNT(ThreadWatcher); | 547 DISABLE_RUNNABLE_METHOD_REFCOUNT(ThreadWatcher); |
535 DISABLE_RUNNABLE_METHOD_REFCOUNT(ThreadWatcherList); | 548 DISABLE_RUNNABLE_METHOD_REFCOUNT(ThreadWatcherList); |
536 | 549 |
537 #endif // CHROME_BROWSER_METRICS_THREAD_WATCHER_H_ | 550 #endif // CHROME_BROWSER_METRICS_THREAD_WATCHER_H_ |
OLD | NEW |