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

Side by Side Diff: runtime/bin/vmservice/client/lib/src/elements/observatory_element.dart

Issue 443713004: Rename vmservice/client to vmservice/observatory to match package name. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 | Annotate | Revision Log
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 library observatory_element;
6
7 import 'dart:async';
8 import 'dart:html';
9 import 'package:observatory/app.dart';
10 import 'package:polymer/polymer.dart';
11
12 /// Base class for all Observatory custom elements.
13 @CustomTag('observatory-element')
14 class ObservatoryElement extends PolymerElement {
15 ObservatoryElement.created() : super.created();
16
17 ObservatoryApplication get app => ObservatoryApplication.app;
18 Page get page => app.currentPage;
19 ObservableMap get args => page.args;
20
21 @override
22 void attached() {
23 super.attached();
24 _startPoll();
25 }
26
27 @override
28 void attributeChanged(String name, var oldValue, var newValue) {
29 super.attributeChanged(name, oldValue, newValue);
30 }
31
32 @override
33 void detached() {
34 super.detached();
35 _stopPoll();
36 }
37
38 @override
39 void ready() {
40 super.ready();
41 }
42
43 /// Set to a non-null value to enable polling on this element. When the poll
44 /// timer fires, onPoll will be called.
45 @observable Duration pollPeriod;
46 Timer _pollTimer;
47
48 /// Called every [pollPeriod] while the element is attached to the DOM.
49 void onPoll() { }
50
51 void pollPeriodChanged(oldValue) {
52 if (pollPeriod != null) {
53 _startPoll();
54 } else {
55 _stopPoll();
56 }
57 }
58
59 void _startPoll() {
60 if (pollPeriod == null) {
61 return;
62 }
63 if (_pollTimer != null) {
64 _pollTimer.cancel();
65 }
66 _pollTimer = new Timer(pollPeriod, _onPoll);
67 }
68
69 void _stopPoll() {
70 if (_pollTimer != null) {
71 _pollTimer.cancel();
72 }
73 _pollTimer = null;
74 }
75
76 void _onPoll() {
77 onPoll();
78 if (pollPeriod == null) {
79 // Stop polling.
80 _stopPoll();
81 return;
82 }
83 // Restart timer.
84 _pollTimer = new Timer(pollPeriod, _onPoll);
85 }
86
87 /// Utility method for handling on-click of <a> tags. Navigates
88 /// within the application using the [LocationManager].
89 void goto(MouseEvent event, var detail, Element target) {
90 app.locationManager.onGoto(event, detail, target);
91 }
92
93 /// Create a link that can be consumed by [goto].
94 String gotoLink(String url) {
95 return app.locationManager.makeLink(url);
96 }
97
98 String formatTimePrecise(double time) => Utils.formatTimePrecise(time);
99
100 String formatTime(double time) => Utils.formatTime(time);
101
102 String formatSeconds(double x) => Utils.formatSeconds(x);
103
104
105 String formatSize(int bytes) => Utils.formatSize(bytes);
106
107 String fileAndLine(Map frame) {
108 var file = frame['script']['user_name'];
109 var shortFile = file.substring(file.lastIndexOf('/') + 1);
110 return "${shortFile}:${frame['line']}";
111 }
112
113 int parseInt(String value) => int.parse(value);
114
115 bool isNull(String type) {
116 return type == 'Null';
117 }
118
119 bool isError(String type) {
120 return type == 'Error';
121 }
122
123 bool isInt(String type) {
124 return (type == 'Smi' ||
125 type == 'Mint' ||
126 type == 'Bigint');
127 }
128
129 bool isBool(String type) {
130 return type == 'Bool';
131 }
132
133 bool isString(String type) {
134 return type == 'String';
135 }
136
137 bool isInstance(String type) {
138 return type == 'Instance';
139 }
140
141 bool isDouble(String type) {
142 return type == 'Double';
143 }
144
145 bool isList(String type) {
146 return (type == 'GrowableObjectArray' ||
147 type == 'Array');
148 }
149
150 bool isType(String type) {
151 return (type == 'Type');
152 }
153
154 bool isUnexpected(String type) {
155 return (!['Null',
156 'Smi',
157 'Mint',
158 'Bigint',
159 'Bool',
160 'String',
161 'Double',
162 'Instance',
163 'GrowableObjectArray',
164 'Array',
165 'Type',
166 'Error'].contains(type));
167 }
168 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698