| Index: runtime/observatory/lib/src/elements/sentinel_value.dart
|
| diff --git a/runtime/observatory/lib/src/elements/sentinel_value.dart b/runtime/observatory/lib/src/elements/sentinel_value.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..70f648973c9eb93fbabf7df86d5f9cc18a992c26
|
| --- /dev/null
|
| +++ b/runtime/observatory/lib/src/elements/sentinel_value.dart
|
| @@ -0,0 +1,72 @@
|
| +// 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 show Sentinel, SentinelKind;
|
| +import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
|
| +import 'package:observatory/src/elements/helpers/tag.dart';
|
| +
|
| +class SentinelValueElement extends HtmlElement implements Renderable {
|
| + static const tag = const Tag<SentinelValueElement>('sentinel-value');
|
| +
|
| + RenderingScheduler<SentinelValueElement> _r;
|
| +
|
| + Stream<RenderedEvent<SentinelValueElement>> get onRendered => _r.onRendered;
|
| +
|
| + M.Sentinel _sentinel;
|
| +
|
| + M.Sentinel get sentinel => _sentinel;
|
| +
|
| + factory SentinelValueElement(M.Sentinel sentinel, {RenderingQueue queue}) {
|
| + assert(sentinel != null);
|
| + SentinelValueElement e = document.createElement(tag.name);
|
| + e._r = new RenderingScheduler(e, queue: queue);
|
| + e._sentinel = sentinel;
|
| + return e;
|
| + }
|
| +
|
| + SentinelValueElement.created() : super.created();
|
| +
|
| + @override
|
| + void attached() {
|
| + super.attached();
|
| + _r.enable();
|
| + }
|
| +
|
| + @override
|
| + void detached() {
|
| + super.detached();
|
| + _r.disable(notify: true);
|
| + text = '';
|
| + title = '';
|
| + }
|
| +
|
| + void render() {
|
| + text = _sentinel.valueAsString;
|
| + title = _sentinelKindToDescription(_sentinel.kind);
|
| + }
|
| +
|
| + 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');
|
| + }
|
| +
|
| +}
|
|
|