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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 // Destructor of |g_thread_watcher_observer_| singleton. | 427 // Destructor of |g_thread_watcher_observer_| singleton. |
428 virtual ~ThreadWatcherObserver(); | 428 virtual ~ThreadWatcherObserver(); |
429 | 429 |
430 // This ensures all thread watchers are active because there is some user | 430 // This ensures all thread watchers are active because there is some user |
431 // activity. It will wake up all thread watchers every |wakeup_interval_| | 431 // activity. It will wake up all thread watchers every |wakeup_interval_| |
432 // seconds. This is the implementation of content::NotificationObserver. When | 432 // seconds. This is the implementation of content::NotificationObserver. When |
433 // a matching notification is posted to the notification service, this method | 433 // a matching notification is posted to the notification service, this method |
434 // is called. | 434 // is called. |
435 virtual void Observe(int type, | 435 virtual void Observe(int type, |
436 const content::NotificationSource& source, | 436 const content::NotificationSource& source, |
437 const content::NotificationDetails& details); | 437 const content::NotificationDetails& details) OVERRIDE; |
438 | 438 |
439 // The singleton of this class. | 439 // The singleton of this class. |
440 static ThreadWatcherObserver* g_thread_watcher_observer_; | 440 static ThreadWatcherObserver* g_thread_watcher_observer_; |
441 | 441 |
442 // The registrar that holds ints to be observed. | 442 // The registrar that holds ints to be observed. |
443 content::NotificationRegistrar registrar_; | 443 content::NotificationRegistrar registrar_; |
444 | 444 |
445 // This is the last time when woke all thread watchers up. | 445 // This is the last time when woke all thread watchers up. |
446 base::TimeTicks last_wakeup_time_; | 446 base::TimeTicks last_wakeup_time_; |
447 | 447 |
(...skipping 22 matching lines...) Expand all Loading... |
470 // They return true iff the watchdog thread existed and the task was posted. | 470 // They return true iff the watchdog thread existed and the task was posted. |
471 // Note that even if the task is posted, there's no guarantee that it will | 471 // Note that even if the task is posted, there's no guarantee that it will |
472 // run, since the target thread may already have a Quit message in its queue. | 472 // run, since the target thread may already have a Quit message in its queue. |
473 static bool PostTask(const tracked_objects::Location& from_here, | 473 static bool PostTask(const tracked_objects::Location& from_here, |
474 const base::Closure& task); | 474 const base::Closure& task); |
475 static bool PostDelayedTask(const tracked_objects::Location& from_here, | 475 static bool PostDelayedTask(const tracked_objects::Location& from_here, |
476 const base::Closure& task, | 476 const base::Closure& task, |
477 int64 delay_ms); | 477 int64 delay_ms); |
478 | 478 |
479 protected: | 479 protected: |
480 virtual void Init(); | 480 virtual void Init() OVERRIDE; |
481 virtual void CleanUp(); | 481 virtual void CleanUp() OVERRIDE; |
482 | 482 |
483 private: | 483 private: |
484 static bool PostTaskHelper( | 484 static bool PostTaskHelper( |
485 const tracked_objects::Location& from_here, | 485 const tracked_objects::Location& from_here, |
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 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 | 528 |
529 DISALLOW_COPY_AND_ASSIGN(ShutdownWatcherHelper); | 529 DISALLOW_COPY_AND_ASSIGN(ShutdownWatcherHelper); |
530 }; | 530 }; |
531 | 531 |
532 // DISABLE_RUNNABLE_METHOD_REFCOUNT is a convenience macro for disabling | 532 // DISABLE_RUNNABLE_METHOD_REFCOUNT is a convenience macro for disabling |
533 // refcounting of ThreadWatcher and ThreadWatcherList classes. | 533 // refcounting of ThreadWatcher and ThreadWatcherList classes. |
534 DISABLE_RUNNABLE_METHOD_REFCOUNT(ThreadWatcher); | 534 DISABLE_RUNNABLE_METHOD_REFCOUNT(ThreadWatcher); |
535 DISABLE_RUNNABLE_METHOD_REFCOUNT(ThreadWatcherList); | 535 DISABLE_RUNNABLE_METHOD_REFCOUNT(ThreadWatcherList); |
536 | 536 |
537 #endif // CHROME_BROWSER_METRICS_THREAD_WATCHER_H_ | 537 #endif // CHROME_BROWSER_METRICS_THREAD_WATCHER_H_ |
OLD | NEW |