| 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 extends Observable { | 9 class ObservatoryApplication extends Observable { |
| 10 static ObservatoryApplication app; | 10 static ObservatoryApplication app; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 void _initOnce(bool chromium) { | 45 void _initOnce(bool chromium) { |
| 46 assert(app == null); | 46 assert(app == null); |
| 47 app = this; | 47 app = this; |
| 48 _registerPages(); | 48 _registerPages(); |
| 49 locationManager._init(this); | 49 locationManager._init(this); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void removePauseEvents(Isolate isolate) { | 52 void removePauseEvents(Isolate isolate) { |
| 53 bool isPauseEvent(var event) { | 53 bool isPauseEvent(var event) { |
| 54 return (event.eventType == 'IsolateInterrupted' || | 54 return (event.eventType == ServiceEvent.kPauseStart || |
| 55 event.eventType == 'BreakpointReached' || | 55 event.eventType == ServiceEvent.kPauseExit || |
| 56 event.eventType == 'ExceptionThrown'); | 56 event.eventType == ServiceEvent.kPauseBreakpoint || |
| 57 event.eventType == ServiceEvent.kPauseInterrupted || |
| 58 event.eventType == ServiceEvent.kPauseException); |
| 57 } | 59 } |
| 58 | 60 |
| 59 notifications.removeWhere((oldEvent) { | 61 notifications.removeWhere((oldEvent) { |
| 60 return (oldEvent.isolate == isolate && | 62 return (oldEvent.isolate == isolate && |
| 61 isPauseEvent(oldEvent)); | 63 isPauseEvent(oldEvent)); |
| 62 }); | 64 }); |
| 63 } | 65 } |
| 64 | 66 |
| 65 void _onEvent(ServiceEvent event) { | 67 void _onEvent(ServiceEvent event) { |
| 66 switch(event.eventType) { | 68 switch(event.eventType) { |
| 67 case 'IsolateCreated': | 69 case ServiceEvent.kIsolateStart: |
| 70 case ServiceEvent.kGraph: |
| 71 case ServiceEvent.kBreakpointAdded: |
| 72 case ServiceEvent.kBreakpointResolved: |
| 73 case ServiceEvent.kBreakpointRemoved: |
| 74 case ServiceEvent.kGC: |
| 68 // Ignore for now. | 75 // Ignore for now. |
| 69 break; | 76 break; |
| 70 | 77 |
| 71 case 'IsolateResumed': | 78 case ServiceEvent.kIsolateExit: |
| 72 event.isolate.pauseEvent = null; | 79 case ServiceEvent.kResume: |
| 80 removePauseEvents(event.isolate); |
| 73 break; | 81 break; |
| 74 | 82 |
| 75 case 'IsolateShutdown': | 83 case ServiceEvent.kPauseStart: |
| 76 // TODO(turnidge): Should we show the user isolate shutdown events? | 84 case ServiceEvent.kPauseExit: |
| 77 // What if there are hundreds of them? Coalesce multiple | 85 case ServiceEvent.kPauseBreakpoint: |
| 78 // shutdown events into one notification? | 86 case ServiceEvent.kPauseInterrupted: |
| 79 removePauseEvents(event.isolate); | 87 case ServiceEvent.kPauseException: |
| 80 | |
| 81 // TODO(turnidge): Reload the isolate for now in case it is | |
| 82 // paused. We may need to distinguish an IsolateShutdown | |
| 83 // event from a "paused at isolate shutdown" event. | |
| 84 event.isolate.reload(); | |
| 85 break; | |
| 86 | |
| 87 case 'BreakpointResolved': | |
| 88 event.isolate.reloadBreakpoints(); | |
| 89 break; | |
| 90 | |
| 91 case 'BreakpointReached': | |
| 92 case 'IsolateInterrupted': | |
| 93 case 'ExceptionThrown': | |
| 94 event.isolate.pauseEvent = event; | |
| 95 removePauseEvents(event.isolate); | 88 removePauseEvents(event.isolate); |
| 96 notifications.add(event); | 89 notifications.add(event); |
| 97 break; | 90 break; |
| 98 | 91 |
| 99 case '_Graph': | |
| 100 event.isolate.loadHeapSnapshot(event); | |
| 101 break; | |
| 102 | |
| 103 case 'GC': | |
| 104 // Ignore GC events for now. | |
| 105 break; | |
| 106 | |
| 107 default: | 92 default: |
| 108 // Ignore unrecognized events. | 93 // Ignore unrecognized events. |
| 109 Logger.root.severe('Unrecognized event: $event'); | 94 Logger.root.severe('Unrecognized event: $event'); |
| 110 break; | 95 break; |
| 111 } | 96 } |
| 112 } | 97 } |
| 113 | 98 |
| 114 void _registerPages() { | 99 void _registerPages() { |
| 115 _pageRegistry.add(new VMPage(this)); | 100 _pageRegistry.add(new VMPage(this)); |
| 116 _pageRegistry.add(new FlagsPage(this)); | 101 _pageRegistry.add(new FlagsPage(this)); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 195 |
| 211 ObservatoryApplication(this.rootElement) : | 196 ObservatoryApplication(this.rootElement) : |
| 212 locationManager = new HashLocationManager(), | 197 locationManager = new HashLocationManager(), |
| 213 targets = new TargetManager() { | 198 targets = new TargetManager() { |
| 214 vm = new WebSocketVM(targets.defaultTarget); | 199 vm = new WebSocketVM(targets.defaultTarget); |
| 215 _initOnce(false); | 200 _initOnce(false); |
| 216 } | 201 } |
| 217 | 202 |
| 218 void _removeDisconnectEvents() { | 203 void _removeDisconnectEvents() { |
| 219 notifications.removeWhere((oldEvent) { | 204 notifications.removeWhere((oldEvent) { |
| 220 return (oldEvent.eventType == 'VMDisconnected'); | 205 return (oldEvent.eventType == ServiceEvent.kVMDisconnected); |
| 221 }); | 206 }); |
| 222 } | 207 } |
| 223 | 208 |
| 224 _vmConnected(VM vm) { | 209 _vmConnected(VM vm) { |
| 225 if (vm is WebSocketVM) { | 210 if (vm is WebSocketVM) { |
| 226 targets.add(vm.target); | 211 targets.add(vm.target); |
| 227 } | 212 } |
| 228 _removeDisconnectEvents(); | 213 _removeDisconnectEvents(); |
| 229 } | 214 } |
| 230 | 215 |
| 231 _vmDisconnected(VM vm) { | 216 _vmDisconnected(VM vm) { |
| 232 if (this.vm != vm) { | 217 if (this.vm != vm) { |
| 233 // This disconnect event occured *after* a new VM was installed. | 218 // This disconnect event occured *after* a new VM was installed. |
| 234 return; | 219 return; |
| 235 } | 220 } |
| 236 this.vm = null; | 221 this.vm = null; |
| 237 notifications.add(new ServiceEvent.vmDisconencted()); | 222 notifications.add(new ServiceEvent.vmDisconencted()); |
| 238 } | 223 } |
| 239 } | 224 } |
| OLD | NEW |