| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 #include <string> | 46 #include <string> |
| 47 #include <vector> | 47 #include <vector> |
| 48 | 48 |
| 49 #include "base/basictypes.h" | 49 #include "base/basictypes.h" |
| 50 #include "base/command_line.h" | 50 #include "base/command_line.h" |
| 51 #include "base/gtest_prod_util.h" | 51 #include "base/gtest_prod_util.h" |
| 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/synchronization/lock.h" | 57 #include "base/synchronization/lock.h" |
| 57 #include "base/threading/platform_thread.h" | 58 #include "base/threading/platform_thread.h" |
| 58 #include "base/threading/thread.h" | 59 #include "base/threading/thread.h" |
| 59 #include "base/threading/watchdog.h" | 60 #include "base/threading/watchdog.h" |
| 60 #include "base/time/time.h" | 61 #include "base/time/time.h" |
| 61 #include "content/public/browser/browser_thread.h" | 62 #include "content/public/browser/browser_thread.h" |
| 62 #include "content/public/browser/notification_observer.h" | 63 #include "content/public/browser/notification_observer.h" |
| 63 #include "content/public/browser/notification_registrar.h" | 64 #include "content/public/browser/notification_registrar.h" |
| 64 | 65 |
| 65 class CustomThreadWatcher; | 66 class CustomThreadWatcher; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 bool IsVeryUnresponsive(); | 213 bool IsVeryUnresponsive(); |
| 213 | 214 |
| 214 // The |thread_id_| of the thread being watched. Only one instance can exist | 215 // The |thread_id_| of the thread being watched. Only one instance can exist |
| 215 // for the given |thread_id_| of the thread being watched. | 216 // for the given |thread_id_| of the thread being watched. |
| 216 const content::BrowserThread::ID thread_id_; | 217 const content::BrowserThread::ID thread_id_; |
| 217 | 218 |
| 218 // The name of the thread being watched. | 219 // The name of the thread being watched. |
| 219 const std::string thread_name_; | 220 const std::string thread_name_; |
| 220 | 221 |
| 221 // Used to post messages to watched thread. | 222 // Used to post messages to watched thread. |
| 222 scoped_refptr<base::MessageLoopProxy> watched_loop_; | 223 scoped_refptr<base::SingleThreadTaskRunner> watched_runner_; |
| 223 | 224 |
| 224 // It is the sleep time between the receipt of a pong message back, and the | 225 // It is the sleep time between the receipt of a pong message back, and the |
| 225 // sending of another ping message. | 226 // sending of another ping message. |
| 226 const base::TimeDelta sleep_time_; | 227 const base::TimeDelta sleep_time_; |
| 227 | 228 |
| 228 // It is the duration from sending a ping message, until we check status to be | 229 // It is the duration from sending a ping message, until we check status to be |
| 229 // sure a pong message has been returned. | 230 // sure a pong message has been returned. |
| 230 const base::TimeDelta unresponsive_time_; | 231 const base::TimeDelta unresponsive_time_; |
| 231 | 232 |
| 232 // This is the last time when ping message was sent. | 233 // This is the last time when ping message was sent. |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 // shutdown_watchdog_ watches for hangs during shutdown. | 642 // shutdown_watchdog_ watches for hangs during shutdown. |
| 642 base::Watchdog* shutdown_watchdog_; | 643 base::Watchdog* shutdown_watchdog_; |
| 643 | 644 |
| 644 // The |thread_id_| on which this object is constructed. | 645 // The |thread_id_| on which this object is constructed. |
| 645 const base::PlatformThreadId thread_id_; | 646 const base::PlatformThreadId thread_id_; |
| 646 | 647 |
| 647 DISALLOW_COPY_AND_ASSIGN(ShutdownWatcherHelper); | 648 DISALLOW_COPY_AND_ASSIGN(ShutdownWatcherHelper); |
| 648 }; | 649 }; |
| 649 | 650 |
| 650 #endif // CHROME_BROWSER_METRICS_THREAD_WATCHER_H_ | 651 #endif // CHROME_BROWSER_METRICS_THREAD_WATCHER_H_ |
| OLD | NEW |