Index: runtime/observatory/lib/src/elements/sentinel_view.dart |
diff --git a/runtime/observatory/lib/src/elements/sentinel_view.dart b/runtime/observatory/lib/src/elements/sentinel_view.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4fcc00d64c1de279fe1f4ddec021efb3089ce222 |
--- /dev/null |
+++ b/runtime/observatory/lib/src/elements/sentinel_view.dart |
@@ -0,0 +1,122 @@ |
+// Copyright (c) 2013, 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/helpers/rendering_scheduler.dart'; |
+import 'package:observatory/src/elements/helpers/tag.dart'; |
+import 'package:observatory/src/elements/nav/bar.dart'; |
+import 'package:observatory/src/elements/nav/isolate_menu.dart'; |
+import 'package:observatory/src/elements/nav/menu.dart'; |
+import 'package:observatory/src/elements/nav/notify.dart'; |
+import 'package:observatory/src/elements/nav/top_menu.dart'; |
+import 'package:observatory/src/elements/nav/vm_menu.dart'; |
+import 'package:observatory/src/elements/view_footer.dart'; |
+ |
+ |
+class SentinelViewElement extends HtmlElement implements Renderable { |
+ static const tag = const Tag<SentinelViewElement>('sentinel-view', |
+ dependencies: const [ |
+ NavBarElement.tag, |
+ NavTopMenuElement.tag, |
+ NavVMMenuElement.tag, |
+ NavIsolateMenuElement.tag, |
+ NavMenuElement.tag, |
+ NavNotifyElement.tag, |
+ ViewFooterElement.tag |
+ ]); |
+ |
+ RenderingScheduler<SentinelViewElement> _r; |
+ |
+ Stream<RenderedEvent<SentinelViewElement>> get onRendered => _r.onRendered; |
+ |
+ M.VM _vm; |
+ M.IsolateRef _isolate; |
+ M.Sentinel _sentinel; |
+ M.EventRepository _events; |
+ M.NotificationRepository _notifications; |
+ |
+ M.Sentinel get sentinel => _sentinel; |
+ |
+ factory SentinelViewElement(M.VM vm, M.IsolateRef isolate, M.Sentinel sentinel, |
+ M.EventRepository events, |
+ M.NotificationRepository notifications, |
+ {RenderingQueue queue}) { |
+ assert(vm != null); |
+ assert(isolate != null); |
+ assert(sentinel != null); |
+ assert(events != null); |
+ assert(notifications != null); |
+ SentinelViewElement e = document.createElement(tag.name); |
+ e._r = new RenderingScheduler(e, queue: queue); |
+ e._vm = vm; |
+ e._isolate = isolate; |
+ e._sentinel = sentinel; |
+ e._events = events; |
+ e._notifications = notifications; |
+ return e; |
+ } |
+ |
+ SentinelViewElement.created() : super.created(); |
+ |
+ @override |
+ void attached() { |
+ super.attached(); |
+ _r.enable(); |
+ } |
+ |
+ @override |
+ void detached() { |
+ super.detached(); |
+ _r.disable(notify: true); |
+ text = ''; |
+ title = ''; |
+ } |
+ |
+ void render() { |
+ children = [ |
+ new NavBarElement(queue: _r.queue) |
+ ..children = [ |
+ new NavTopMenuElement(queue: _r.queue), |
+ new NavVMMenuElement(_vm, _events, queue: _r.queue), |
+ new NavIsolateMenuElement(_isolate, _events, queue: _r.queue), |
+ new NavMenuElement('sentinel', last: true, queue: _r.queue), |
+ new NavNotifyElement(_notifications, queue: _r.queue) |
+ ], |
+ new DivElement()..classes = const ['content-centered-big'] |
+ ..children = [ |
+ new HeadingElement.h2() |
+ ..text = 'Sentinel: #{_sentinel.valueAsString}', |
+ new HRElement(), |
+ new DivElement() |
+ ..text = _sentinelKindToDescription(_sentinel.kind), |
+ new HRElement(), |
+ new ViewFooterElement(queue: _r.queue) |
+ ] |
+ ]; |
+ } |
+ |
+ static String _sentinelKindToDescription(M.SentinelKind kind) { |
+ switch (kind) { |
+ case M.SentinelKind.collected: |
+ return 'This object has been reclaimed by the garbage collector.'; |
+ case M.SentinelKind.expired: |
+ return 'The handle to this object has expired. ' |
+ 'Consider refreshing the page.'; |
+ case M.SentinelKind.notInitialized: |
+ return 'This object will be initialized once it is accessed by ' |
+ 'the program.'; |
+ case M.SentinelKind.initializing: |
+ return 'This object is currently being initialized.'; |
+ case M.SentinelKind.optimizedOut: |
+ return 'This object is no longer needed and has been removed by the ' |
+ 'optimizing compiler.'; |
+ case M.SentinelKind.free: |
+ return ''; |
+ } |
+ throw new Exception('Unknown SentinelKind: $kind'); |
+ } |
+ |
+} |