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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 | « chrome/browser/metrics/metrics_service.cc ('k') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 386
387 // This class ensures that the thread watching is actively taking place. Only 387 // This class ensures that the thread watching is actively taking place. Only
388 // one instance of this class exists. 388 // one instance of this class exists.
389 class ThreadWatcherObserver : public NotificationObserver { 389 class ThreadWatcherObserver : public NotificationObserver {
390 public: 390 public:
391 // Registers |g_thread_watcher_observer_| as the Notifications observer. 391 // Registers |g_thread_watcher_observer_| as the Notifications observer.
392 // |wakeup_interval| specifies how often to wake up thread watchers. This 392 // |wakeup_interval| specifies how often to wake up thread watchers. This
393 // method is accessible on UI thread. 393 // method is accessible on UI thread.
394 static void SetupNotifications(const base::TimeDelta& wakeup_interval); 394 static void SetupNotifications(const base::TimeDelta& wakeup_interval);
395 395
396 // Removes all NotificationTypes from |registrar_| and deletes 396 // Removes all ints from |registrar_| and deletes
397 // |g_thread_watcher_observer_|. This method is accessible on UI thread. 397 // |g_thread_watcher_observer_|. This method is accessible on UI thread.
398 static void RemoveNotifications(); 398 static void RemoveNotifications();
399 399
400 private: 400 private:
401 // Constructor of |g_thread_watcher_observer_| singleton. 401 // Constructor of |g_thread_watcher_observer_| singleton.
402 explicit ThreadWatcherObserver(const base::TimeDelta& wakeup_interval); 402 explicit ThreadWatcherObserver(const base::TimeDelta& wakeup_interval);
403 403
404 // Destructor of |g_thread_watcher_observer_| singleton. 404 // Destructor of |g_thread_watcher_observer_| singleton.
405 virtual ~ThreadWatcherObserver(); 405 virtual ~ThreadWatcherObserver();
406 406
407 // This ensures all thread watchers are active because there is some user 407 // This ensures all thread watchers are active because there is some user
408 // activity. It will wake up all thread watchers every |wakeup_interval_| 408 // activity. It will wake up all thread watchers every |wakeup_interval_|
409 // seconds. This is the implementation of NotificationObserver. When a 409 // seconds. This is the implementation of NotificationObserver. When a
410 // matching notification is posted to the notification service, this method is 410 // matching notification is posted to the notification service, this method is
411 // called. 411 // called.
412 virtual void Observe(NotificationType type, 412 virtual void Observe(int type,
413 const NotificationSource& source, 413 const NotificationSource& source,
414 const NotificationDetails& details); 414 const NotificationDetails& details);
415 415
416 // The singleton of this class. 416 // The singleton of this class.
417 static ThreadWatcherObserver* g_thread_watcher_observer_; 417 static ThreadWatcherObserver* g_thread_watcher_observer_;
418 418
419 // The registrar that holds NotificationTypes to be observed. 419 // The registrar that holds ints to be observed.
420 NotificationRegistrar registrar_; 420 NotificationRegistrar registrar_;
421 421
422 // This is the last time when woke all thread watchers up. 422 // This is the last time when woke all thread watchers up.
423 base::TimeTicks last_wakeup_time_; 423 base::TimeTicks last_wakeup_time_;
424 424
425 // It is the time interval between wake up calls to thread watchers. 425 // It is the time interval between wake up calls to thread watchers.
426 const base::TimeDelta wakeup_interval_; 426 const base::TimeDelta wakeup_interval_;
427 427
428 DISALLOW_COPY_AND_ASSIGN(ThreadWatcherObserver); 428 DISALLOW_COPY_AND_ASSIGN(ThreadWatcherObserver);
429 }; 429 };
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 469
470 DISALLOW_COPY_AND_ASSIGN(WatchDogThread); 470 DISALLOW_COPY_AND_ASSIGN(WatchDogThread);
471 }; 471 };
472 472
473 // DISABLE_RUNNABLE_METHOD_REFCOUNT is a convenience macro for disabling 473 // DISABLE_RUNNABLE_METHOD_REFCOUNT is a convenience macro for disabling
474 // refcounting of ThreadWatcher and ThreadWatcherList classes. 474 // refcounting of ThreadWatcher and ThreadWatcherList classes.
475 DISABLE_RUNNABLE_METHOD_REFCOUNT(ThreadWatcher); 475 DISABLE_RUNNABLE_METHOD_REFCOUNT(ThreadWatcher);
476 DISABLE_RUNNABLE_METHOD_REFCOUNT(ThreadWatcherList); 476 DISABLE_RUNNABLE_METHOD_REFCOUNT(ThreadWatcherList);
477 477
478 #endif // CHROME_BROWSER_METRICS_THREAD_WATCHER_H_ 478 #endif // CHROME_BROWSER_METRICS_THREAD_WATCHER_H_
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_service.cc ('k') | chrome/browser/metrics/thread_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698