ProcessHangMonitor.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_ProcessHangMonitor_h
  6. #define mozilla_ProcessHangMonitor_h
  7. #include "mozilla/Atomics.h"
  8. #include "nsIObserver.h"
  9. class nsITabChild;
  10. class MessageLoop;
  11. namespace base {
  12. class Thread;
  13. } // namespace base
  14. namespace mozilla {
  15. namespace dom {
  16. class ContentParent;
  17. class TabParent;
  18. } // namespace dom
  19. class PProcessHangMonitorParent;
  20. class ProcessHangMonitor final
  21. : public nsIObserver
  22. {
  23. private:
  24. ProcessHangMonitor();
  25. virtual ~ProcessHangMonitor();
  26. public:
  27. static ProcessHangMonitor* Get() { return sInstance; }
  28. static ProcessHangMonitor* GetOrCreate();
  29. NS_DECL_ISUPPORTS
  30. NS_DECL_NSIOBSERVER
  31. static void AddProcess(dom::ContentParent* aContentParent);
  32. static void RemoveProcess(PProcessHangMonitorParent* aParent);
  33. static void ClearHang();
  34. static void ForcePaint(PProcessHangMonitorParent* aParent,
  35. dom::TabParent* aTab,
  36. uint64_t aLayerObserverEpoch);
  37. static void ClearForcePaint();
  38. enum SlowScriptAction {
  39. Continue,
  40. Terminate,
  41. StartDebugger
  42. };
  43. SlowScriptAction NotifySlowScript(nsITabChild* aTabChild,
  44. const char* aFileName,
  45. unsigned aLineNo);
  46. void NotifyPluginHang(uint32_t aPluginId);
  47. bool IsDebuggerStartupComplete();
  48. void InitiateCPOWTimeout();
  49. bool ShouldTimeOutCPOWs();
  50. MessageLoop* MonitorLoop();
  51. private:
  52. static ProcessHangMonitor* sInstance;
  53. Atomic<bool> mCPOWTimeout;
  54. base::Thread* mThread;
  55. };
  56. } // namespace mozilla
  57. #endif // mozilla_ProcessHangMonitor_h