Line data Source code
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 :
15 : class nsIRunnable;
16 : class nsITabChild;
17 : class nsIThread;
18 :
19 : namespace mozilla {
20 :
21 : namespace dom {
22 : class ContentParent;
23 : class TabParent;
24 : } // namespace dom
25 :
26 : class PProcessHangMonitorParent;
27 :
28 : class ProcessHangMonitor final
29 : : public nsIObserver
30 : {
31 : private:
32 : ProcessHangMonitor();
33 : virtual ~ProcessHangMonitor();
34 :
35 : public:
36 0 : static ProcessHangMonitor* Get() { return sInstance; }
37 : static ProcessHangMonitor* GetOrCreate();
38 :
39 : NS_DECL_ISUPPORTS
40 : NS_DECL_NSIOBSERVER
41 :
42 : static PProcessHangMonitorParent* AddProcess(dom::ContentParent* aContentParent);
43 : static void RemoveProcess(PProcessHangMonitorParent* aParent);
44 :
45 : static void ClearHang();
46 :
47 : static void ForcePaint(PProcessHangMonitorParent* aParent,
48 : dom::TabParent* aTab,
49 : uint64_t aLayerObserverEpoch);
50 : static void ClearForcePaint();
51 :
52 : enum SlowScriptAction {
53 : Continue,
54 : Terminate,
55 : StartDebugger
56 : };
57 : SlowScriptAction NotifySlowScript(nsITabChild* aTabChild,
58 : const char* aFileName);
59 :
60 : void NotifyPluginHang(uint32_t aPluginId);
61 :
62 : bool IsDebuggerStartupComplete();
63 :
64 : void InitiateCPOWTimeout();
65 : bool ShouldTimeOutCPOWs();
66 :
67 : void Dispatch(already_AddRefed<nsIRunnable> aRunnable);
68 : bool IsOnThread();
69 :
70 : private:
71 : static ProcessHangMonitor* sInstance;
72 :
73 : Atomic<bool> mCPOWTimeout;
74 :
75 : nsCOMPtr<nsIThread> mThread;
76 : };
77 :
78 : } // namespace mozilla
79 :
80 : #endif // mozilla_ProcessHangMonitor_h
|