OLD | NEW |
| (Empty) |
1 // Copyright (c) 2014, 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 io_view_element; | |
6 | |
7 import 'dart:async'; | |
8 import 'observatory_element.dart'; | |
9 import 'service_ref.dart'; | |
10 import 'package:observatory/service.dart'; | |
11 import 'package:polymer/polymer.dart'; | |
12 | |
13 @CustomTag('io-view') | |
14 class IOViewElement extends ObservatoryElement { | |
15 @published ServiceMap io; | |
16 | |
17 IOViewElement.created() : super.created(); | |
18 | |
19 void refresh(var done) { | |
20 io.reload().whenComplete(done); | |
21 } | |
22 } | |
23 | |
24 @CustomTag('io-ref') | |
25 class IORefElement extends ServiceRefElement { | |
26 IORefElement.created() : super.created(); | |
27 } | |
28 | |
29 @CustomTag('io-http-server-list-view') | |
30 class IOHttpServerListViewElement extends ObservatoryElement { | |
31 @published ServiceMap list; | |
32 | |
33 IOHttpServerListViewElement.created() : super.created(); | |
34 | |
35 void refresh(var done) { | |
36 list.reload().whenComplete(done); | |
37 } | |
38 } | |
39 | |
40 @CustomTag('io-http-server-ref') | |
41 class IOHttpServerRefElement extends ServiceRefElement { | |
42 IOHttpServerRefElement.created() : super.created(); | |
43 } | |
44 | |
45 @CustomTag('io-http-server-view') | |
46 class IOHttpServerViewElement extends ObservatoryElement { | |
47 // TODO(ajohnsen): Create a HttpServer object. | |
48 @published ServiceMap httpServer; | |
49 Timer _updateTimer; | |
50 | |
51 IOHttpServerViewElement.created() : super.created(); | |
52 | |
53 void refresh(var done) { | |
54 httpServer.reload().whenComplete(done); | |
55 } | |
56 | |
57 void _updateHttpServer() { | |
58 refresh(() { | |
59 if (_updateTimer != null) { | |
60 _updateTimer = new Timer(new Duration(seconds: 1), _updateHttpServer); | |
61 } | |
62 }); | |
63 } | |
64 | |
65 @override | |
66 void attached() { | |
67 super.attached(); | |
68 // Start a timer to update the isolate summary once a second. | |
69 _updateTimer = new Timer(new Duration(seconds: 1), _updateHttpServer); | |
70 } | |
71 | |
72 @override | |
73 void detached() { | |
74 super.detached(); | |
75 if (_updateTimer != null) { | |
76 _updateTimer.cancel(); | |
77 _updateTimer = null; | |
78 } | |
79 } | |
80 } | |
81 | |
82 @CustomTag('io-http-server-connection-view') | |
83 class IOHttpServerConnectionViewElement extends ObservatoryElement { | |
84 @published ServiceMap connection; | |
85 Timer _updateTimer; | |
86 | |
87 IOHttpServerConnectionViewElement.created() : super.created(); | |
88 | |
89 void refresh(var done) { | |
90 connection.reload().whenComplete(done); | |
91 } | |
92 | |
93 void _updateHttpServer() { | |
94 refresh(() { | |
95 if (_updateTimer != null) { | |
96 _updateTimer = new Timer(new Duration(seconds: 1), _updateHttpServer); | |
97 } | |
98 }); | |
99 } | |
100 | |
101 @override | |
102 void attached() { | |
103 super.attached(); | |
104 // Start a timer to update the isolate summary once a second. | |
105 _updateTimer = new Timer(new Duration(seconds: 1), _updateHttpServer); | |
106 } | |
107 | |
108 @override | |
109 void detached() { | |
110 super.detached(); | |
111 if (_updateTimer != null) { | |
112 _updateTimer.cancel(); | |
113 _updateTimer = null; | |
114 } | |
115 } | |
116 } | |
117 | |
118 @CustomTag('io-http-server-connection-ref') | |
119 class IOHttpServerConnectionRefElement extends ServiceRefElement { | |
120 IOHttpServerConnectionRefElement.created() : super.created(); | |
121 } | |
122 | |
123 @CustomTag('io-socket-ref') | |
124 class IOSocketRefElement extends ServiceRefElement { | |
125 IOSocketRefElement.created() : super.created(); | |
126 } | |
127 | |
128 @CustomTag('io-socket-list-view') | |
129 class IOSocketListViewElement extends ObservatoryElement { | |
130 @published ServiceMap list; | |
131 | |
132 IOSocketListViewElement.created() : super.created(); | |
133 | |
134 void refresh(var done) { | |
135 list.reload().whenComplete(done); | |
136 } | |
137 } | |
138 | |
139 @CustomTag('io-socket-view') | |
140 class IOSocketViewElement extends ObservatoryElement { | |
141 @published Socket socket; | |
142 | |
143 IOSocketViewElement.created() : super.created(); | |
144 | |
145 void refresh(var done) { | |
146 socket.reload().whenComplete(done); | |
147 } | |
148 } | |
149 | |
150 @CustomTag('io-web-socket-ref') | |
151 class IOWebSocketRefElement extends ServiceRefElement { | |
152 IOWebSocketRefElement.created() : super.created(); | |
153 } | |
154 | |
155 @CustomTag('io-web-socket-list-view') | |
156 class IOWebSocketListViewElement extends ObservatoryElement { | |
157 @published ServiceMap list; | |
158 | |
159 IOWebSocketListViewElement.created() : super.created(); | |
160 | |
161 void refresh(var done) { | |
162 list.reload().whenComplete(done); | |
163 } | |
164 } | |
165 | |
166 @CustomTag('io-web-socket-view') | |
167 class IOWebSocketViewElement extends ObservatoryElement { | |
168 @published ServiceMap webSocket; | |
169 | |
170 IOWebSocketViewElement.created() : super.created(); | |
171 | |
172 void refresh(var done) { | |
173 webSocket.reload().whenComplete(done); | |
174 } | |
175 } | |
176 | |
177 @CustomTag('io-random-access-file-list-view') | |
178 class IORandomAccessFileListViewElement extends ObservatoryElement { | |
179 @published ServiceMap list; | |
180 | |
181 IORandomAccessFileListViewElement.created() : super.created(); | |
182 | |
183 void refresh(var done) { | |
184 list.reload().whenComplete(done); | |
185 } | |
186 } | |
187 | |
188 @CustomTag('io-random-access-file-ref') | |
189 class IORandomAccessFileRefElement extends ServiceRefElement { | |
190 IORandomAccessFileRefElement.created() : super.created(); | |
191 } | |
192 | |
193 @CustomTag('io-random-access-file-view') | |
194 class IORandomAccessFileViewElement extends ObservatoryElement { | |
195 // TODO(ajohnsen): Create a RandomAccessFile object. | |
196 @published ServiceMap file; | |
197 Timer _updateTimer; | |
198 | |
199 IORandomAccessFileViewElement.created() : super.created(); | |
200 | |
201 void refresh(var done) { | |
202 file.reload().whenComplete(done); | |
203 } | |
204 | |
205 void _updateFile() { | |
206 refresh(() { | |
207 if (_updateTimer != null) { | |
208 _updateTimer = new Timer(new Duration(seconds: 1), _updateFile); | |
209 } | |
210 }); | |
211 } | |
212 | |
213 @override | |
214 void attached() { | |
215 super.attached(); | |
216 // Start a timer to update the isolate summary once a second. | |
217 _updateTimer = new Timer(new Duration(seconds: 1), _updateFile); | |
218 } | |
219 | |
220 @override | |
221 void detached() { | |
222 super.detached(); | |
223 if (_updateTimer != null) { | |
224 _updateTimer.cancel(); | |
225 _updateTimer = null; | |
226 } | |
227 } | |
228 } | |
229 | |
230 @CustomTag('io-process-list-view') | |
231 class IOProcessListViewElement extends ObservatoryElement { | |
232 @published ServiceMap list; | |
233 | |
234 IOProcessListViewElement.created() : super.created(); | |
235 | |
236 void refresh(var done) { | |
237 list.reload().whenComplete(done); | |
238 } | |
239 } | |
240 | |
241 @CustomTag('io-process-ref') | |
242 class IOProcessRefElement extends ServiceRefElement { | |
243 // Only display the process name when small is set. | |
244 @published bool small = false; | |
245 IOProcessRefElement.created() : super.created(); | |
246 } | |
247 | |
248 @CustomTag('io-process-view') | |
249 class IOProcessViewElement extends ObservatoryElement { | |
250 // TODO(ajohnsen): Create a Process object. | |
251 @published ServiceMap process; | |
252 Timer _updateTimer; | |
253 | |
254 IOProcessViewElement.created() : super.created(); | |
255 | |
256 void refresh(var done) { | |
257 process.reload().whenComplete(done); | |
258 } | |
259 | |
260 void _updateFile() { | |
261 refresh(() { | |
262 if (_updateTimer != null) { | |
263 _updateTimer = new Timer(new Duration(seconds: 1), _updateFile); | |
264 } | |
265 }); | |
266 } | |
267 | |
268 @override | |
269 void attached() { | |
270 super.attached(); | |
271 // Start a timer to update the isolate summary once a second. | |
272 _updateTimer = new Timer(new Duration(seconds: 1), _updateFile); | |
273 } | |
274 | |
275 @override | |
276 void detached() { | |
277 super.detached(); | |
278 if (_updateTimer != null) { | |
279 _updateTimer.cancel(); | |
280 _updateTimer = null; | |
281 } | |
282 } | |
283 } | |
OLD | NEW |