Bug 1889091 - Part 6: Remove "scratch" register parameter from emitPushArguments...
[gecko.git] / dom / ipc / ProcessHangMonitor.h
blob9e4ce5758d9ae73e5f6d8751c30ed630071e228a
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_ProcessHangMonitor_h
8 #define mozilla_ProcessHangMonitor_h
10 #include "mozilla/AlreadyAddRefed.h"
11 #include "mozilla/Atomics.h"
12 #include "nsCOMPtr.h"
13 #include "nsIObserver.h"
14 #include "nsIRemoteTab.h"
15 #include "nsIThread.h"
16 #include "nsStringFwd.h"
18 class nsIRunnable;
19 class nsIBrowserChild;
20 class nsIThread;
22 namespace mozilla {
24 namespace dom {
25 class ContentParent;
26 class BrowserParent;
27 struct CancelContentJSOptions;
28 } // namespace dom
30 class PProcessHangMonitorParent;
32 class ProcessHangMonitor final : public nsIObserver {
33 private:
34 ProcessHangMonitor();
35 virtual ~ProcessHangMonitor();
37 public:
38 static ProcessHangMonitor* Get() { return sInstance; }
39 static ProcessHangMonitor* GetOrCreate();
41 NS_DECL_ISUPPORTS
42 NS_DECL_NSIOBSERVER
44 static already_AddRefed<PProcessHangMonitorParent> AddProcess(
45 dom::ContentParent* aContentParent);
46 static void RemoveProcess(PProcessHangMonitorParent* aParent);
48 static void ClearHang();
50 static void PaintWhileInterruptingJS(PProcessHangMonitorParent* aParent,
51 dom::BrowserParent* aTab);
53 static void UnloadLayersWhileInterruptingJS(
54 PProcessHangMonitorParent* aParent, dom::BrowserParent* aTab);
56 static void ClearPaintWhileInterruptingJS();
57 static void MaybeStartPaintWhileInterruptingJS();
59 static void CancelContentJSExecutionIfRunning(
60 PProcessHangMonitorParent* aParent, dom::BrowserParent* aTab,
61 nsIRemoteTab::NavigationType aNavigationType,
62 const dom::CancelContentJSOptions& aCancelContentJSOptions);
64 static void SetMainThreadQoSPriority(PProcessHangMonitorParent* aParent,
65 nsIThread::QoSPriority aQoSPriority);
67 enum SlowScriptAction {
68 Continue,
69 Terminate,
70 StartDebugger,
72 SlowScriptAction NotifySlowScript(nsIBrowserChild* aBrowserChild,
73 const char* aFileName,
74 const nsString& aAddonId,
75 const double aDuration);
77 void NotifyPluginHang(uint32_t aPluginId);
79 bool IsDebuggerStartupComplete();
81 void InitiateCPOWTimeout();
82 bool ShouldTimeOutCPOWs();
84 nsresult Dispatch(already_AddRefed<nsIRunnable> aRunnable);
85 bool IsOnThread();
87 private:
88 static ProcessHangMonitor* sInstance;
90 Atomic<bool> mCPOWTimeout;
92 nsCOMPtr<nsIThread> mThread;
95 } // namespace mozilla
97 #endif // mozilla_ProcessHangMonitor_h