2015-01-17 05:34:47 +03: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 06:36:10 +03:00
|
|
|
#include "mozilla/AlreadyAddRefed.h"
|
2015-01-17 05:34:47 +03:00
|
|
|
#include "mozilla/Atomics.h"
|
2017-05-20 06:36:10 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2015-01-17 05:34:47 +03:00
|
|
|
#include "nsIObserver.h"
|
2019-05-01 02:31:36 +03:00
|
|
|
#include "nsIRemoteTab.h"
|
2017-08-24 02:27:16 +03:00
|
|
|
#include "nsStringFwd.h"
|
2015-01-17 05:34:47 +03:00
|
|
|
|
2017-05-20 06:36:10 +03:00
|
|
|
class nsIRunnable;
|
2019-04-10 02:15:02 +03:00
|
|
|
class nsIBrowserChild;
|
2017-05-20 06:36:10 +03:00
|
|
|
class nsIThread;
|
2015-01-17 05:34:47 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
class ContentParent;
|
2019-04-10 00:38:15 +03:00
|
|
|
class BrowserParent;
|
2019-05-01 02:31:36 +03:00
|
|
|
struct CancelContentJSOptions;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
2015-01-17 05:34:47 +03:00
|
|
|
|
2018-07-30 16:24:50 +03:00
|
|
|
namespace layers {
|
|
|
|
struct LayersObserverEpoch;
|
|
|
|
} // namespace layers
|
|
|
|
|
2015-01-17 05:34:47 +03:00
|
|
|
class PProcessHangMonitorParent;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class ProcessHangMonitor final : public nsIObserver {
|
2015-01-17 05:34:47 +03:00
|
|
|
private:
|
|
|
|
ProcessHangMonitor();
|
|
|
|
virtual ~ProcessHangMonitor();
|
|
|
|
|
|
|
|
public:
|
|
|
|
static ProcessHangMonitor* Get() { return sInstance; }
|
|
|
|
static ProcessHangMonitor* GetOrCreate();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
2017-01-05 23:54:52 +03:00
|
|
|
static PProcessHangMonitorParent* AddProcess(
|
|
|
|
dom::ContentParent* aContentParent);
|
2015-01-17 05:34:47 +03:00
|
|
|
static void RemoveProcess(PProcessHangMonitorParent* aParent);
|
|
|
|
|
|
|
|
static void ClearHang();
|
|
|
|
|
2018-05-15 09:45:00 +03:00
|
|
|
static void PaintWhileInterruptingJS(
|
2019-04-10 00:38:15 +03:00
|
|
|
PProcessHangMonitorParent* aParent, dom::BrowserParent* aTab,
|
2019-09-27 01:11:17 +03:00
|
|
|
const layers::LayersObserverEpoch& aEpoch);
|
2018-07-30 16:24:50 +03:00
|
|
|
static void ClearPaintWhileInterruptingJS(
|
|
|
|
const layers::LayersObserverEpoch& aEpoch);
|
2018-05-15 09:45:00 +03:00
|
|
|
static void MaybeStartPaintWhileInterruptingJS();
|
2016-07-23 02:36:45 +03:00
|
|
|
|
2019-05-01 02:56:17 +03:00
|
|
|
static void CancelContentJSExecutionIfRunning(
|
2019-05-01 02:31:36 +03:00
|
|
|
PProcessHangMonitorParent* aParent, dom::BrowserParent* aTab,
|
|
|
|
nsIRemoteTab::NavigationType aNavigationType,
|
|
|
|
const dom::CancelContentJSOptions& aCancelContentJSOptions);
|
2019-05-01 02:56:17 +03:00
|
|
|
|
2015-01-17 05:34:47 +03:00
|
|
|
enum SlowScriptAction {
|
|
|
|
Continue,
|
|
|
|
Terminate,
|
2017-04-17 00:01:16 +03:00
|
|
|
StartDebugger,
|
2015-01-17 05:34:47 +03:00
|
|
|
};
|
2019-04-10 01:39:01 +03:00
|
|
|
SlowScriptAction NotifySlowScript(nsIBrowserChild* aBrowserChild,
|
2017-08-18 06:17:51 +03:00
|
|
|
const char* aFileName,
|
2020-07-24 03:01:57 +03:00
|
|
|
const nsString& aAddonId,
|
|
|
|
const double aDuration);
|
2015-01-17 05:34:47 +03:00
|
|
|
|
|
|
|
void NotifyPluginHang(uint32_t aPluginId);
|
|
|
|
|
|
|
|
bool IsDebuggerStartupComplete();
|
|
|
|
|
|
|
|
void InitiateCPOWTimeout();
|
|
|
|
bool ShouldTimeOutCPOWs();
|
|
|
|
|
2017-05-20 06:36:10 +03:00
|
|
|
void Dispatch(already_AddRefed<nsIRunnable> aRunnable);
|
|
|
|
bool IsOnThread();
|
2015-01-17 05:34:47 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
static ProcessHangMonitor* sInstance;
|
|
|
|
|
|
|
|
Atomic<bool> mCPOWTimeout;
|
|
|
|
|
2017-05-20 06:36:10 +03:00
|
|
|
nsCOMPtr<nsIThread> mThread;
|
2015-01-17 05:34:47 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_ProcessHangMonitor_h
|