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..1b25ef63a19b9ad52f3221fb990601e16f3538e0 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) { |
|
Cutch
2016/07/25 13:57:15
why was this made private?
cbernaschina
2016/07/25 17:27:28
Changing the current VM without informing the rest
|
| 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,7 @@ class ObservatoryApplication extends Observable { |
| } |
| _vm = vm; |
| } |
| - final TargetManager targets; |
| + //final TargetManager targets; |
|
Cutch
2016/07/25 13:57:15
why is this commented out?
cbernaschina
2016/07/25 17:27:28
Dead code. I removed it in the last commit.
done
|
| @reflectable final ObservatoryApplicationElement rootElement; |
| TraceViewElement _traceView = null; |
| @@ -68,6 +66,19 @@ class ObservatoryApplication extends Observable { |
| locationManager._visit(); |
| } |
| + void removePauseEvents(Isolate isolate) { |
| + 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 +100,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 +108,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 +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() { |
| + 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'); |
| } |