Index: chrome/browser/metrics/thread_watcher.h |
=================================================================== |
--- chrome/browser/metrics/thread_watcher.h (revision 88502) |
+++ chrome/browser/metrics/thread_watcher.h (working copy) |
@@ -32,10 +32,12 @@ |
#define CHROME_BROWSER_METRICS_THREAD_WATCHER_H_ |
#include <map> |
+#include <set> |
#include <string> |
#include <vector> |
#include "base/basictypes.h" |
+#include "base/command_line.h" |
#include "base/gtest_prod_util.h" |
#include "base/memory/ref_counted.h" |
#include "base/memory/scoped_ptr.h" |
@@ -158,16 +160,13 @@ |
// It increments unresponsive_count_ by 1. |
void GotNoResponse(); |
+ // Helper method to get |unresponsive_count_|. |
+ uint32 unresponsive_count() const { return unresponsive_count_; } |
+ |
// This is the number of ping messages to be sent when the user is idle. |
// ping_count_ will be initialized to kPingCount whenever user becomes active. |
static const int kPingCount; |
- // This value is used to determine if the watched thread is responsive or not. |
- // If unresponsive_count_ is less than kUnresponsiveCount then watched thread |
- // is considered as responsive (in responsive_count_histogram_) otherwise it |
- // is considered as unresponsive (in unresponsive_count_histogram_). |
- static const int kUnresponsiveCount; |
- |
// The thread_id of the thread being watched. Only one instance can exist for |
// the given thread_id of the thread being watched. |
const BrowserThread::ID thread_id_; |
@@ -223,7 +222,7 @@ |
// is zero then watched thread has responded with a pong message. This is |
// incremented by 1 when we got no response (GotNoResponse) from the watched |
// thread. |
- int unresponsive_count_; |
+ uint32 unresponsive_count_; |
// This is set to true when we would have crashed the browser because the |
// watched thread hasn't responded atleast 6 times. It is reset to false when |
@@ -248,7 +247,7 @@ |
typedef std::map<BrowserThread::ID, ThreadWatcher*> RegistrationList; |
// This singleton holds the global list of registered ThreadWatchers. |
- ThreadWatcherList(); |
+ explicit ThreadWatcherList(const CommandLine& command_line); |
// Destructor deletes all registered ThreadWatcher instances. |
virtual ~ThreadWatcherList(); |
@@ -273,8 +272,19 @@ |
// This method is accessible on UI thread. |
static void RemoveNotifications(); |
+ // Returns true if watched thread's |unresponsive_count_| is less than |
+ // |crash_on_unresponsive_count_|. A watched thread is considered as |
+ // unresponsive if it has not responded with a pong message for |
+ // |crash_on_unresponsive_count_| number of ping messages. |
+ static bool IsResponsive(ThreadWatcher* watcher); |
+ |
+ // Returns true if the watched thread is not responsive and is listed |
+ // as one of the threads in "--crash-on-hang-threads" command line switch. |
+ static bool CrashOnHang(ThreadWatcher* watcher); |
+ |
// This method returns number of watched threads that have responded and |
- // threads that have not responded with a pong message. |
+ // threads that have not responded with a pong message for |
+ // |crash_on_unresponsive_count_| number of ping messages. |
static void GetStatusOfThreads(int* no_of_responding_threads, |
int* no_of_unresponding_threads); |
@@ -316,6 +326,11 @@ |
// received pong message or not. |
static const int kUnresponsiveSeconds; |
+ // This is used to initialize |crash_on_unresponsive_count_|. |
+ // |crash_on_unresponsive_count_| is used to determine if the watched thread |
+ // is responsive or not. |
jar (doing other things)
2011/06/10 00:38:33
nit: Don't bother explaining the variable... since
ramant (doing other things)
2011/06/13 03:26:02
Done.
|
+ static const int kUnresponsiveCount; |
+ |
// Lock for access to registered_. |
base::Lock lock_; |
@@ -328,6 +343,19 @@ |
// This is the last time when woke all thread watchers up. |
base::TimeTicks last_wakeup_time_; |
+ // This is used to determine if the watched thread is responsive or not. If |
+ // watched thread's |unresponsive_count_| is greater than or equal to |
+ // |crash_on_unresponsive_count_| then we could crash the browser if the |
+ // watched thread is listed in the "--crash-on-hang-threads" command line |
+ // switch. It is initialized with |kUnresponsiveCount|, but can be overwritten |
+ // by the command line switch "--crash-on-hang-seconds". |
+ uint32 crash_on_unresponsive_count_; |
+ |
+ // This is the set of watched thread's names that are to be crashed if they |
+ // have not responded with a pong message for |crash_on_unresponsive_count_| |
+ // number of ping messages. |
+ std::set<std::string> crash_on_hang_thread_names_; |
+ |
DISALLOW_COPY_AND_ASSIGN(ThreadWatcherList); |
}; |