Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: runtime/observatory/lib/src/app/application.dart

Issue 2255613002: Converted Observatory heap-profile element (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Better sorting tests Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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;
11 final RenderingQueue queue = new RenderingQueue(); 11 final RenderingQueue queue = new RenderingQueue();
12 final TargetRepository targets = new TargetRepository(); 12 final TargetRepository targets = new TargetRepository();
13 final EventRepository events = new EventRepository(); 13 final EventRepository events = new EventRepository();
14 final NotificationRepository notifications = new NotificationRepository(); 14 final NotificationRepository notifications = new NotificationRepository();
15 final _pageRegistry = new List<Page>(); 15 final _pageRegistry = new List<Page>();
16 LocationManager _locationManager; 16 LocationManager _locationManager;
17 LocationManager get locationManager => _locationManager; 17 LocationManager get locationManager => _locationManager;
18 @observable Page currentPage; 18 @observable Page currentPage;
19 VM _vm; 19 VM _vm;
20 VM get vm => _vm; 20 VM get vm => _vm;
21 21
22 _setVM(VM vm) { 22 _setVM(VM vm) {
23 if (_vm == vm) { 23 if (_vm == vm) {
24 // Do nothing. 24 // Do nothing.
25 return; 25 return;
26 } 26 }
27 if (_vm != null) { 27 if (_vm != null) {
28 _gcSubscription = null;
28 // Disconnect from current VM. 29 // Disconnect from current VM.
29 notifications.deleteAll(); 30 notifications.deleteAll();
30 _vm.disconnect(); 31 _vm.disconnect();
31 } 32 }
32 if (vm != null) { 33 if (vm != null) {
33 Logger.root.info('Registering new VM callbacks'); 34 Logger.root.info('Registering new VM callbacks');
34 35
35 vm.onConnect.then((_) { 36 vm.onConnect.then((_) {
36 notifications.deleteDisconnectEvents(); 37 notifications.deleteDisconnectEvents();
37 }); 38 });
38 39
39 vm.onDisconnect.then((String reason) { 40 vm.onDisconnect.then((String reason) {
40 if (this.vm != vm) { 41 if (this.vm != vm) {
41 // This disconnect event occured *after* a new VM was installed. 42 // This disconnect event occured *after* a new VM was installed.
42 return; 43 return;
43 } 44 }
44 events.add(new ConnectionClosedEvent(new DateTime.now(), reason)); 45 events.add(new ConnectionClosedEvent(new DateTime.now(), reason));
45 }); 46 });
46 47
47 // TODO(cbernaschina) smart connection of streams in the events object. 48 // TODO(cbernaschina) smart connection of streams in the events object.
48 vm.listenEventStream(VM.kVMStream, _onEvent); 49 vm.listenEventStream(VM.kVMStream, _onEvent);
49 vm.listenEventStream(VM.kIsolateStream, _onEvent); 50 vm.listenEventStream(VM.kIsolateStream, _onEvent);
50 vm.listenEventStream(VM.kDebugStream, _onEvent); 51 vm.listenEventStream(VM.kDebugStream, _onEvent);
51 } 52 }
52 _vm = vm; 53 _vm = vm;
53 } 54 }
55
56 StreamSubscription _gcSubscription;
57
58 Future startGCEventListener() async {
59 if (_gcSubscription != null || _vm == null) {
60 return;
61 }
62 _gcSubscription = await _vm.listenEventStream(VM.kGCStream, _onEvent);
63 }
64
65 Future stopGCEventListener() async {
66 if (_gcSubscription == null) {
67 return;
68 }
69 _gcSubscription.cancel();
70 _gcSubscription = null;
71 }
72
73
54 @reflectable final ObservatoryApplicationElement rootElement; 74 @reflectable final ObservatoryApplicationElement rootElement;
55 75
56 TraceViewElement _traceView = null; 76 TraceViewElement _traceView = null;
57 77
58 @reflectable ServiceObject lastErrorOrException; 78 @reflectable ServiceObject lastErrorOrException;
59 79
60 void _initOnce() { 80 void _initOnce() {
61 assert(app == null); 81 assert(app == null);
62 app = this; 82 app = this;
63 _registerPages(); 83 _registerPages();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 event.topFrame, event.atAsyncSuspension); 151 event.topFrame, event.atAsyncSuspension);
132 break; 152 break;
133 case ServiceEvent.kPauseException: 153 case ServiceEvent.kPauseException:
134 e = new PauseExceptionEvent(event.timestamp, event.isolate, 154 e = new PauseExceptionEvent(event.timestamp, event.isolate,
135 event.topFrame, event.exception); 155 event.topFrame, event.exception);
136 break; 156 break;
137 case ServiceEvent.kInspect: 157 case ServiceEvent.kInspect:
138 e = new InspectEvent(event.timestamp, event.isolate, 158 e = new InspectEvent(event.timestamp, event.isolate,
139 event.inspectee); 159 event.inspectee);
140 break; 160 break;
161 case ServiceEvent.kGC:
162 e = new GCEvent(event.timestamp, event.isolate);
163 break;
141 default: 164 default:
142 // Ignore unrecognized events. 165 // Ignore unrecognized events.
143 Logger.root.severe('Unrecognized event: $event'); 166 Logger.root.severe('Unrecognized event: $event');
144 return; 167 return;
145 } 168 }
146 events.add(e); 169 events.add(e);
147 } 170 }
148 171
149 void _registerPages() { 172 void _registerPages() {
150 _pageRegistry.add(new VMPage(this)); 173 _pageRegistry.add(new VMPage(this));
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 } 294 }
272 295
273 // TODO(turnidge): Report this failure via analytics. 296 // TODO(turnidge): Report this failure via analytics.
274 Logger.root.warning('Caught exception: ${e}\n${st}'); 297 Logger.root.warning('Caught exception: ${e}\n${st}');
275 notifications.add(new ExceptionNotification(e, stacktrace: st)); 298 notifications.add(new ExceptionNotification(e, stacktrace: st));
276 } 299 }
277 300
278 // This map keeps track of which curly-blocks have been expanded by the user. 301 // This map keeps track of which curly-blocks have been expanded by the user.
279 Map<String,bool> expansions = {}; 302 Map<String,bool> expansions = {};
280 } 303 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/allocation_profile/allocation_profile.dart ('k') | runtime/observatory/lib/src/app/page.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698