Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Side by Side Diff: runtime/observatory/lib/src/elements/sentinel_value.dart

Issue 2244433003: Converted Observatory refs elements (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: All element tested Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'dart:html';
6 import 'dart:async';
7 import 'package:observatory/models.dart' as M show Sentinel, SentinelKind;
8 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
9 import 'package:observatory/src/elements/helpers/tag.dart';
10
11 class SentinelValueElement extends HtmlElement implements Renderable {
12 static const tag = const Tag<SentinelValueElement>('sentinel-value');
13
14 RenderingScheduler<SentinelValueElement> _r;
15
16 Stream<RenderedEvent<SentinelValueElement>> get onRendered => _r.onRendered;
17
18 M.Sentinel _sentinel;
19
20 M.Sentinel get sentinel => _sentinel;
21
22 factory SentinelValueElement(M.Sentinel sentinel, {RenderingQueue queue}) {
23 assert(sentinel != null);
24 SentinelValueElement e = document.createElement(tag.name);
25 e._r = new RenderingScheduler(e, queue: queue);
26 e._sentinel = sentinel;
27 return e;
28 }
29
30 SentinelValueElement.created() : super.created();
31
32 @override
33 void attached() {
34 super.attached();
35 _r.enable();
36 }
37
38 @override
39 void detached() {
40 super.detached();
41 _r.disable(notify: true);
42 text = '';
43 title = '';
44 }
45
46 void render() {
47 text = _sentinel.valueAsString;
48 title = _sentinelKindToDescription(_sentinel.kind);
49 }
50
51 static String _sentinelKindToDescription(M.SentinelKind kind) {
52 switch (kind) {
53 case M.SentinelKind.collected:
54 return 'This object has been reclaimed by the garbage collector.';
55 case M.SentinelKind.expired:
56 return 'The handle to this object has expired. '
57 'Consider refreshing the page.';
58 case M.SentinelKind.notInitialized:
59 return 'This object will be initialized once it is accessed by '
60 'the program.';
61 case M.SentinelKind.beingInitialized:
62 return 'This object is currently being initialized.';
63 case M.SentinelKind.optimizedOut:
64 return 'This object is no longer needed and has been removed by the '
65 'optimizing compiler.';
66 case M.SentinelKind.free:
67 return '';
68 }
69 throw new Exception('Unknown SentinelKind: $kind');
70 }
71
72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698