Chromium Code Reviews| 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 b37eda2750e780e3f455058d31e1ac72e8ce0386..523ecee80e02403a5564ed6c2cfb1852c34969db 100644 | 
| --- a/runtime/observatory/lib/src/app/application.dart | 
| +++ b/runtime/observatory/lib/src/app/application.dart | 
| @@ -9,6 +9,7 @@ part of app; | 
| 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; | 
| @@ -17,7 +18,7 @@ class ObservatoryApplication extends Observable { | 
| VM _vm; | 
| VM get vm => _vm; | 
| - set vm(VM vm) { | 
| + _setVM(VM vm) { | 
| if (_vm == vm) { | 
| // Do nothing. | 
| return; | 
| @@ -31,10 +32,7 @@ class ObservatoryApplication extends Observable { | 
| Logger.root.info('Registering new VM callbacks'); | 
| vm.onConnect.then((_) { | 
| - if (vm is WebSocketVM) { | 
| - targets.add(vm.target); | 
| - } | 
| - notifications.deleteDisconnectEvents(); | 
| + _removeDisconnectEvents(); | 
| }); | 
| vm.onDisconnect.then((String reason) { | 
| @@ -52,7 +50,6 @@ class ObservatoryApplication extends Observable { | 
| } | 
| _vm = vm; | 
| } | 
| - final TargetManager targets; | 
| @reflectable final ObservatoryApplicationElement rootElement; | 
| TraceViewElement _traceView = null; | 
| @@ -68,6 +65,19 @@ class ObservatoryApplication extends Observable { | 
| locationManager._visit(); | 
| } | 
| + void removePauseEvents(Isolate isolate) { | 
| 
 
Cutch
2016/07/25 20:26:22
This could be made much more efficient by moving t
 
cbernaschina
2016/07/25 20:36:25
It was already been fixed with nav-notify.
Merge h
 
 | 
| + 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) { | 
| assert(event.kind != ServiceEvent.kNone); | 
| @@ -89,7 +99,7 @@ class ObservatoryApplication extends Observable { | 
| case ServiceEvent.kIsolateExit: | 
| case ServiceEvent.kResume: | 
| - notifications.deletePauseEvents(isolate: event.isolate); | 
| + removePauseEvents(event.isolate); | 
| break; | 
| case ServiceEvent.kPauseStart: | 
| @@ -97,7 +107,7 @@ class ObservatoryApplication extends Observable { | 
| case ServiceEvent.kPauseBreakpoint: | 
| case ServiceEvent.kPauseInterrupted: | 
| case ServiceEvent.kPauseException: | 
| - notifications.deletePauseEvents(isolate: event.isolate); | 
| + removePauseEvents(event.isolate); | 
| notifications.add(new EventNotification.fromServiceEvent(event)); | 
| break; | 
| @@ -194,15 +204,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() { | 
| + var remove = notifications.list().where((notification) { | 
| 
 
Cutch
2016/07/26 14:47:53
this still isn't using removeWhere
 
cbernaschina
2016/07/26 20:02:35
Done.
 
 | 
| + 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'); | 
| } |