Index: runtime/observatory/lib/src/app/application.dart |
diff --git a/runtime/observatory/lib/src/app/application.dart b/runtime/observatory/lib/src/app/application.dart |
index be95803660838c8257ee7db709f73860c7fa2fc8..1b25ef63a19b9ad52f3221fb990601e16f3538e0 100644 |
--- a/runtime/observatory/lib/src/app/application.dart |
+++ b/runtime/observatory/lib/src/app/application.dart |
@@ -4,19 +4,13 @@ |
part of app; |
-class Notification { |
- Notification.fromEvent(this.event); |
- Notification.fromException(this.exception, this.stacktrace); |
- |
- ServiceEvent event; |
- var exception; |
- var stacktrace; |
-} |
- |
/// The observatory application. Instances of this are created and owned |
/// by the observatory_application custom element. |
class ObservatoryApplication extends Observable { |
static ObservatoryApplication app; |
+ final RenderingQueue queue = new RenderingQueue(); |
+ final TargetRepository targets = new TargetRepository(); |
+ final NotificationRepository notifications = new NotificationRepository(); |
final _pageRegistry = new List<Page>(); |
LocationManager _locationManager; |
LocationManager get locationManager => _locationManager; |
@@ -24,23 +18,20 @@ class ObservatoryApplication extends Observable { |
VM _vm; |
VM get vm => _vm; |
- set vm(VM vm) { |
+ _setVM(VM vm) { |
if (_vm == vm) { |
// Do nothing. |
return; |
} |
if (_vm != null) { |
// Disconnect from current VM. |
- notifications.clear(); |
+ notifications.deleteAll(); |
_vm.disconnect(); |
} |
if (vm != null) { |
Logger.root.info('Registering new VM callbacks'); |
vm.onConnect.then((_) { |
- if (vm is WebSocketVM) { |
- targets.add(vm.target); |
- } |
_removeDisconnectEvents(); |
}); |
@@ -50,8 +41,8 @@ class ObservatoryApplication extends Observable { |
return; |
} |
notifications.add( |
- new Notification.fromEvent( |
- new ServiceEvent.connectionClosed(reason))); |
+ new EventNotification.fromServiceEvent( |
+ new ServiceEvent.connectionClosed(reason))); |
}); |
vm.listenEventStream(VM.kIsolateStream, _onEvent); |
@@ -59,14 +50,12 @@ class ObservatoryApplication extends Observable { |
} |
_vm = vm; |
} |
- final TargetManager targets; |
+ //final TargetManager targets; |
@reflectable final ObservatoryApplicationElement rootElement; |
TraceViewElement _traceView = null; |
@reflectable ServiceObject lastErrorOrException; |
- @observable ObservableList<Notification> notifications = |
- new ObservableList<Notification>(); |
void _initOnce() { |
assert(app == null); |
@@ -78,12 +67,16 @@ class ObservatoryApplication extends Observable { |
} |
void removePauseEvents(Isolate isolate) { |
- notifications.removeWhere((notification) { |
- var event = notification.event; |
- return (event != null && |
- event.isolate == isolate && |
- event.isPauseEvent); |
- }); |
+ var remove = notifications.list().where((notification) { |
+ var event = notification.event; |
+ return notification is M.EventNotification && |
+ notification.event is M.IsolateEvent && |
+ notification.event.isolate == isolate && |
+ M.Event.isPauseEvent(notification.event); |
+ }).toList(growable: false); |
+ remove.forEach((notification) { |
+ notifications.delete(notification); |
+ }); |
} |
void _onEvent(ServiceEvent event) { |
@@ -102,7 +95,7 @@ class ObservatoryApplication extends Observable { |
break; |
case ServiceEvent.kIsolateReload: |
- notifications.add(new Notification.fromEvent(event)); |
+ notifications.add(new EventNotification.fromServiceEvent(event)); |
break; |
case ServiceEvent.kIsolateExit: |
@@ -116,11 +109,11 @@ class ObservatoryApplication extends Observable { |
case ServiceEvent.kPauseInterrupted: |
case ServiceEvent.kPauseException: |
removePauseEvents(event.isolate); |
- notifications.add(new Notification.fromEvent(event)); |
+ notifications.add(new EventNotification.fromServiceEvent(event)); |
break; |
case ServiceEvent.kInspect: |
- notifications.add(new Notification.fromEvent(event)); |
+ notifications.add(new EventNotification.fromServiceEvent(event)); |
break; |
default: |
@@ -212,23 +205,30 @@ class ObservatoryApplication extends Observable { |
currentPage = page; |
} |
- ObservatoryApplication(this.rootElement) : |
- targets = new TargetManager() { |
+ ObservatoryApplication(this.rootElement) { |
_locationManager = new LocationManager(this); |
- vm = new WebSocketVM(targets.defaultTarget); |
+ targets.onChange.listen((e) { |
+ if (targets.current == null) return _setVM(null); |
+ if ((_vm as WebSocketVM)?.target != targets.current) { |
+ _setVM(new WebSocketVM(targets.current)); |
+ } |
+ }); |
+ _setVM(new WebSocketVM(targets.current)); |
_initOnce(); |
} |
void _removeDisconnectEvents() { |
- notifications.removeWhere((notification) { |
- var event = notification.event; |
- return (event != null && |
- event.kind == ServiceEvent.kConnectionClosed); |
- }); |
+ var remove = notifications.list().where((notification) { |
+ return notification is EventNotification && |
+ notification.event is M.ConnectionClosedEvent; |
+ }).toList(growable: false); |
+ remove.forEach((notification){ |
+ notifications.delete(notification); |
+ }); |
} |
loadCrashDump(Map crashDump) { |
- this.vm = new FakeVM(crashDump['result']); |
+ _setVM(new FakeVM(crashDump['result'])); |
app.locationManager.go('#/vm'); |
} |
@@ -242,7 +242,7 @@ class ObservatoryApplication extends Observable { |
// TODO(turnidge): Report this failure via analytics. |
Logger.root.warning('Caught exception: ${e}\n${st}'); |
- notifications.add(new Notification.fromException(e, st)); |
+ notifications.add(new ExceptionNotification(e, stacktrace: st)); |
} |
// This map keeps track of which curly-blocks have been expanded by the user. |