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

Side by Side Diff: runtime/observatory/lib/src/app/application.dart

Issue 1093043004: Do not JSON encode the 'result' of a service rpc. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: edits Created 5 years, 8 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
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of app; 5 part of app;
6 6
7 /// The observatory application. Instances of this are created and owned 7 /// The observatory application. Instances of this are created and owned
8 /// by the observatory_application custom element. 8 /// by the observatory_application custom element.
9 class ObservatoryApplication extends Observable { 9 class ObservatoryApplication extends Observable {
10 static ObservatoryApplication app; 10 static ObservatoryApplication app;
11 final _pageRegistry = new List<Page>(); 11 final _pageRegistry = new List<Page>();
12 @observable Page currentPage; 12 @observable Page currentPage;
13 @observable final LocationManager locationManager; 13 @observable final LocationManager locationManager;
14 VM _vm; 14 VM _vm;
15 VM get vm => _vm; 15 VM get vm => _vm;
16 set vm(VM vm) { 16 set vm(VM vm) {
17 if (_vm == vm) { 17 if (_vm == vm) {
18 // Do nothing. 18 // Do nothing.
19 return; 19 return;
20 } 20 }
21 if (_vm != null) { 21 if (_vm != null) {
22 // Disconnect from current VM. 22 // Disconnect from current VM.
23 notifications.clear(); 23 notifications.clear();
24 _vm.disconnect(); 24 _vm.disconnect();
25 } 25 }
26 if (vm != null) { 26 if (vm != null) {
27 Logger.root.info('Registering new VM callbacks'); 27 Logger.root.info('Registering new VM callbacks');
28 vm.onConnect.then(_vmConnected); 28
29 vm.onDisconnect.then(_vmDisconnected); 29 vm.onConnect.then((_) {
30 if (vm is WebSocketVM) {
31 targets.add(vm.target);
32 }
33 _removeDisconnectEvents();
34 });
35
36 vm.onDisconnect.then((String reason) {
37 if (this.vm != vm) {
38 // This disconnect event occured *after* a new VM was installed.
39 return;
40 }
41 notifications.add(new ServiceEvent.connectionClosed(reason));
42 });
43
30 vm.errors.stream.listen(_onError); 44 vm.errors.stream.listen(_onError);
31 vm.events.stream.listen(_onEvent); 45 vm.events.stream.listen(_onEvent);
32 vm.exceptions.stream.listen(_onException); 46 vm.exceptions.stream.listen(_onException);
33 } 47 }
34 _vm = vm; 48 _vm = vm;
35 } 49 }
36 final TargetManager targets; 50 final TargetManager targets;
37 @reflectable final ObservatoryApplicationElement rootElement; 51 @reflectable final ObservatoryApplicationElement rootElement;
38 52
39 TraceViewElement _traceView = null; 53 TraceViewElement _traceView = null;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 211
198 ObservatoryApplication(this.rootElement) : 212 ObservatoryApplication(this.rootElement) :
199 locationManager = new HashLocationManager(), 213 locationManager = new HashLocationManager(),
200 targets = new TargetManager() { 214 targets = new TargetManager() {
201 vm = new WebSocketVM(targets.defaultTarget); 215 vm = new WebSocketVM(targets.defaultTarget);
202 _initOnce(false); 216 _initOnce(false);
203 } 217 }
204 218
205 void _removeDisconnectEvents() { 219 void _removeDisconnectEvents() {
206 notifications.removeWhere((oldEvent) { 220 notifications.removeWhere((oldEvent) {
207 return (oldEvent.eventType == ServiceEvent.kVMDisconnected); 221 return (oldEvent.eventType == ServiceEvent.kConnectionClosed);
208 }); 222 });
209 } 223 }
210
211 _vmConnected(VM vm) {
212 if (vm is WebSocketVM) {
213 targets.add(vm.target);
214 }
215 _removeDisconnectEvents();
216 }
217
218 _vmDisconnected(VM vm) {
219 if (this.vm != vm) {
220 // This disconnect event occured *after* a new VM was installed.
221 return;
222 }
223 this.vm = null;
224 notifications.add(new ServiceEvent.vmDisconencted());
225 }
226 } 224 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698