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

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

Issue 188653003: ThreadWatcher: fixes Start/StopWatchingAll. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes TSan Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/metrics/thread_watcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 static void GetStatusOfThreads(uint32* responding_thread_count, 399 static void GetStatusOfThreads(uint32* responding_thread_count,
400 uint32* unresponding_thread_count); 400 uint32* unresponding_thread_count);
401 401
402 // This will ensure that the watching is actively taking place, and awaken 402 // This will ensure that the watching is actively taking place, and awaken
403 // all thread watchers that are registered. 403 // all thread watchers that are registered.
404 static void WakeUpAll(); 404 static void WakeUpAll();
405 405
406 private: 406 private:
407 // Allow tests to access our innards for testing purposes. 407 // Allow tests to access our innards for testing purposes.
408 friend class CustomThreadWatcher; 408 friend class CustomThreadWatcher;
409 friend class ThreadWatcherListTest;
409 friend class ThreadWatcherTest; 410 friend class ThreadWatcherTest;
410 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherTest, ThreadNamesOnlyArgs); 411 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherTest, ThreadNamesOnlyArgs);
411 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherTest, ThreadNamesAndLiveThresholdArgs); 412 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherTest, ThreadNamesAndLiveThresholdArgs);
412 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherTest, CrashOnHangThreadsAllArgs); 413 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherTest, CrashOnHangThreadsAllArgs);
414 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherListTest, Restart);
ramant (doing other things) 2014/03/07 22:56:41 nit: please consider moving line 414 to before lin
bulach 2014/03/10 12:13:21 Done.
413 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherAndroidTest, 415 FRIEND_TEST_ALL_PREFIXES(ThreadWatcherAndroidTest,
ramant (doing other things) 2014/03/07 22:56:41 nit: please consider moving lines 415-416 to after
bulach 2014/03/10 12:13:21 Done.
414 ApplicationStatusNotification); 416 ApplicationStatusNotification);
415 417
416 // This singleton holds the global list of registered ThreadWatchers. 418 // This singleton holds the global list of registered ThreadWatchers.
417 ThreadWatcherList(); 419 ThreadWatcherList();
418 420
419 // Destructor deletes all registered ThreadWatcher instances. 421 // Destructor deletes all registered ThreadWatcher instances.
420 virtual ~ThreadWatcherList(); 422 virtual ~ThreadWatcherList();
421 423
422 // Parses the command line to get |crash_on_hang_threads| map from 424 // Parses the command line to get |crash_on_hang_threads| map from
423 // switches::kCrashOnHangThreads. |crash_on_hang_threads| is a map of 425 // switches::kCrashOnHangThreads. |crash_on_hang_threads| is a map of
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 const CrashOnHangThreadMap& crash_on_hang_threads); 459 const CrashOnHangThreadMap& crash_on_hang_threads);
458 460
459 // Delete all thread watcher objects and remove them from global map. It also 461 // Delete all thread watcher objects and remove them from global map. It also
460 // deletes |g_thread_watcher_list_|. 462 // deletes |g_thread_watcher_list_|.
461 static void DeleteAll(); 463 static void DeleteAll();
462 464
463 // The Find() method can be used to test to see if a given ThreadWatcher was 465 // The Find() method can be used to test to see if a given ThreadWatcher was
464 // already registered, or to retrieve a pointer to it from the global map. 466 // already registered, or to retrieve a pointer to it from the global map.
465 static ThreadWatcher* Find(const content::BrowserThread::ID& thread_id); 467 static ThreadWatcher* Find(const content::BrowserThread::ID& thread_id);
466 468
469 // Sets |g_stopped_| on the WatchDogThread. This is necessary to reflect the
470 // state between the delayed |StartWatchingAll| and the immediate
471 // |StopWatchingAll|.
472 static void SetStopped(bool stopped);
473
467 // The singleton of this class and is used to keep track of information about 474 // The singleton of this class and is used to keep track of information about
468 // threads that are being watched. 475 // threads that are being watched.
469 static ThreadWatcherList* g_thread_watcher_list_; 476 static ThreadWatcherList* g_thread_watcher_list_;
470 477
478 // StartWatchingAll() is delayed in relation to StopWatchingAll(), so if
479 // a Stop comes first, prevent further initialization.
480 static bool g_stopped_;
481
471 // This is the wait time between ping messages. 482 // This is the wait time between ping messages.
472 static const int kSleepSeconds; 483 static const int kSleepSeconds;
473 484
474 // This is the wait time after ping message is sent, to check if we have 485 // This is the wait time after ping message is sent, to check if we have
475 // received pong message or not. 486 // received pong message or not.
476 static const int kUnresponsiveSeconds; 487 static const int kUnresponsiveSeconds;
477 488
478 // Default values for |unresponsive_threshold|. 489 // Default values for |unresponsive_threshold|.
479 static const int kUnresponsiveCount; 490 static const int kUnresponsiveCount;
480 491
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 // shutdown_watchdog_ watches for hangs during shutdown. 641 // shutdown_watchdog_ watches for hangs during shutdown.
631 base::Watchdog* shutdown_watchdog_; 642 base::Watchdog* shutdown_watchdog_;
632 643
633 // The |thread_id_| on which this object is constructed. 644 // The |thread_id_| on which this object is constructed.
634 const base::PlatformThreadId thread_id_; 645 const base::PlatformThreadId thread_id_;
635 646
636 DISALLOW_COPY_AND_ASSIGN(ShutdownWatcherHelper); 647 DISALLOW_COPY_AND_ASSIGN(ShutdownWatcherHelper);
637 }; 648 };
638 649
639 #endif // CHROME_BROWSER_METRICS_THREAD_WATCHER_H_ 650 #endif // CHROME_BROWSER_METRICS_THREAD_WATCHER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/metrics/thread_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698