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