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

Unified 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 side-by-side diff with in-line comments
Download patch
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..12be9219d945af19518b4c8cd3c43610a7eb164b
--- /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.beingInitialized:
+ 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');
+ }
+
+}

Powered by Google App Engine
This is Rietveld 408576698