| 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 // 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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 // all thread watchers that are registered. | 403 // all thread watchers that are registered. |
| 404 static void WakeUpAll(); | 404 static void WakeUpAll(); |
| 405 | 405 |
| 406 private: | 406 private: |
| 407 // Allow tests to access our innards for testing purposes. | 407 // Allow tests to access our innards for testing purposes. |
| 408 friend class CustomThreadWatcher; | 408 friend class CustomThreadWatcher; |
| 409 friend class ThreadWatcherTest; | 409 friend class ThreadWatcherTest; |
| 410 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherTest, ThreadNamesOnlyArgs); | 410 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherTest, ThreadNamesOnlyArgs); |
| 411 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherTest, ThreadNamesAndLiveThresholdArgs); | 411 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherTest, ThreadNamesAndLiveThresholdArgs); |
| 412 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherTest, CrashOnHangThreadsAllArgs); | 412 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherTest, CrashOnHangThreadsAllArgs); |
| 413 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherListTest, Restart); |
| 413 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherAndroidTest, | 414 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherAndroidTest, |
| 414 ApplicationStatusNotification); | 415 ApplicationStatusNotification); |
| 415 | 416 |
| 416 // This singleton holds the global list of registered ThreadWatchers. | 417 // This singleton holds the global list of registered ThreadWatchers. |
| 417 ThreadWatcherList(); | 418 ThreadWatcherList(); |
| 418 | 419 |
| 419 // Destructor deletes all registered ThreadWatcher instances. | 420 // Destructor deletes all registered ThreadWatcher instances. |
| 420 virtual ~ThreadWatcherList(); | 421 virtual ~ThreadWatcherList(); |
| 421 | 422 |
| 422 // Parses the command line to get |crash_on_hang_threads| map from | 423 // Parses the command line to get |crash_on_hang_threads| map from |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 const CrashOnHangThreadMap& crash_on_hang_threads); | 458 const CrashOnHangThreadMap& crash_on_hang_threads); |
| 458 | 459 |
| 459 // Delete all thread watcher objects and remove them from global map. It also | 460 // Delete all thread watcher objects and remove them from global map. It also |
| 460 // deletes |g_thread_watcher_list_|. | 461 // deletes |g_thread_watcher_list_|. |
| 461 static void DeleteAll(); | 462 static void DeleteAll(); |
| 462 | 463 |
| 463 // The Find() method can be used to test to see if a given ThreadWatcher was | 464 // The Find() method can be used to test to see if a given ThreadWatcher was |
| 464 // already registered, or to retrieve a pointer to it from the global map. | 465 // already registered, or to retrieve a pointer to it from the global map. |
| 465 static ThreadWatcher* Find(const content::BrowserThread::ID& thread_id); | 466 static ThreadWatcher* Find(const content::BrowserThread::ID& thread_id); |
| 466 | 467 |
| 468 // Sets |g_stopped_| on the WatchDogThread. This is necessary to reflect the |
| 469 // state between the delayed |StartWatchingAll| and the immediate |
| 470 // |StopWatchingAll|. |
| 471 static void SetStopped(bool stopped); |
| 472 |
| 467 // The singleton of this class and is used to keep track of information about | 473 // The singleton of this class and is used to keep track of information about |
| 468 // threads that are being watched. | 474 // threads that are being watched. |
| 469 static ThreadWatcherList* g_thread_watcher_list_; | 475 static ThreadWatcherList* g_thread_watcher_list_; |
| 470 | 476 |
| 477 // StartWatchingAll() is delayed in relation to StopWatchingAll(), so if |
| 478 // a Stop comes first, prevent further initialization. |
| 479 static bool g_stopped_; |
| 480 |
| 471 // This is the wait time between ping messages. | 481 // This is the wait time between ping messages. |
| 472 static const int kSleepSeconds; | 482 static const int kSleepSeconds; |
| 473 | 483 |
| 474 // This is the wait time after ping message is sent, to check if we have | 484 // This is the wait time after ping message is sent, to check if we have |
| 475 // received pong message or not. | 485 // received pong message or not. |
| 476 static const int kUnresponsiveSeconds; | 486 static const int kUnresponsiveSeconds; |
| 477 | 487 |
| 478 // Default values for |unresponsive_threshold|. | 488 // Default values for |unresponsive_threshold|. |
| 479 static const int kUnresponsiveCount; | 489 static const int kUnresponsiveCount; |
| 480 | 490 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 // shutdown_watchdog_ watches for hangs during shutdown. | 640 // shutdown_watchdog_ watches for hangs during shutdown. |
| 631 base::Watchdog* shutdown_watchdog_; | 641 base::Watchdog* shutdown_watchdog_; |
| 632 | 642 |
| 633 // The |thread_id_| on which this object is constructed. | 643 // The |thread_id_| on which this object is constructed. |
| 634 const base::PlatformThreadId thread_id_; | 644 const base::PlatformThreadId thread_id_; |
| 635 | 645 |
| 636 DISALLOW_COPY_AND_ASSIGN(ShutdownWatcherHelper); | 646 DISALLOW_COPY_AND_ASSIGN(ShutdownWatcherHelper); |
| 637 }; | 647 }; |
| 638 | 648 |
| 639 #endif // CHROME_BROWSER_METRICS_THREAD_WATCHER_H_ | 649 #endif // CHROME_BROWSER_METRICS_THREAD_WATCHER_H_ |
| OLD | NEW |