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

Side by Side Diff: runtime/bin/vmservice/client/lib/src/service/object.dart

Issue 221263002: Miscellaneous Observatory UI improvements (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 service; 5 part of service;
6 6
7 /// A [ServiceObject] is an object known to the VM service and is tied 7 /// A [ServiceObject] is an object known to the VM service and is tied
8 /// to an owning [Isolate]. 8 /// to an owning [Isolate].
9 abstract class ServiceObject extends Observable { 9 abstract class ServiceObject extends Observable {
10 /// The owner of this [ServiceObject]. This can be an [Isolate], a 10 /// The owner of this [ServiceObject]. This can be an [Isolate], a
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 Future<ServiceObject> reload() { 106 Future<ServiceObject> reload() {
107 if (id == '') { 107 if (id == '') {
108 // Errors don't have ids. 108 // Errors don't have ids.
109 assert(serviceType == 'Error'); 109 assert(serviceType == 'Error');
110 return new Future.value(this); 110 return new Future.value(this);
111 } 111 }
112 if (loaded && immutable) { 112 if (loaded && immutable) {
113 return new Future.value(this); 113 return new Future.value(this);
114 } 114 }
115 if (_inProgressReload == null) { 115 if (_inProgressReload == null) {
116 _inProgressReload = vm.getAsMap(link).then((ObservableMap map) { 116 _inProgressReload = vm.getAsMap(link).then((ObservableMap map) {
117 var mapType = _stripRef(map['type']); 117 var mapType = _stripRef(map['type']);
118 if (mapType != _serviceType) { 118 if (mapType != _serviceType) {
119 // If the type changes, return a new object instead of 119 // If the type changes, return a new object instead of
120 // updating the existing one. 120 // updating the existing one.
121 assert(mapType == 'Error' || mapType == 'Null'); 121 assert(mapType == 'Error' || mapType == 'Null');
122 return new ServiceObject._fromMap(owner, map); 122 return new ServiceObject._fromMap(owner, map);
123 } 123 }
124 update(map); 124 update(map);
125 return this; 125 return this;
126 }).whenComplete(() { 126 }).whenComplete(() {
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 if (snapshots.length > _historySize) { 437 if (snapshots.length > _historySize) {
438 snapshots.removeAt(0); 438 snapshots.removeAt(0);
439 } 439 }
440 } 440 }
441 } 441 }
442 442
443 /// State for a running isolate. 443 /// State for a running isolate.
444 class Isolate extends ServiceObjectOwner { 444 class Isolate extends ServiceObjectOwner {
445 @reflectable VM get vm => owner; 445 @reflectable VM get vm => owner;
446 @reflectable Isolate get isolate => this; 446 @reflectable Isolate get isolate => this;
447 @observable ObservableMap counters = toObservable(new ObservableMap());
447 448
448 String get link => _id; 449 String get link => _id;
449 String get hashLink => '#/$_id'; 450 String get hashLink => '#/$_id';
450 451
451 @observable bool pausedOnStart = false; 452 @observable bool pausedOnStart = false;
452 @observable bool pausedOnExit = false; 453 @observable bool pausedOnExit = false;
453 @observable bool running = false; 454 @observable bool running = false;
454 @observable bool idle = false; 455 @observable bool idle = false;
455 456
456 Map<String,ServiceObject> _cache = new Map<String,ServiceObject>(); 457 Map<String,ServiceObject> _cache = new Map<String,ServiceObject>();
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 rootLib = map['rootLib']; 601 rootLib = map['rootLib'];
601 if (map['entry'] != null) { 602 if (map['entry'] != null) {
602 entry = map['entry']; 603 entry = map['entry'];
603 } 604 }
604 if (map['topFrame'] != null) { 605 if (map['topFrame'] != null) {
605 topFrame = map['topFrame']; 606 topFrame = map['topFrame'];
606 } else { 607 } else {
607 topFrame = null ; 608 topFrame = null ;
608 } 609 }
609 610
611 var countersMap = map['tagCounters'];
612 if (countersMap != null) {
613 var names = countersMap['names'];
614 var counts = countersMap['counters'];
615 assert(names.length == counts.length);
616 var sum = 0;
617 for (var i = 0; i < counts.length; i++) {
618 sum += counts[i];
619 }
620 // TODO: Why does this not work without this?
621 counters = toObservable({});
622 if (sum == 0) {
623 for (var i = 0; i < names.length; i++) {
624 counters[names[i]] = '0.0%';
625 }
626 } else {
627 for (var i = 0; i < names.length; i++) {
628 counters[names[i]] =
629 (counts[i] / sum * 100.0).toStringAsFixed(2) + '%';
630 }
631 }
632 }
610 var timerMap = {}; 633 var timerMap = {};
611 map['timers'].forEach((timer) { 634 map['timers'].forEach((timer) {
612 timerMap[timer['name']] = timer['time']; 635 timerMap[timer['name']] = timer['time'];
613 }); 636 });
614 timers['total'] = timerMap['time_total_runtime']; 637 timers['total'] = timerMap['time_total_runtime'];
615 timers['compile'] = timerMap['time_compilation']; 638 timers['compile'] = timerMap['time_compilation'];
616 timers['gc'] = 0.0; // TODO(turnidge): Export this from VM. 639 timers['gc'] = 0.0; // TODO(turnidge): Export this from VM.
617 timers['init'] = (timerMap['time_script_loading'] + 640 timers['init'] = (timerMap['time_script_loading'] +
618 timerMap['time_creating_snapshot'] + 641 timerMap['time_creating_snapshot'] +
619 timerMap['time_isolate_initialization'] + 642 timerMap['time_isolate_initialization'] +
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 @reflectable final int line; 834 @reflectable final int line;
812 @reflectable final String text; 835 @reflectable final String text;
813 ScriptLine(this.line, this.text); 836 ScriptLine(this.line, this.text);
814 } 837 }
815 838
816 class Script extends ServiceObject { 839 class Script extends ServiceObject {
817 @reflectable final lines = new ObservableList<ScriptLine>(); 840 @reflectable final lines = new ObservableList<ScriptLine>();
818 @reflectable final hits = new ObservableMap<int, int>(); 841 @reflectable final hits = new ObservableMap<int, int>();
819 @observable ServiceObject library; 842 @observable ServiceObject library;
820 @observable String kind; 843 @observable String kind;
844 @observable int firstTokenPos;
845 @observable int lastTokenPos;
turnidge 2014/04/01 19:42:48 I see where these are initialized, but I missed wh
Cutch 2014/04/02 18:26:52 Now that <script-view> uses <script-inset> we pass
821 846
822 bool get canCache => true; 847 bool get canCache => true;
823 bool get immutable => true; 848 bool get immutable => true;
824 849
825 String _shortUrl; 850 String _shortUrl;
826 String _url; 851 String _url;
827 852
828 Script._empty(ServiceObjectOwner owner) : super._empty(owner); 853 Script._empty(ServiceObjectOwner owner) : super._empty(owner);
829 854
830 /// This function maps a token position to a line number. 855 /// This function maps a token position to a line number.
(...skipping 13 matching lines...) Expand all
844 _processSource(map['source']); 869 _processSource(map['source']);
845 _parseTokenPosTable(map['tokenPosTable']); 870 _parseTokenPosTable(map['tokenPosTable']);
846 } 871 }
847 872
848 void _parseTokenPosTable(List<List<int>> table) { 873 void _parseTokenPosTable(List<List<int>> table) {
849 if (table == null) { 874 if (table == null) {
850 return; 875 return;
851 } 876 }
852 _tokenToLine = {}; 877 _tokenToLine = {};
853 _tokenToCol = {}; 878 _tokenToCol = {};
879 firstTokenPos = null;
854 for (var line in table) { 880 for (var line in table) {
855 // Each entry begins with a line number... 881 // Each entry begins with a line number...
856 var lineNumber = line[0]; 882 var lineNumber = line[0];
857 for (var pos = 1; pos < line.length; pos += 2) { 883 for (var pos = 1; pos < line.length; pos += 2) {
858 // ...and is followed by (token offset, col number) pairs. 884 // ...and is followed by (token offset, col number) pairs.
859 var tokenOffset = line[pos]; 885 var tokenOffset = line[pos];
860 var colNumber = line[pos+1]; 886 var colNumber = line[pos+1];
887 if (firstTokenPos == null) {
888 // Mark first token position.
turnidge 2014/04/01 19:42:48 This assumes that the line number table is provide
Cutch 2014/04/02 18:26:52 I've modified the code to track the minimum and ma
889 firstTokenPos = tokenOffset;
890 }
891 lastTokenPos = tokenOffset;
861 _tokenToLine[tokenOffset] = lineNumber; 892 _tokenToLine[tokenOffset] = lineNumber;
862 _tokenToCol[tokenOffset] = colNumber; 893 _tokenToCol[tokenOffset] = colNumber;
863 } 894 }
864 } 895 }
865 } 896 }
866 897
867 void _processHits(List scriptHits) { 898 void _processHits(List scriptHits) {
868 if (!_loaded) { 899 if (!_loaded) {
869 // Eagerly grab script source. 900 // Eagerly grab script source.
870 load(); 901 load();
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 var v = list[i]; 1239 var v = list[i];
1209 if ((v is ObservableMap) && _isServiceMap(v)) { 1240 if ((v is ObservableMap) && _isServiceMap(v)) {
1210 list[i] = owner.getFromMap(v); 1241 list[i] = owner.getFromMap(v);
1211 } else if (v is ObservableList) { 1242 } else if (v is ObservableList) {
1212 _upgradeObservableList(v, owner); 1243 _upgradeObservableList(v, owner);
1213 } else if (v is ObservableMap) { 1244 } else if (v is ObservableMap) {
1214 _upgradeObservableMap(v, owner); 1245 _upgradeObservableMap(v, owner);
1215 } 1246 }
1216 } 1247 }
1217 } 1248 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698