Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: chrome/browser/metrics/thread_watcher.h

Issue 1550593002: Switch to standard integer types in chrome/browser/, part 2 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 14 matching lines...) Expand all
25 // |unresponsive_threshold| specifies the number of unanswered ping messages 25 // |unresponsive_threshold| specifies the number of unanswered ping messages
26 // after which watched (IO) thread is considered as not responsive. 26 // after which watched (IO) thread is considered as not responsive.
27 // |crash_on_hang| specifies if we want to crash the browser when the watched 27 // |crash_on_hang| specifies if we want to crash the browser when the watched
28 // (IO) thread has become sufficiently unresponsive, while other threads are 28 // (IO) thread has become sufficiently unresponsive, while other threads are
29 // sufficiently responsive. |live_threads_threshold| specifies the number of 29 // sufficiently responsive. |live_threads_threshold| specifies the number of
30 // browser threads that are to be responsive when we want to crash the browser 30 // browser threads that are to be responsive when we want to crash the browser
31 // because of hung watched (IO) thread. 31 // because of hung watched (IO) thread.
32 // 32 //
33 // base::TimeDelta sleep_time = base::TimeDelta::FromSeconds(5); 33 // base::TimeDelta sleep_time = base::TimeDelta::FromSeconds(5);
34 // base::TimeDelta unresponsive_time = base::TimeDelta::FromSeconds(10); 34 // base::TimeDelta unresponsive_time = base::TimeDelta::FromSeconds(10);
35 // uint32 unresponsive_threshold = ThreadWatcherList::kUnresponsiveCount; 35 // uint32_t unresponsive_threshold = ThreadWatcherList::kUnresponsiveCount;
36 // bool crash_on_hang = false; 36 // bool crash_on_hang = false;
37 // uint32 live_threads_threshold = ThreadWatcherList::kLiveThreadsThreshold; 37 // uint32_t live_threads_threshold = ThreadWatcherList::kLiveThreadsThreshold;
38 // ThreadWatcher::StartWatching( 38 // ThreadWatcher::StartWatching(
39 // BrowserThread::IO, "IO", sleep_time, unresponsive_time, 39 // BrowserThread::IO, "IO", sleep_time, unresponsive_time,
40 // unresponsive_threshold, crash_on_hang, live_threads_threshold); 40 // unresponsive_threshold, crash_on_hang, live_threads_threshold);
41 41
42 #ifndef CHROME_BROWSER_METRICS_THREAD_WATCHER_H_ 42 #ifndef CHROME_BROWSER_METRICS_THREAD_WATCHER_H_
43 #define CHROME_BROWSER_METRICS_THREAD_WATCHER_H_ 43 #define CHROME_BROWSER_METRICS_THREAD_WATCHER_H_
44 44
45 #include <map> 45 #include <map>
46 #include <string> 46 #include <string>
47 #include <vector> 47 #include <vector>
48 48
49 #include "base/basictypes.h" 49 #include <stdint.h>
50
50 #include "base/command_line.h" 51 #include "base/command_line.h"
51 #include "base/gtest_prod_util.h" 52 #include "base/gtest_prod_util.h"
53 #include "base/macros.h"
52 #include "base/memory/ref_counted.h" 54 #include "base/memory/ref_counted.h"
53 #include "base/memory/weak_ptr.h" 55 #include "base/memory/weak_ptr.h"
54 #include "base/message_loop/message_loop.h" 56 #include "base/message_loop/message_loop.h"
55 #include "base/metrics/histogram.h" 57 #include "base/metrics/histogram.h"
56 #include "base/profiler/stack_sampling_profiler.h" 58 #include "base/profiler/stack_sampling_profiler.h"
57 #include "base/single_thread_task_runner.h" 59 #include "base/single_thread_task_runner.h"
58 #include "base/synchronization/lock.h" 60 #include "base/synchronization/lock.h"
59 #include "base/threading/platform_thread.h" 61 #include "base/threading/platform_thread.h"
60 #include "base/threading/thread.h" 62 #include "base/threading/thread.h"
61 #include "base/threading/watchdog.h" 63 #include "base/threading/watchdog.h"
(...skipping 11 matching lines...) Expand all
73 // This class performs health check on threads that would like to be watched. 75 // This class performs health check on threads that would like to be watched.
74 class ThreadWatcher { 76 class ThreadWatcher {
75 public: 77 public:
76 // base::Bind supports methods with up to 6 parameters. WatchingParams is used 78 // base::Bind supports methods with up to 6 parameters. WatchingParams is used
77 // as a workaround that limitation for invoking ThreadWatcher::StartWatching. 79 // as a workaround that limitation for invoking ThreadWatcher::StartWatching.
78 struct WatchingParams { 80 struct WatchingParams {
79 const content::BrowserThread::ID& thread_id; 81 const content::BrowserThread::ID& thread_id;
80 const std::string& thread_name; 82 const std::string& thread_name;
81 const base::TimeDelta& sleep_time; 83 const base::TimeDelta& sleep_time;
82 const base::TimeDelta& unresponsive_time; 84 const base::TimeDelta& unresponsive_time;
83 uint32 unresponsive_threshold; 85 uint32_t unresponsive_threshold;
84 bool crash_on_hang; 86 bool crash_on_hang;
85 uint32 live_threads_threshold; 87 uint32_t live_threads_threshold;
86 88
87 WatchingParams(const content::BrowserThread::ID& thread_id_in, 89 WatchingParams(const content::BrowserThread::ID& thread_id_in,
88 const std::string& thread_name_in, 90 const std::string& thread_name_in,
89 const base::TimeDelta& sleep_time_in, 91 const base::TimeDelta& sleep_time_in,
90 const base::TimeDelta& unresponsive_time_in, 92 const base::TimeDelta& unresponsive_time_in,
91 uint32 unresponsive_threshold_in, 93 uint32_t unresponsive_threshold_in,
92 bool crash_on_hang_in, 94 bool crash_on_hang_in,
93 uint32 live_threads_threshold_in) 95 uint32_t live_threads_threshold_in)
94 : thread_id(thread_id_in), 96 : thread_id(thread_id_in),
95 thread_name(thread_name_in), 97 thread_name(thread_name_in),
96 sleep_time(sleep_time_in), 98 sleep_time(sleep_time_in),
97 unresponsive_time(unresponsive_time_in), 99 unresponsive_time(unresponsive_time_in),
98 unresponsive_threshold(unresponsive_threshold_in), 100 unresponsive_threshold(unresponsive_threshold_in),
99 crash_on_hang(crash_on_hang_in), 101 crash_on_hang(crash_on_hang_in),
100 live_threads_threshold(live_threads_threshold_in) { 102 live_threads_threshold(live_threads_threshold_in) {}
101 }
102 }; 103 };
103 104
104 // This method starts performing health check on the given |thread_id|. It 105 // This method starts performing health check on the given |thread_id|. It
105 // will create ThreadWatcher object for the given |thread_id|, |thread_name|. 106 // will create ThreadWatcher object for the given |thread_id|, |thread_name|.
106 // |sleep_time| is the wait time between ping messages. |unresponsive_time| is 107 // |sleep_time| is the wait time between ping messages. |unresponsive_time| is
107 // the wait time after ping message is sent, to check if we have received pong 108 // the wait time after ping message is sent, to check if we have received pong
108 // message or not. |unresponsive_threshold| is used to determine if the thread 109 // message or not. |unresponsive_threshold| is used to determine if the thread
109 // is responsive or not. The watched thread is considered unresponsive if it 110 // is responsive or not. The watched thread is considered unresponsive if it
110 // hasn't responded with a pong message for |unresponsive_threshold| number of 111 // hasn't responded with a pong message for |unresponsive_threshold| number of
111 // ping messages. |crash_on_hang| specifies if browser should be crashed when 112 // ping messages. |crash_on_hang| specifies if browser should be crashed when
(...skipping 16 matching lines...) Expand all
128 // Return the the wait time to check the responsiveness of the thread. 129 // Return the the wait time to check the responsiveness of the thread.
129 base::TimeDelta unresponsive_time() const { return unresponsive_time_; } 130 base::TimeDelta unresponsive_time() const { return unresponsive_time_; }
130 131
131 // Returns true if we are montioring the thread. 132 // Returns true if we are montioring the thread.
132 bool active() const { return active_; } 133 bool active() const { return active_; }
133 134
134 // Returns |ping_time_| (used by unit tests). 135 // Returns |ping_time_| (used by unit tests).
135 base::TimeTicks ping_time() const { return ping_time_; } 136 base::TimeTicks ping_time() const { return ping_time_; }
136 137
137 // Returns |ping_sequence_number_| (used by unit tests). 138 // Returns |ping_sequence_number_| (used by unit tests).
138 uint64 ping_sequence_number() const { return ping_sequence_number_; } 139 uint64_t ping_sequence_number() const { return ping_sequence_number_; }
139 140
140 protected: 141 protected:
141 // Construct a ThreadWatcher for the given |thread_id|. |sleep_time| is the 142 // Construct a ThreadWatcher for the given |thread_id|. |sleep_time| is the
142 // wait time between ping messages. |unresponsive_time| is the wait time after 143 // wait time between ping messages. |unresponsive_time| is the wait time after
143 // ping message is sent, to check if we have received pong message or not. 144 // ping message is sent, to check if we have received pong message or not.
144 explicit ThreadWatcher(const WatchingParams& params); 145 explicit ThreadWatcher(const WatchingParams& params);
145 146
146 virtual ~ThreadWatcher(); 147 virtual ~ThreadWatcher();
147 148
148 // This method activates the thread watching which starts ping/pong messaging. 149 // This method activates the thread watching which starts ping/pong messaging.
(...skipping 14 matching lines...) Expand all
163 // responsiveness of monitored thread that would be called after waiting 164 // responsiveness of monitored thread that would be called after waiting
164 // |unresponsive_time_|. 165 // |unresponsive_time_|.
165 // This method is accessible on WatchDogThread. 166 // This method is accessible on WatchDogThread.
166 virtual void PostPingMessage(); 167 virtual void PostPingMessage();
167 168
168 // This method handles a Pong Message from watched thread. It will track the 169 // This method handles a Pong Message from watched thread. It will track the
169 // response time (pong time minus ping time) via histograms. It posts a 170 // response time (pong time minus ping time) via histograms. It posts a
170 // PostPingMessage() task that would be called after waiting |sleep_time_|. It 171 // PostPingMessage() task that would be called after waiting |sleep_time_|. It
171 // increments |ping_sequence_number_| by 1. 172 // increments |ping_sequence_number_| by 1.
172 // This method is accessible on WatchDogThread. 173 // This method is accessible on WatchDogThread.
173 virtual void OnPongMessage(uint64 ping_sequence_number); 174 virtual void OnPongMessage(uint64_t ping_sequence_number);
174 175
175 // This method will determine if the watched thread is responsive or not. If 176 // This method will determine if the watched thread is responsive or not. If
176 // the latest |ping_sequence_number_| is not same as the 177 // the latest |ping_sequence_number_| is not same as the
177 // |ping_sequence_number| that is passed in, then we can assume that watched 178 // |ping_sequence_number| that is passed in, then we can assume that watched
178 // thread has responded with a pong message. 179 // thread has responded with a pong message.
179 // This method is accessible on WatchDogThread. 180 // This method is accessible on WatchDogThread.
180 virtual void OnCheckResponsiveness(uint64 ping_sequence_number); 181 virtual void OnCheckResponsiveness(uint64_t ping_sequence_number);
181 182
182 // Set by OnCheckResponsiveness when it determines if the watched thread is 183 // Set by OnCheckResponsiveness when it determines if the watched thread is
183 // responsive or not. 184 // responsive or not.
184 bool responsive_; 185 bool responsive_;
185 186
186 private: 187 private:
187 friend class ThreadWatcherList; 188 friend class ThreadWatcherList;
188 friend class CustomThreadWatcher; 189 friend class CustomThreadWatcher;
189 190
190 // Allow tests to access our innards for testing purposes. 191 // Allow tests to access our innards for testing purposes.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 235
235 // This is the last time when ping message was sent. 236 // This is the last time when ping message was sent.
236 base::TimeTicks ping_time_; 237 base::TimeTicks ping_time_;
237 238
238 // This is the last time when we got pong message. 239 // This is the last time when we got pong message.
239 base::TimeTicks pong_time_; 240 base::TimeTicks pong_time_;
240 241
241 // This is the sequence number of the next ping for which there is no pong. If 242 // This is the sequence number of the next ping for which there is no pong. If
242 // the instance is sleeping, then it will be the sequence number for the next 243 // the instance is sleeping, then it will be the sequence number for the next
243 // ping. 244 // ping.
244 uint64 ping_sequence_number_; 245 uint64_t ping_sequence_number_;
245 246
246 // This is set to true if thread watcher is watching. 247 // This is set to true if thread watcher is watching.
247 bool active_; 248 bool active_;
248 249
249 // The counter tracks least number of ping messages that will be sent to 250 // The counter tracks least number of ping messages that will be sent to
250 // watched thread before the ping-pong mechanism will go into an extended 251 // watched thread before the ping-pong mechanism will go into an extended
251 // sleep. If this value is zero, then the mechanism is in an extended sleep, 252 // sleep. If this value is zero, then the mechanism is in an extended sleep,
252 // and awaiting some observed user action before continuing. 253 // and awaiting some observed user action before continuing.
253 int ping_count_; 254 int ping_count_;
254 255
(...skipping 10 matching lines...) Expand all
265 266
266 // Histogram that keeps track of how many threads are not responding when we 267 // Histogram that keeps track of how many threads are not responding when we
267 // got no response (GotNoResponse()) from the watched thread. Count includes 268 // got no response (GotNoResponse()) from the watched thread. Count includes
268 // the thread that got no response. 269 // the thread that got no response.
269 base::HistogramBase* unresponsive_count_histogram_; 270 base::HistogramBase* unresponsive_count_histogram_;
270 271
271 // This counter tracks the unresponsiveness of watched thread. If this value 272 // This counter tracks the unresponsiveness of watched thread. If this value
272 // is zero then watched thread has responded with a pong message. This is 273 // is zero then watched thread has responded with a pong message. This is
273 // incremented by 1 when we got no response (GotNoResponse()) from the watched 274 // incremented by 1 when we got no response (GotNoResponse()) from the watched
274 // thread. 275 // thread.
275 uint32 unresponsive_count_; 276 uint32_t unresponsive_count_;
276 277
277 // This is set to true when we would have crashed the browser because the 278 // This is set to true when we would have crashed the browser because the
278 // watched thread hasn't responded at least |unresponsive_threshold_| times. 279 // watched thread hasn't responded at least |unresponsive_threshold_| times.
279 // It is reset to false when watched thread responds with a pong message. 280 // It is reset to false when watched thread responds with a pong message.
280 bool hung_processing_complete_; 281 bool hung_processing_complete_;
281 282
282 // This is used to determine if the watched thread is responsive or not. If 283 // This is used to determine if the watched thread is responsive or not. If
283 // watched thread's |unresponsive_count_| is greater than or equal to 284 // watched thread's |unresponsive_count_| is greater than or equal to
284 // |unresponsive_threshold_| then we would consider it as unresponsive. 285 // |unresponsive_threshold_| then we would consider it as unresponsive.
285 uint32 unresponsive_threshold_; 286 uint32_t unresponsive_threshold_;
286 287
287 // This is set to true if we want to crash the browser when the watched thread 288 // This is set to true if we want to crash the browser when the watched thread
288 // has become sufficiently unresponsive, while other threads are sufficiently 289 // has become sufficiently unresponsive, while other threads are sufficiently
289 // responsive. 290 // responsive.
290 bool crash_on_hang_; 291 bool crash_on_hang_;
291 292
292 // This specifies the number of browser threads that are to be responsive when 293 // This specifies the number of browser threads that are to be responsive when
293 // we want to crash the browser because watched thread has become sufficiently 294 // we want to crash the browser because watched thread has become sufficiently
294 // unresponsive. 295 // unresponsive.
295 uint32 live_threads_threshold_; 296 uint32_t live_threads_threshold_;
296 297
297 // We use this factory to create callback tasks for ThreadWatcher object. We 298 // We use this factory to create callback tasks for ThreadWatcher object. We
298 // use this during ping-pong messaging between WatchDog thread and watched 299 // use this during ping-pong messaging between WatchDog thread and watched
299 // thread. 300 // thread.
300 base::WeakPtrFactory<ThreadWatcher> weak_ptr_factory_; 301 base::WeakPtrFactory<ThreadWatcher> weak_ptr_factory_;
301 302
302 DISALLOW_COPY_AND_ASSIGN(ThreadWatcher); 303 DISALLOW_COPY_AND_ASSIGN(ThreadWatcher);
303 }; 304 };
304 305
305 // Class with a list of all active thread watchers. A thread watcher is active 306 // Class with a list of all active thread watchers. A thread watcher is active
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 // |unresponsive_threshold| is 9), then we would always crash if the UI thread 366 // |unresponsive_threshold| is 9), then we would always crash if the UI thread
366 // was hung (9 unanswered ping messages), no matter what the other threads are 367 // was hung (9 unanswered ping messages), no matter what the other threads are
367 // doing. 368 // doing.
368 // Example 3: If the |live_threads_threshold| value of "FILE" was 5 and 369 // Example 3: If the |live_threads_threshold| value of "FILE" was 5 and
369 // unresponsive threshold seconds is 90 (or |unresponsive_threshold| is 45), 370 // unresponsive threshold seconds is 90 (or |unresponsive_threshold| is 45),
370 // then we would only crash if the FILE thread was the ONLY hung thread 371 // then we would only crash if the FILE thread was the ONLY hung thread
371 // (because we watch 6 threads). If there was another unresponsive thread, we 372 // (because we watch 6 threads). If there was another unresponsive thread, we
372 // would not consider this a problem worth crashing for. FILE thread would be 373 // would not consider this a problem worth crashing for. FILE thread would be
373 // considered as hung if it didn't respond for 45 ping messages. 374 // considered as hung if it didn't respond for 45 ping messages.
374 struct CrashDataThresholds { 375 struct CrashDataThresholds {
375 CrashDataThresholds(uint32 live_threads_threshold, 376 CrashDataThresholds(uint32_t live_threads_threshold,
376 uint32 unresponsive_threshold); 377 uint32_t unresponsive_threshold);
377 CrashDataThresholds(); 378 CrashDataThresholds();
378 379
379 uint32 live_threads_threshold; 380 uint32_t live_threads_threshold;
380 uint32 unresponsive_threshold; 381 uint32_t unresponsive_threshold;
381 }; 382 };
382 typedef std::map<std::string, CrashDataThresholds> CrashOnHangThreadMap; 383 typedef std::map<std::string, CrashDataThresholds> CrashOnHangThreadMap;
383 384
384 // This method posts a task on WatchDogThread to start watching all browser 385 // This method posts a task on WatchDogThread to start watching all browser
385 // threads. 386 // threads.
386 // This method is accessible on UI thread. 387 // This method is accessible on UI thread.
387 static void StartWatchingAll(const base::CommandLine& command_line); 388 static void StartWatchingAll(const base::CommandLine& command_line);
388 389
389 // This method posts a task on WatchDogThread to RevokeAll tasks and to 390 // This method posts a task on WatchDogThread to RevokeAll tasks and to
390 // deactive thread watching of other threads and tell NotificationService to 391 // deactive thread watching of other threads and tell NotificationService to
391 // stop calling Observe. 392 // stop calling Observe.
392 // This method is accessible on UI thread. 393 // This method is accessible on UI thread.
393 static void StopWatchingAll(); 394 static void StopWatchingAll();
394 395
395 // Register() stores a pointer to the given ThreadWatcher in a global map. 396 // Register() stores a pointer to the given ThreadWatcher in a global map.
396 static void Register(ThreadWatcher* watcher); 397 static void Register(ThreadWatcher* watcher);
397 398
398 // This method returns true if the ThreadWatcher object is registerd. 399 // This method returns true if the ThreadWatcher object is registerd.
399 static bool IsRegistered(const content::BrowserThread::ID thread_id); 400 static bool IsRegistered(const content::BrowserThread::ID thread_id);
400 401
401 // This method returns number of responsive and unresponsive watched threads. 402 // This method returns number of responsive and unresponsive watched threads.
402 static void GetStatusOfThreads(uint32* responding_thread_count, 403 static void GetStatusOfThreads(uint32_t* responding_thread_count,
403 uint32* unresponding_thread_count); 404 uint32_t* unresponding_thread_count);
404 405
405 // This will ensure that the watching is actively taking place, and awaken 406 // This will ensure that the watching is actively taking place, and awaken
406 // all thread watchers that are registered. 407 // all thread watchers that are registered.
407 static void WakeUpAll(); 408 static void WakeUpAll();
408 409
409 private: 410 private:
410 // Allow tests to access our innards for testing purposes. 411 // Allow tests to access our innards for testing purposes.
411 friend class CustomThreadWatcher; 412 friend class CustomThreadWatcher;
412 friend class ThreadWatcherListTest; 413 friend class ThreadWatcherListTest;
413 friend class ThreadWatcherTest; 414 friend class ThreadWatcherTest;
414 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherAndroidTest, 415 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherAndroidTest,
415 ApplicationStatusNotification); 416 ApplicationStatusNotification);
416 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherListTest, Restart); 417 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherListTest, Restart);
417 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherTest, ThreadNamesOnlyArgs); 418 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherTest, ThreadNamesOnlyArgs);
418 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherTest, ThreadNamesAndLiveThresholdArgs); 419 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherTest, ThreadNamesAndLiveThresholdArgs);
419 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherTest, CrashOnHangThreadsAllArgs); 420 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherTest, CrashOnHangThreadsAllArgs);
420 421
421 // This singleton holds the global list of registered ThreadWatchers. 422 // This singleton holds the global list of registered ThreadWatchers.
422 ThreadWatcherList(); 423 ThreadWatcherList();
423 424
424 // Destructor deletes all registered ThreadWatcher instances. 425 // Destructor deletes all registered ThreadWatcher instances.
425 virtual ~ThreadWatcherList(); 426 virtual ~ThreadWatcherList();
426 427
427 // Parses the command line to get |crash_on_hang_threads| map from 428 // Parses the command line to get |crash_on_hang_threads| map from
428 // switches::kCrashOnHangThreads. |crash_on_hang_threads| is a map of 429 // switches::kCrashOnHangThreads. |crash_on_hang_threads| is a map of
429 // |crash_on_hang| thread's names to |CrashDataThresholds|. 430 // |crash_on_hang| thread's names to |CrashDataThresholds|.
430 static void ParseCommandLine( 431 static void ParseCommandLine(const base::CommandLine& command_line,
431 const base::CommandLine& command_line, 432 uint32_t* unresponsive_threshold,
432 uint32* unresponsive_threshold, 433 CrashOnHangThreadMap* crash_on_hang_threads);
433 CrashOnHangThreadMap* crash_on_hang_threads);
434 434
435 // Parses the argument |crash_on_hang_thread_names| and creates 435 // Parses the argument |crash_on_hang_thread_names| and creates
436 // |crash_on_hang_threads| map of |crash_on_hang| thread's names to 436 // |crash_on_hang_threads| map of |crash_on_hang| thread's names to
437 // |CrashDataThresholds|. If |crash_on_hang_thread_names| doesn't specify 437 // |CrashDataThresholds|. If |crash_on_hang_thread_names| doesn't specify
438 // |live_threads_threshold|, then it uses |default_live_threads_threshold| as 438 // |live_threads_threshold|, then it uses |default_live_threads_threshold| as
439 // the value. If |crash_on_hang_thread_names| doesn't specify |crash_seconds|, 439 // the value. If |crash_on_hang_thread_names| doesn't specify |crash_seconds|,
440 // then it uses |default_crash_seconds| as the value. 440 // then it uses |default_crash_seconds| as the value.
441 static void ParseCommandLineCrashOnHangThreads( 441 static void ParseCommandLineCrashOnHangThreads(
442 const std::string& crash_on_hang_thread_names, 442 const std::string& crash_on_hang_thread_names,
443 uint32 default_live_threads_threshold, 443 uint32_t default_live_threads_threshold,
444 uint32 default_crash_seconds, 444 uint32_t default_crash_seconds,
445 CrashOnHangThreadMap* crash_on_hang_threads); 445 CrashOnHangThreadMap* crash_on_hang_threads);
446 446
447 // This constructs the |ThreadWatcherList| singleton and starts watching 447 // This constructs the |ThreadWatcherList| singleton and starts watching
448 // browser threads by calling StartWatching() on each browser thread that is 448 // browser threads by calling StartWatching() on each browser thread that is
449 // watched. It disarms StartupTimeBomb. 449 // watched. It disarms StartupTimeBomb.
450 static void InitializeAndStartWatching( 450 static void InitializeAndStartWatching(
451 uint32 unresponsive_threshold, 451 uint32_t unresponsive_threshold,
452 const CrashOnHangThreadMap& crash_on_hang_threads); 452 const CrashOnHangThreadMap& crash_on_hang_threads);
453 453
454 // This method calls ThreadWatcher::StartWatching() to perform health check on 454 // This method calls ThreadWatcher::StartWatching() to perform health check on
455 // the given |thread_id|. 455 // the given |thread_id|.
456 static void StartWatching( 456 static void StartWatching(const content::BrowserThread::ID& thread_id,
457 const content::BrowserThread::ID& thread_id, 457 const std::string& thread_name,
458 const std::string& thread_name, 458 const base::TimeDelta& sleep_time,
459 const base::TimeDelta& sleep_time, 459 const base::TimeDelta& unresponsive_time,
460 const base::TimeDelta& unresponsive_time, 460 uint32_t unresponsive_threshold,
461 uint32 unresponsive_threshold, 461 const CrashOnHangThreadMap& crash_on_hang_threads);
462 const CrashOnHangThreadMap& crash_on_hang_threads);
463 462
464 // Delete all thread watcher objects and remove them from global map. It also 463 // Delete all thread watcher objects and remove them from global map. It also
465 // deletes |g_thread_watcher_list_|. 464 // deletes |g_thread_watcher_list_|.
466 static void DeleteAll(); 465 static void DeleteAll();
467 466
468 // The Find() method can be used to test to see if a given ThreadWatcher was 467 // The Find() method can be used to test to see if a given ThreadWatcher was
469 // already registered, or to retrieve a pointer to it from the global map. 468 // already registered, or to retrieve a pointer to it from the global map.
470 static ThreadWatcher* Find(const content::BrowserThread::ID& thread_id); 469 static ThreadWatcher* Find(const content::BrowserThread::ID& thread_id);
471 470
472 // Sets |g_stopped_| on the WatchDogThread. This is necessary to reflect the 471 // Sets |g_stopped_| on the WatchDogThread. This is necessary to reflect the
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 // shutdown_watchdog_ watches for hangs during shutdown. 687 // shutdown_watchdog_ watches for hangs during shutdown.
689 base::Watchdog* shutdown_watchdog_; 688 base::Watchdog* shutdown_watchdog_;
690 689
691 // The |thread_id_| on which this object is constructed. 690 // The |thread_id_| on which this object is constructed.
692 const base::PlatformThreadId thread_id_; 691 const base::PlatformThreadId thread_id_;
693 692
694 DISALLOW_COPY_AND_ASSIGN(ShutdownWatcherHelper); 693 DISALLOW_COPY_AND_ASSIGN(ShutdownWatcherHelper);
695 }; 694 };
696 695
697 #endif // CHROME_BROWSER_METRICS_THREAD_WATCHER_H_ 696 #endif // CHROME_BROWSER_METRICS_THREAD_WATCHER_H_
OLDNEW
« no previous file with comments | « chrome/browser/metrics/plugin_metrics_provider_unittest.cc ('k') | chrome/browser/metrics/thread_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698