| 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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 // Destructor of |g_thread_watcher_observer_| singleton. | 522 // Destructor of |g_thread_watcher_observer_| singleton. |
| 523 virtual ~ThreadWatcherObserver(); | 523 virtual ~ThreadWatcherObserver(); |
| 524 | 524 |
| 525 // This ensures all thread watchers are active because there is some user | 525 // This ensures all thread watchers are active because there is some user |
| 526 // activity. It will wake up all thread watchers every |wakeup_interval_| | 526 // activity. It will wake up all thread watchers every |wakeup_interval_| |
| 527 // seconds. This is the implementation of content::NotificationObserver. When | 527 // seconds. This is the implementation of content::NotificationObserver. When |
| 528 // a matching notification is posted to the notification service, this method | 528 // a matching notification is posted to the notification service, this method |
| 529 // is called. | 529 // is called. |
| 530 virtual void Observe(int type, | 530 virtual void Observe(int type, |
| 531 const content::NotificationSource& source, | 531 const content::NotificationSource& source, |
| 532 const content::NotificationDetails& details) OVERRIDE; | 532 const content::NotificationDetails& details) override; |
| 533 | 533 |
| 534 // The singleton of this class. | 534 // The singleton of this class. |
| 535 static ThreadWatcherObserver* g_thread_watcher_observer_; | 535 static ThreadWatcherObserver* g_thread_watcher_observer_; |
| 536 | 536 |
| 537 // The registrar that holds ints to be observed. | 537 // The registrar that holds ints to be observed. |
| 538 content::NotificationRegistrar registrar_; | 538 content::NotificationRegistrar registrar_; |
| 539 | 539 |
| 540 // This is the last time when woke all thread watchers up. | 540 // This is the last time when woke all thread watchers up. |
| 541 base::TimeTicks last_wakeup_time_; | 541 base::TimeTicks last_wakeup_time_; |
| 542 | 542 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 565 // They return true iff the watchdog thread existed and the task was posted. | 565 // They return true iff the watchdog thread existed and the task was posted. |
| 566 // Note that even if the task is posted, there's no guarantee that it will | 566 // Note that even if the task is posted, there's no guarantee that it will |
| 567 // run, since the target thread may already have a Quit message in its queue. | 567 // run, since the target thread may already have a Quit message in its queue. |
| 568 static bool PostTask(const tracked_objects::Location& from_here, | 568 static bool PostTask(const tracked_objects::Location& from_here, |
| 569 const base::Closure& task); | 569 const base::Closure& task); |
| 570 static bool PostDelayedTask(const tracked_objects::Location& from_here, | 570 static bool PostDelayedTask(const tracked_objects::Location& from_here, |
| 571 const base::Closure& task, | 571 const base::Closure& task, |
| 572 base::TimeDelta delay); | 572 base::TimeDelta delay); |
| 573 | 573 |
| 574 protected: | 574 protected: |
| 575 virtual void Init() OVERRIDE; | 575 virtual void Init() override; |
| 576 virtual void CleanUp() OVERRIDE; | 576 virtual void CleanUp() override; |
| 577 | 577 |
| 578 private: | 578 private: |
| 579 static bool PostTaskHelper( | 579 static bool PostTaskHelper( |
| 580 const tracked_objects::Location& from_here, | 580 const tracked_objects::Location& from_here, |
| 581 const base::Closure& task, | 581 const base::Closure& task, |
| 582 base::TimeDelta delay); | 582 base::TimeDelta delay); |
| 583 | 583 |
| 584 DISALLOW_COPY_AND_ASSIGN(WatchDogThread); | 584 DISALLOW_COPY_AND_ASSIGN(WatchDogThread); |
| 585 }; | 585 }; |
| 586 | 586 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 // shutdown_watchdog_ watches for hangs during shutdown. | 641 // shutdown_watchdog_ watches for hangs during shutdown. |
| 642 base::Watchdog* shutdown_watchdog_; | 642 base::Watchdog* shutdown_watchdog_; |
| 643 | 643 |
| 644 // The |thread_id_| on which this object is constructed. | 644 // The |thread_id_| on which this object is constructed. |
| 645 const base::PlatformThreadId thread_id_; | 645 const base::PlatformThreadId thread_id_; |
| 646 | 646 |
| 647 DISALLOW_COPY_AND_ASSIGN(ShutdownWatcherHelper); | 647 DISALLOW_COPY_AND_ASSIGN(ShutdownWatcherHelper); |
| 648 }; | 648 }; |
| 649 | 649 |
| 650 #endif // CHROME_BROWSER_METRICS_THREAD_WATCHER_H_ | 650 #endif // CHROME_BROWSER_METRICS_THREAD_WATCHER_H_ |
| OLD | NEW |