/work/obj-fuzz/dist/include/mozilla/ProcessHangMonitor.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | #ifndef mozilla_ProcessHangMonitor_h |
8 | | #define mozilla_ProcessHangMonitor_h |
9 | | |
10 | | #include "mozilla/AlreadyAddRefed.h" |
11 | | #include "mozilla/Atomics.h" |
12 | | #include "nsCOMPtr.h" |
13 | | #include "nsIObserver.h" |
14 | | #include "nsStringFwd.h" |
15 | | |
16 | | class nsIRunnable; |
17 | | class nsITabChild; |
18 | | class nsIThread; |
19 | | |
20 | | namespace mozilla { |
21 | | |
22 | | namespace dom { |
23 | | class ContentParent; |
24 | | class TabParent; |
25 | | } // namespace dom |
26 | | |
27 | | namespace layers { |
28 | | struct LayersObserverEpoch; |
29 | | } // namespace layers |
30 | | |
31 | | class PProcessHangMonitorParent; |
32 | | |
33 | | class ProcessHangMonitor final |
34 | | : public nsIObserver |
35 | | { |
36 | | private: |
37 | | ProcessHangMonitor(); |
38 | | virtual ~ProcessHangMonitor(); |
39 | | |
40 | | public: |
41 | 0 | static ProcessHangMonitor* Get() { return sInstance; } |
42 | | static ProcessHangMonitor* GetOrCreate(); |
43 | | |
44 | | NS_DECL_ISUPPORTS |
45 | | NS_DECL_NSIOBSERVER |
46 | | |
47 | | static PProcessHangMonitorParent* AddProcess(dom::ContentParent* aContentParent); |
48 | | static void RemoveProcess(PProcessHangMonitorParent* aParent); |
49 | | |
50 | | static void ClearHang(); |
51 | | |
52 | | static void PaintWhileInterruptingJS(PProcessHangMonitorParent* aParent, |
53 | | dom::TabParent* aTab, |
54 | | bool aForceRepaint, |
55 | | const layers::LayersObserverEpoch& aEpoch); |
56 | | static void ClearPaintWhileInterruptingJS(const layers::LayersObserverEpoch& aEpoch); |
57 | | static void MaybeStartPaintWhileInterruptingJS(); |
58 | | |
59 | | enum SlowScriptAction { |
60 | | Continue, |
61 | | Terminate, |
62 | | StartDebugger, |
63 | | TerminateGlobal, |
64 | | }; |
65 | | SlowScriptAction NotifySlowScript(nsITabChild* aTabChild, |
66 | | const char* aFileName, |
67 | | const nsString& aAddonId); |
68 | | |
69 | | void NotifyPluginHang(uint32_t aPluginId); |
70 | | |
71 | | bool IsDebuggerStartupComplete(); |
72 | | |
73 | | void InitiateCPOWTimeout(); |
74 | | bool ShouldTimeOutCPOWs(); |
75 | | |
76 | | void Dispatch(already_AddRefed<nsIRunnable> aRunnable); |
77 | | bool IsOnThread(); |
78 | | |
79 | | private: |
80 | | static ProcessHangMonitor* sInstance; |
81 | | |
82 | | Atomic<bool> mCPOWTimeout; |
83 | | |
84 | | nsCOMPtr<nsIThread> mThread; |
85 | | }; |
86 | | |
87 | | } // namespace mozilla |
88 | | |
89 | | #endif // mozilla_ProcessHangMonitor_h |