| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 #include "base/memory/ref_counted.h" | 52 #include "base/memory/ref_counted.h" |
| 53 #include "base/memory/weak_ptr.h" | 53 #include "base/memory/weak_ptr.h" |
| 54 #include "base/message_loop/message_loop.h" | 54 #include "base/message_loop/message_loop.h" |
| 55 #include "base/metrics/histogram.h" | 55 #include "base/metrics/histogram.h" |
| 56 #include "base/single_thread_task_runner.h" | 56 #include "base/single_thread_task_runner.h" |
| 57 #include "base/synchronization/lock.h" | 57 #include "base/synchronization/lock.h" |
| 58 #include "base/threading/platform_thread.h" | 58 #include "base/threading/platform_thread.h" |
| 59 #include "base/threading/thread.h" | 59 #include "base/threading/thread.h" |
| 60 #include "base/threading/watchdog.h" | 60 #include "base/threading/watchdog.h" |
| 61 #include "base/time/time.h" | 61 #include "base/time/time.h" |
| 62 #include "components/omnibox/browser/omnibox_event_global_tracker.h" |
| 62 #include "content/public/browser/browser_thread.h" | 63 #include "content/public/browser/browser_thread.h" |
| 63 #include "content/public/browser/notification_observer.h" | 64 #include "content/public/browser/notification_observer.h" |
| 64 #include "content/public/browser/notification_registrar.h" | 65 #include "content/public/browser/notification_registrar.h" |
| 65 | 66 |
| 66 class CustomThreadWatcher; | 67 class CustomThreadWatcher; |
| 67 class StartupTimeBomb; | 68 class StartupTimeBomb; |
| 68 class ThreadWatcherList; | 69 class ThreadWatcherList; |
| 69 class ThreadWatcherObserver; | 70 class ThreadWatcherObserver; |
| 70 | 71 |
| 71 // This class performs health check on threads that would like to be watched. | 72 // This class performs health check on threads that would like to be watched. |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 | 526 |
| 526 // This ensures all thread watchers are active because there is some user | 527 // This ensures all thread watchers are active because there is some user |
| 527 // activity. It will wake up all thread watchers every |wakeup_interval_| | 528 // activity. It will wake up all thread watchers every |wakeup_interval_| |
| 528 // seconds. This is the implementation of content::NotificationObserver. When | 529 // seconds. This is the implementation of content::NotificationObserver. When |
| 529 // a matching notification is posted to the notification service, this method | 530 // a matching notification is posted to the notification service, this method |
| 530 // is called. | 531 // is called. |
| 531 void Observe(int type, | 532 void Observe(int type, |
| 532 const content::NotificationSource& source, | 533 const content::NotificationSource& source, |
| 533 const content::NotificationDetails& details) override; | 534 const content::NotificationDetails& details) override; |
| 534 | 535 |
| 536 // Called when a URL is opened from the Omnibox. |
| 537 void OnURLOpenedFromOmnibox(OmniboxLog* log); |
| 538 |
| 539 // Called when user activity is detected. |
| 540 void OnUserActivityDetected(); |
| 541 |
| 535 // The singleton of this class. | 542 // The singleton of this class. |
| 536 static ThreadWatcherObserver* g_thread_watcher_observer_; | 543 static ThreadWatcherObserver* g_thread_watcher_observer_; |
| 537 | 544 |
| 538 // The registrar that holds ints to be observed. | 545 // The registrar that holds ints to be observed. |
| 539 content::NotificationRegistrar registrar_; | 546 content::NotificationRegistrar registrar_; |
| 540 | 547 |
| 541 // This is the last time when woke all thread watchers up. | 548 // This is the last time when woke all thread watchers up. |
| 542 base::TimeTicks last_wakeup_time_; | 549 base::TimeTicks last_wakeup_time_; |
| 543 | 550 |
| 544 // It is the time interval between wake up calls to thread watchers. | 551 // It is the time interval between wake up calls to thread watchers. |
| 545 const base::TimeDelta wakeup_interval_; | 552 const base::TimeDelta wakeup_interval_; |
| 546 | 553 |
| 554 // Subscription for receiving callbacks that a URL was opened from the |
| 555 // omnibox. |
| 556 scoped_ptr<base::CallbackList<void(OmniboxLog*)>::Subscription> |
| 557 omnibox_url_opened_subscription_; |
| 558 |
| 547 DISALLOW_COPY_AND_ASSIGN(ThreadWatcherObserver); | 559 DISALLOW_COPY_AND_ASSIGN(ThreadWatcherObserver); |
| 548 }; | 560 }; |
| 549 | 561 |
| 550 // Class for WatchDogThread and in its Init method, we start watching UI, IO, | 562 // Class for WatchDogThread and in its Init method, we start watching UI, IO, |
| 551 // DB, FILE, CACHED threads. | 563 // DB, FILE, CACHED threads. |
| 552 class WatchDogThread : public base::Thread { | 564 class WatchDogThread : public base::Thread { |
| 553 public: | 565 public: |
| 554 // Constructor. | 566 // Constructor. |
| 555 WatchDogThread(); | 567 WatchDogThread(); |
| 556 | 568 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 // shutdown_watchdog_ watches for hangs during shutdown. | 654 // shutdown_watchdog_ watches for hangs during shutdown. |
| 643 base::Watchdog* shutdown_watchdog_; | 655 base::Watchdog* shutdown_watchdog_; |
| 644 | 656 |
| 645 // The |thread_id_| on which this object is constructed. | 657 // The |thread_id_| on which this object is constructed. |
| 646 const base::PlatformThreadId thread_id_; | 658 const base::PlatformThreadId thread_id_; |
| 647 | 659 |
| 648 DISALLOW_COPY_AND_ASSIGN(ShutdownWatcherHelper); | 660 DISALLOW_COPY_AND_ASSIGN(ShutdownWatcherHelper); |
| 649 }; | 661 }; |
| 650 | 662 |
| 651 #endif // CHROME_BROWSER_METRICS_THREAD_WATCHER_H_ | 663 #endif // CHROME_BROWSER_METRICS_THREAD_WATCHER_H_ |
| OLD | NEW |