OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:html'; | 5 import 'dart:html'; |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'package:observatory/models.dart' as M; | 7 import 'package:observatory/models.dart' as M; |
8 import 'package:observatory/src/elements/helpers/nav_bar.dart'; | 8 import 'package:observatory/src/elements/helpers/nav_bar.dart'; |
9 import 'package:observatory/src/elements/helpers/nav_menu.dart'; | 9 import 'package:observatory/src/elements/helpers/nav_menu.dart'; |
10 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 10 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
11 import 'package:observatory/src/elements/helpers/tag.dart'; | 11 import 'package:observatory/src/elements/helpers/tag.dart'; |
12 import 'package:observatory/src/elements/nav/isolate_menu.dart'; | 12 import 'package:observatory/src/elements/nav/isolate_menu.dart'; |
13 import 'package:observatory/src/elements/nav/notify.dart'; | 13 import 'package:observatory/src/elements/nav/notify.dart'; |
14 import 'package:observatory/src/elements/nav/top_menu.dart'; | 14 import 'package:observatory/src/elements/nav/top_menu.dart'; |
15 import 'package:observatory/src/elements/nav/vm_menu.dart'; | 15 import 'package:observatory/src/elements/nav/vm_menu.dart'; |
16 import 'package:observatory/src/elements/view_footer.dart'; | 16 import 'package:observatory/src/elements/view_footer.dart'; |
17 | 17 |
18 | |
19 class SentinelViewElement extends HtmlElement implements Renderable { | 18 class SentinelViewElement extends HtmlElement implements Renderable { |
20 static const tag = const Tag<SentinelViewElement>('sentinel-view', | 19 static const tag = |
21 dependencies: const [ | 20 const Tag<SentinelViewElement>('sentinel-view', dependencies: const [ |
22 NavTopMenuElement.tag, | 21 NavTopMenuElement.tag, |
23 NavVMMenuElement.tag, | 22 NavVMMenuElement.tag, |
24 NavIsolateMenuElement.tag, | 23 NavIsolateMenuElement.tag, |
25 NavNotifyElement.tag, | 24 NavNotifyElement.tag, |
26 ViewFooterElement.tag | 25 ViewFooterElement.tag |
27 ]); | 26 ]); |
28 | 27 |
29 RenderingScheduler<SentinelViewElement> _r; | 28 RenderingScheduler<SentinelViewElement> _r; |
30 | 29 |
31 Stream<RenderedEvent<SentinelViewElement>> get onRendered => _r.onRendered; | 30 Stream<RenderedEvent<SentinelViewElement>> get onRendered => _r.onRendered; |
32 | 31 |
33 M.VM _vm; | 32 M.VM _vm; |
34 M.IsolateRef _isolate; | 33 M.IsolateRef _isolate; |
35 M.Sentinel _sentinel; | 34 M.Sentinel _sentinel; |
36 M.EventRepository _events; | 35 M.EventRepository _events; |
37 M.NotificationRepository _notifications; | 36 M.NotificationRepository _notifications; |
38 | 37 |
39 M.Sentinel get sentinel => _sentinel; | 38 M.Sentinel get sentinel => _sentinel; |
40 | 39 |
41 factory SentinelViewElement(M.VM vm, M.IsolateRef isolate, M.Sentinel sentinel
, | 40 factory SentinelViewElement( |
42 M.EventRepository events, | 41 M.VM vm, |
43 M.NotificationRepository notifications, | 42 M.IsolateRef isolate, |
44 {RenderingQueue queue}) { | 43 M.Sentinel sentinel, |
| 44 M.EventRepository events, |
| 45 M.NotificationRepository notifications, |
| 46 {RenderingQueue queue}) { |
45 assert(vm != null); | 47 assert(vm != null); |
46 assert(isolate != null); | 48 assert(isolate != null); |
47 assert(sentinel != null); | 49 assert(sentinel != null); |
48 assert(events != null); | 50 assert(events != null); |
49 assert(notifications != null); | 51 assert(notifications != null); |
50 SentinelViewElement e = document.createElement(tag.name); | 52 SentinelViewElement e = document.createElement(tag.name); |
51 e._r = new RenderingScheduler(e, queue: queue); | 53 e._r = new RenderingScheduler(e, queue: queue); |
52 e._vm = vm; | 54 e._vm = vm; |
53 e._isolate = isolate; | 55 e._isolate = isolate; |
54 e._sentinel = sentinel; | 56 e._sentinel = sentinel; |
(...skipping 20 matching lines...) Expand all Loading... |
75 | 77 |
76 void render() { | 78 void render() { |
77 children = [ | 79 children = [ |
78 navBar([ | 80 navBar([ |
79 new NavTopMenuElement(queue: _r.queue), | 81 new NavTopMenuElement(queue: _r.queue), |
80 new NavVMMenuElement(_vm, _events, queue: _r.queue), | 82 new NavVMMenuElement(_vm, _events, queue: _r.queue), |
81 new NavIsolateMenuElement(_isolate, _events, queue: _r.queue), | 83 new NavIsolateMenuElement(_isolate, _events, queue: _r.queue), |
82 navMenu('sentinel'), | 84 navMenu('sentinel'), |
83 new NavNotifyElement(_notifications, queue: _r.queue) | 85 new NavNotifyElement(_notifications, queue: _r.queue) |
84 ]), | 86 ]), |
85 new DivElement()..classes = ['content-centered-big'] | 87 new DivElement() |
| 88 ..classes = ['content-centered-big'] |
86 ..children = [ | 89 ..children = [ |
87 new HeadingElement.h2() | 90 new HeadingElement.h2() |
88 ..text = 'Sentinel: #{_sentinel.valueAsString}', | 91 ..text = 'Sentinel: #{_sentinel.valueAsString}', |
89 new HRElement(), | 92 new HRElement(), |
90 new DivElement() | 93 new DivElement()..text = _sentinelKindToDescription(_sentinel.kind), |
91 ..text = _sentinelKindToDescription(_sentinel.kind), | |
92 new HRElement(), | 94 new HRElement(), |
93 new ViewFooterElement(queue: _r.queue) | 95 new ViewFooterElement(queue: _r.queue) |
94 ] | 96 ] |
95 ]; | 97 ]; |
96 } | 98 } |
97 | 99 |
98 static String _sentinelKindToDescription(M.SentinelKind kind) { | 100 static String _sentinelKindToDescription(M.SentinelKind kind) { |
99 switch (kind) { | 101 switch (kind) { |
100 case M.SentinelKind.collected: | 102 case M.SentinelKind.collected: |
101 return 'This object has been reclaimed by the garbage collector.'; | 103 return 'This object has been reclaimed by the garbage collector.'; |
102 case M.SentinelKind.expired: | 104 case M.SentinelKind.expired: |
103 return 'The handle to this object has expired. ' | 105 return 'The handle to this object has expired. ' |
104 'Consider refreshing the page.'; | 106 'Consider refreshing the page.'; |
105 case M.SentinelKind.notInitialized: | 107 case M.SentinelKind.notInitialized: |
106 return 'This object will be initialized once it is accessed by ' | 108 return 'This object will be initialized once it is accessed by ' |
107 'the program.'; | 109 'the program.'; |
108 case M.SentinelKind.initializing: | 110 case M.SentinelKind.initializing: |
109 return 'This object is currently being initialized.'; | 111 return 'This object is currently being initialized.'; |
110 case M.SentinelKind.optimizedOut: | 112 case M.SentinelKind.optimizedOut: |
111 return 'This object is no longer needed and has been removed by the ' | 113 return 'This object is no longer needed and has been removed by the ' |
112 'optimizing compiler.'; | 114 'optimizing compiler.'; |
113 case M.SentinelKind.free: | 115 case M.SentinelKind.free: |
114 return ''; | 116 return ''; |
115 } | 117 } |
116 throw new Exception('Unknown SentinelKind: $kind'); | 118 throw new Exception('Unknown SentinelKind: $kind'); |
117 } | 119 } |
118 | |
119 } | 120 } |
OLD | NEW |