| Index: runtime/observatory/lib/src/elements/isolate/location.dart
|
| diff --git a/runtime/observatory/lib/src/elements/isolate/location.dart b/runtime/observatory/lib/src/elements/isolate/location.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..fffadf608f11caecc8540227eb490e9cd5d6ddbf
|
| --- /dev/null
|
| +++ b/runtime/observatory/lib/src/elements/isolate/location.dart
|
| @@ -0,0 +1,125 @@
|
| +// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
| +// for details. All rights reserved. Use of this source code is governed by a
|
| +// BSD-style license that can be found in the LICENSE file.
|
| +
|
| +import 'dart:html';
|
| +import 'dart:async';
|
| +import 'package:observatory/models.dart' as M;
|
| +import 'package:observatory/src/elements/function_ref.dart';
|
| +import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
|
| +import 'package:observatory/src/elements/helpers/tag.dart';
|
| +import 'package:observatory/src/elements/source_link.dart';
|
| +
|
| +class IsolateLocationElement extends HtmlElement implements Renderable {
|
| + static const tag = const Tag<IsolateLocationElement>('isolate-location',
|
| + dependencies: const [
|
| + FunctionRefElement.tag,
|
| + SourceLinkElement.tag
|
| + ]);
|
| +
|
| + RenderingScheduler<IsolateLocationElement> _r;
|
| +
|
| + Stream<RenderedEvent<IsolateLocationElement>> get onRendered =>
|
| + _r.onRendered;
|
| +
|
| + M.Isolate _isolate;
|
| + M.EventRepository _events;
|
| + M.ScriptRepository _scripts;
|
| + StreamSubscription _debugSubscription;
|
| + StreamSubscription _isolateSubscription;
|
| +
|
| + factory IsolateLocationElement(M.Isolate isolate,
|
| + M.EventRepository events,
|
| + M.ScriptRepository scripts,
|
| + {RenderingQueue queue}) {
|
| + assert(isolate != null);
|
| + assert(events != null);
|
| + assert(scripts != null);
|
| + IsolateLocationElement e = document.createElement(tag.name);
|
| + e._r = new RenderingScheduler(e, queue: queue);
|
| + e._isolate = isolate;
|
| + e._events = events;
|
| + e._scripts = scripts;
|
| + return e;
|
| + }
|
| +
|
| + IsolateLocationElement.created() : super.created();
|
| +
|
| + @override
|
| + void attached() {
|
| + super.attached();
|
| + _r.enable();
|
| + _debugSubscription = _events.onDebugEvent.listen(_eventListener);
|
| + _isolateSubscription = _events.onIsolateEvent.listen(_eventListener);
|
| + }
|
| +
|
| + @override
|
| + void detached() {
|
| + super.detached();
|
| + children = [];
|
| + _r.disable(notify: true);
|
| + _debugSubscription.cancel();
|
| + _isolateSubscription.cancel();
|
| + }
|
| +
|
| + void render() {
|
| + switch (_isolate.status) {
|
| + case M.IsolateStatus.loading:
|
| + children = [new SpanElement()..text = 'not yet runnable'];
|
| + break;
|
| + case M.IsolateStatus.running:
|
| + children = [
|
| + new SpanElement()..text = 'at ',
|
| + new FunctionRefElement(_isolate,
|
| + M.topFrame(_isolate.pauseEvent).function,
|
| + queue: _r.queue),
|
| + new SpanElement()..text = ' (',
|
| + new SourceLinkElement(_isolate,
|
| + M.topFrame(_isolate.pauseEvent).location,
|
| + _scripts,
|
| + queue: _r.queue),
|
| + new SpanElement()..text = ') '
|
| + ];
|
| + break;
|
| + case M.IsolateStatus.paused:
|
| + if (_isolate.pauseEvent is M.PauseStartEvent) {
|
| + children = [new SpanElement()..text = 'at isolate start'];
|
| + } else if (_isolate.pauseEvent is M.PauseExitEvent) {
|
| + children = [new SpanElement()..text = 'at isolate exit'];
|
| + } else if (_isolate.pauseEvent is M.NoneEvent) {
|
| + children = [new SpanElement()..text = 'not yet runnable'];
|
| + } else {
|
| + final content = <Element>[];
|
| + if (_isolate.pauseEvent is M.PauseBreakpointEvent) {
|
| + content.add(new SpanElement()..text = 'by breakpoint');
|
| + } else if (_isolate.pauseEvent is M.PauseExceptionEvent) {
|
| + content.add(new SpanElement()..text = 'by exception');
|
| + }
|
| + if (M.topFrame(_isolate.pauseEvent) != null) {
|
| + content.addAll([
|
| + new SpanElement()..text = ' at ',
|
| + new FunctionRefElement(_isolate,
|
| + M.topFrame(_isolate.pauseEvent).function,
|
| + queue: _r.queue),
|
| + new SpanElement()..text = ' (',
|
| + new SourceLinkElement(_isolate,
|
| + M.topFrame(_isolate.pauseEvent).location,
|
| + _scripts,
|
| + queue: _r.queue),
|
| + new SpanElement()..text = ') '
|
| + ]);
|
| + }
|
| + children = content;
|
| + }
|
| + break;
|
| + default:
|
| + children = const [];
|
| + }
|
| + }
|
| +
|
| + void _eventListener(e) {
|
| + if (e.isolate.id == _isolate.id) {
|
| + _r.dirty();
|
| + }
|
| + }
|
| +}
|
|
|