| OLD | NEW |
| 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 { | 9 class ObservatoryApplication { |
| 10 static ObservatoryApplication app; | 10 static ObservatoryApplication app; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // Disconnect from current VM. | 44 // Disconnect from current VM. |
| 45 stopGCEventListener(); | 45 stopGCEventListener(); |
| 46 notifications.deleteAll(); | 46 notifications.deleteAll(); |
| 47 oldVM.disconnect(); | 47 oldVM.disconnect(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 if (newVM != null) { | 50 if (newVM != null) { |
| 51 // Mark that we haven't connected yet. | 51 // Mark that we haven't connected yet. |
| 52 _vmConnected = false; | 52 _vmConnected = false; |
| 53 // On connect: | 53 // On connect: |
| 54 newVM.onConnect.then((_) { | 54 newVM.onConnect.then((_) async { |
| 55 // We connected. | 55 // We connected. |
| 56 _vmConnected = true; | 56 _vmConnected = true; |
| 57 notifications.deleteDisconnectEvents(); | 57 notifications.deleteDisconnectEvents(); |
| 58 await newVM.load(); |
| 59 // TODO(cbernaschina) smart connection of streams in the events object. |
| 60 newVM.listenEventStream(VM.kVMStream, _onEvent); |
| 61 newVM.listenEventStream(VM.kIsolateStream, _onEvent); |
| 62 newVM.listenEventStream(VM.kDebugStream, _onEvent); |
| 63 newVM.listenEventStream(VM.kServiceStream, _onEvent); |
| 58 }); | 64 }); |
| 59 // On disconnect: | 65 // On disconnect: |
| 60 newVM.onDisconnect.then((String reason) { | 66 newVM.onDisconnect.then((String reason) { |
| 61 if (this.vm != newVM) { | 67 if (this.vm != newVM) { |
| 62 // This disconnect event occured *after* a new VM was installed. | 68 // This disconnect event occured *after* a new VM was installed. |
| 63 return; | 69 return; |
| 64 } | 70 } |
| 65 // Let anyone looking at the targets know that we have disconnected | 71 // Let anyone looking at the targets know that we have disconnected |
| 66 // from one. | 72 // from one. |
| 67 targets.emitDisconnectEvent(); | 73 targets.emitDisconnectEvent(); |
| 68 if (!_vmConnected) { | 74 if (!_vmConnected) { |
| 69 // Connection error. Navigate back to the connect page. | 75 // Connection error. Navigate back to the connect page. |
| 70 Logger.root.info('Connection failed, navigating to VM connect page.'); | 76 Logger.root.info('Connection failed, navigating to VM connect page.'); |
| 71 // Clear the vm. | 77 // Clear the vm. |
| 72 _vm = null; | 78 _vm = null; |
| 73 app.locationManager.go(Uris.vmConnect()); | 79 app.locationManager.go(Uris.vmConnect()); |
| 74 } else { | 80 } else { |
| 75 // Disconnect. Stay at the current page and push an a connection | 81 // Disconnect. Stay at the current page and push an a connection |
| 76 // closed event. | 82 // closed event. |
| 77 Logger.root.info('Lost an existing connection to a VM'); | 83 Logger.root.info('Lost an existing connection to a VM'); |
| 78 events.add(new ConnectionClosedEvent(new DateTime.now(), reason)); | 84 events.add(new ConnectionClosedEvent(new DateTime.now(), reason)); |
| 79 } | 85 } |
| 80 }); | 86 }); |
| 81 // TODO(cbernaschina) smart connection of streams in the events object. | |
| 82 newVM.listenEventStream(VM.kVMStream, _onEvent); | |
| 83 newVM.listenEventStream(VM.kIsolateStream, _onEvent); | |
| 84 newVM.listenEventStream(VM.kDebugStream, _onEvent); | |
| 85 } | 87 } |
| 86 | 88 |
| 87 _vm = newVM; | 89 _vm = newVM; |
| 88 } | 90 } |
| 89 | 91 |
| 90 StreamSubscription _gcSubscription; | 92 StreamSubscription _gcSubscription; |
| 91 StreamSubscription _loggingSubscription; | 93 StreamSubscription _loggingSubscription; |
| 92 | 94 |
| 93 Future startGCEventListener() async { | 95 Future startGCEventListener() async { |
| 94 if (_gcSubscription != null || _vm == null) { | 96 if (_gcSubscription != null || _vm == null) { |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 } | 289 } |
| 288 | 290 |
| 289 // TODO(turnidge): Report this failure via analytics. | 291 // TODO(turnidge): Report this failure via analytics. |
| 290 Logger.root.warning('Caught exception: ${e}\n${st}'); | 292 Logger.root.warning('Caught exception: ${e}\n${st}'); |
| 291 notifications.add(new ExceptionNotification(e, stacktrace: st)); | 293 notifications.add(new ExceptionNotification(e, stacktrace: st)); |
| 292 } | 294 } |
| 293 | 295 |
| 294 // This map keeps track of which curly-blocks have been expanded by the user. | 296 // This map keeps track of which curly-blocks have been expanded by the user. |
| 295 Map<String, bool> expansions = {}; | 297 Map<String, bool> expansions = {}; |
| 296 } | 298 } |
| OLD | NEW |