mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-30 17:27:22 +08:00
This was a temporary method, used during the migration to use objects in dispatcher callbacks. Since all dispatchers now receive the event as an object, we can remove these temporary methods. R=aerotwist@chromium.org Fixed: 1138492 Bug: 1011811 Change-Id: Ib7fbfae567ebc9b2be0a5d760458e5b0c7edc12e Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2484723 Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Paul Lewis <aerotwist@chromium.org>
75 lines
2.2 KiB
JavaScript
75 lines
2.2 KiB
JavaScript
// Copyright 2018 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import * as SDK from '../sdk/sdk.js';
|
|
import * as UI from '../ui/ui.js';
|
|
|
|
/**
|
|
* @implements {ProtocolProxyApi.InspectorDispatcher}
|
|
*/
|
|
export class TargetDetachedDialog extends SDK.SDKModel.SDKModel {
|
|
/**
|
|
* @param {!SDK.SDKModel.Target} target
|
|
*/
|
|
constructor(target) {
|
|
super(target);
|
|
target.registerInspectorDispatcher(this);
|
|
target.inspectorAgent().invoke_enable();
|
|
this._hideCrashedDialog = null;
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
* @param {!Protocol.Inspector.DetachedEvent} event
|
|
*/
|
|
detached({reason}) {
|
|
UI.RemoteDebuggingTerminatedScreen.RemoteDebuggingTerminatedScreen.show(reason);
|
|
}
|
|
|
|
static webSocketConnectionLost() {
|
|
UI.RemoteDebuggingTerminatedScreen.RemoteDebuggingTerminatedScreen.show(ls`WebSocket disconnected`);
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
*/
|
|
targetCrashed() {
|
|
// In case of service workers targetCrashed usually signals that the worker is stopped
|
|
// and in any case it is restarted automatically (in which case front-end will receive
|
|
// targetReloadedAfterCrash event).
|
|
if (this.target().parentTarget()) {
|
|
return;
|
|
}
|
|
const dialog = new UI.Dialog.Dialog();
|
|
dialog.setSizeBehavior(UI.GlassPane.SizeBehavior.MeasureContent);
|
|
dialog.addCloseButton();
|
|
dialog.setDimmed(true);
|
|
this._hideCrashedDialog = dialog.hide.bind(dialog);
|
|
new UI.TargetCrashedScreen
|
|
.TargetCrashedScreen(() => {
|
|
this._hideCrashedDialog = null;
|
|
})
|
|
.show(dialog.contentElement);
|
|
|
|
// UI.Dialog extends GlassPane and overrides the `show` method with a wider
|
|
// accepted type. However, TypeScript uses the supertype declaration to
|
|
// determine the full type, which requires a `!Document`.
|
|
// @ts-ignore
|
|
dialog.show();
|
|
}
|
|
|
|
/**
|
|
* @override;
|
|
*/
|
|
targetReloadedAfterCrash() {
|
|
this.target().runtimeAgent().invoke_runIfWaitingForDebugger();
|
|
if (this._hideCrashedDialog) {
|
|
this._hideCrashedDialog.call(null);
|
|
this._hideCrashedDialog = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
SDK.SDKModel.SDKModel.register(TargetDetachedDialog, SDK.SDKModel.Capability.Inspector, true);
|