2015-01-17 02:34:47 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_ProcessHangMonitor_h
|
|
|
|
#define mozilla_ProcessHangMonitor_h
|
|
|
|
|
2017-05-20 03:36:10 +00:00
|
|
|
#include "mozilla/AlreadyAddRefed.h"
|
2015-01-17 02:34:47 +00:00
|
|
|
#include "mozilla/Atomics.h"
|
2017-05-20 03:36:10 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2015-01-17 02:34:47 +00:00
|
|
|
#include "nsIObserver.h"
|
2019-04-30 23:31:36 +00:00
|
|
|
#include "nsIRemoteTab.h"
|
2017-08-23 23:27:16 +00:00
|
|
|
#include "nsStringFwd.h"
|
2015-01-17 02:34:47 +00:00
|
|
|
|
2017-05-20 03:36:10 +00:00
|
|
|
class nsIRunnable;
|
2019-04-09 23:15:02 +00:00
|
|
|
class nsIBrowserChild;
|
2017-05-20 03:36:10 +00:00
|
|
|
class nsIThread;
|
2015-01-17 02:34:47 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
class ContentParent;
|
2019-04-09 21:38:15 +00:00
|
|
|
class BrowserParent;
|
2019-04-30 23:31:36 +00:00
|
|
|
struct CancelContentJSOptions;
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace dom
|
2015-01-17 02:34:47 +00:00
|
|
|
|
2018-07-30 13:24:50 +00:00
|
|
|
namespace layers {
|
|
|
|
struct LayersObserverEpoch;
|
|
|
|
} // namespace layers
|
|
|
|
|
2015-01-17 02:34:47 +00:00
|
|
|
class PProcessHangMonitorParent;
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class ProcessHangMonitor final : public nsIObserver {
|
2015-01-17 02:34:47 +00:00
|
|
|
private:
|
|
|
|
ProcessHangMonitor();
|
|
|
|
virtual ~ProcessHangMonitor();
|
|
|
|
|
|
|
|
public:
|
|
|
|
static ProcessHangMonitor* Get() { return sInstance; }
|
|
|
|
static ProcessHangMonitor* GetOrCreate();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
2017-01-05 20:54:52 +00:00
|
|
|
static PProcessHangMonitorParent* AddProcess(
|
|
|
|
dom::ContentParent* aContentParent);
|
2015-01-17 02:34:47 +00:00
|
|
|
static void RemoveProcess(PProcessHangMonitorParent* aParent);
|
|
|
|
|
|
|
|
static void ClearHang();
|
|
|
|
|
2018-05-15 06:45:00 +00:00
|
|
|
static void PaintWhileInterruptingJS(
|
2019-04-09 21:38:15 +00:00
|
|
|
PProcessHangMonitorParent* aParent, dom::BrowserParent* aTab,
|
2018-07-30 13:24:50 +00:00
|
|
|
bool aForceRepaint, const layers::LayersObserverEpoch& aEpoch);
|
|
|
|
static void ClearPaintWhileInterruptingJS(
|
|
|
|
const layers::LayersObserverEpoch& aEpoch);
|
2018-05-15 06:45:00 +00:00
|
|
|
static void MaybeStartPaintWhileInterruptingJS();
|
2016-07-22 23:36:45 +00:00
|
|
|
|
2019-04-30 23:56:17 +00:00
|
|
|
static void CancelContentJSExecutionIfRunning(
|
2019-04-30 23:31:36 +00:00
|
|
|
PProcessHangMonitorParent* aParent, dom::BrowserParent* aTab,
|
|
|
|
nsIRemoteTab::NavigationType aNavigationType,
|
|
|
|
const dom::CancelContentJSOptions& aCancelContentJSOptions);
|
2019-04-30 23:56:17 +00:00
|
|
|
|
2015-01-17 02:34:47 +00:00
|
|
|
enum SlowScriptAction {
|
|
|
|
Continue,
|
|
|
|
Terminate,
|
2017-04-16 21:01:16 +00:00
|
|
|
StartDebugger,
|
|
|
|
TerminateGlobal,
|
2015-01-17 02:34:47 +00:00
|
|
|
};
|
2019-04-09 22:39:01 +00:00
|
|
|
SlowScriptAction NotifySlowScript(nsIBrowserChild* aBrowserChild,
|
2017-08-18 03:17:51 +00:00
|
|
|
const char* aFileName,
|
|
|
|
const nsString& aAddonId);
|
2015-01-17 02:34:47 +00:00
|
|
|
|
|
|
|
void NotifyPluginHang(uint32_t aPluginId);
|
|
|
|
|
|
|
|
bool IsDebuggerStartupComplete();
|
|
|
|
|
|
|
|
void InitiateCPOWTimeout();
|
|
|
|
bool ShouldTimeOutCPOWs();
|
|
|
|
|
2017-05-20 03:36:10 +00:00
|
|
|
void Dispatch(already_AddRefed<nsIRunnable> aRunnable);
|
|
|
|
bool IsOnThread();
|
2015-01-17 02:34:47 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
static ProcessHangMonitor* sInstance;
|
|
|
|
|
|
|
|
Atomic<bool> mCPOWTimeout;
|
|
|
|
|
2017-05-20 03:36:10 +00:00
|
|
|
nsCOMPtr<nsIThread> mThread;
|
2015-01-17 02:34:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_ProcessHangMonitor_h
|