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"
|
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;
|
2015-01-17 05:34:47 +03:00
|
|
|
class nsITabChild;
|
2017-05-20 06:36:10 +03:00
|
|
|
class nsIThread;
|
2015-01-17 05:34:47 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
class ContentParent;
|
2016-07-23 02:36:45 +03:00
|
|
|
class TabParent;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
2015-01-17 05:34:47 +03:00
|
|
|
|
|
|
|
class PProcessHangMonitorParent;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class ProcessHangMonitor final
|
2015-01-17 05:34:47 +03:00
|
|
|
: public nsIObserver
|
|
|
|
{
|
|
|
|
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(PProcessHangMonitorParent* aParent,
|
|
|
|
dom::TabParent* aTab,
|
|
|
|
bool aForceRepaint,
|
|
|
|
uint64_t aLayerObserverEpoch);
|
|
|
|
static void ClearPaintWhileInterruptingJS(uint64_t aLayerObserverEpoch);
|
|
|
|
static void MaybeStartPaintWhileInterruptingJS();
|
2016-07-23 02:36:45 +03:00
|
|
|
|
2015-01-17 05:34:47 +03:00
|
|
|
enum SlowScriptAction {
|
|
|
|
Continue,
|
|
|
|
Terminate,
|
2017-04-17 00:01:16 +03:00
|
|
|
StartDebugger,
|
|
|
|
TerminateGlobal,
|
2015-01-17 05:34:47 +03:00
|
|
|
};
|
|
|
|
SlowScriptAction NotifySlowScript(nsITabChild* aTabChild,
|
2017-08-18 06:17:51 +03:00
|
|
|
const char* aFileName,
|
|
|
|
const nsString& aAddonId);
|
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
|