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

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

Issue 262303002: Observatory grab-bag for 1.4 release. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: gen js Created 6 years, 7 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
« no previous file with comments | « runtime/bin/vmservice/client/lib/src/elements/stack_trace.html ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 12 matching lines...) Expand all
23 String _id; 23 String _id;
24 24
25 /// The service type of this object. 25 /// The service type of this object.
26 @reflectable String get serviceType => _serviceType; 26 @reflectable String get serviceType => _serviceType;
27 String _serviceType; 27 String _serviceType;
28 28
29 /// The complete service url of this object. 29 /// The complete service url of this object.
30 @reflectable String get link => isolate.relativeLink(_id); 30 @reflectable String get link => isolate.relativeLink(_id);
31 31
32 /// The complete service url of this object with a '#/' prefix. 32 /// The complete service url of this object with a '#/' prefix.
33 // TODO(turnidge): Figure out why using a getter here messes up polymer.
33 @reflectable String get hashLink => '#/${link}'; 34 @reflectable String get hashLink => '#/${link}';
34 @reflectable set hashLink(var o) { /* silence polymer */ } 35 @reflectable set hashLink(var o) { /* silence polymer */ }
35 36
36 /// Has this object been fully loaded? 37 /// Has this object been fully loaded?
37 bool get loaded => _loaded; 38 bool get loaded => _loaded;
38 bool _loaded = false; 39 bool _loaded = false;
39 40
40 /// Is this object cacheable? That is, is it impossible for the [id] 41 /// Is this object cacheable? That is, is it impossible for the [id]
41 /// of this object to change? 42 /// of this object to change?
42 bool get canCache => false; 43 bool get canCache => false;
(...skipping 23 matching lines...) Expand all
66 switch (type) { 67 switch (type) {
67 case 'Code': 68 case 'Code':
68 obj = new Code._empty(owner); 69 obj = new Code._empty(owner);
69 break; 70 break;
70 case 'Error': 71 case 'Error':
71 obj = new DartError._empty(owner); 72 obj = new DartError._empty(owner);
72 break; 73 break;
73 case 'Isolate': 74 case 'Isolate':
74 obj = new Isolate._empty(owner); 75 obj = new Isolate._empty(owner);
75 break; 76 break;
77 case 'Library':
78 obj = new Library._empty(owner);
79 break;
76 case 'ServiceError': 80 case 'ServiceError':
77 obj = new ServiceError._empty(owner); 81 obj = new ServiceError._empty(owner);
78 break; 82 break;
79 case 'ServiceException': 83 case 'ServiceException':
80 obj = new ServiceException._empty(owner); 84 obj = new ServiceException._empty(owner);
81 break; 85 break;
82 case 'Script': 86 case 'Script':
83 obj = new Script._empty(owner); 87 obj = new Script._empty(owner);
84 break; 88 break;
85 default: 89 default:
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 // Cache miss. Get the object from the vm directly. 573 // Cache miss. Get the object from the vm directly.
570 return vm.getAsMap(relativeLink(id)).then((ObservableMap map) { 574 return vm.getAsMap(relativeLink(id)).then((ObservableMap map) {
571 var obj = new ServiceObject._fromMap(this, map); 575 var obj = new ServiceObject._fromMap(this, map);
572 if (obj.canCache) { 576 if (obj.canCache) {
573 _cache.putIfAbsent(id, () => obj); 577 _cache.putIfAbsent(id, () => obj);
574 } 578 }
575 return obj; 579 return obj;
576 }); 580 });
577 } 581 }
578 582
579 @observable ServiceMap rootLib; 583 @observable Library rootLib;
580 @observable ObservableList<ServiceMap> libraries = 584 @observable ObservableList<Library> libraries =
581 new ObservableList<ServiceMap>(); 585 new ObservableList<Library>();
582 @observable ObservableMap topFrame; 586 @observable ObservableMap topFrame;
583 587
584 @observable String name; 588 @observable String name;
585 @observable String vmName; 589 @observable String vmName;
586 @observable String mainPort; 590 @observable String mainPort;
587 @observable Map entry; 591 @observable Map entry;
588 592
589 @observable final Map<String, double> timers = 593 @observable final Map<String, double> timers =
590 toObservable(new Map<String, double>()); 594 toObservable(new Map<String, double>());
591 595
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 } 736 }
733 737
734 /// A [ServiceObject] which implements [ObservableMap]. 738 /// A [ServiceObject] which implements [ObservableMap].
735 class ServiceMap extends ServiceObject implements ObservableMap { 739 class ServiceMap extends ServiceObject implements ObservableMap {
736 final ObservableMap _map = new ObservableMap(); 740 final ObservableMap _map = new ObservableMap();
737 static String objectIdRingPrefix = 'objects/'; 741 static String objectIdRingPrefix = 'objects/';
738 742
739 bool get canCache { 743 bool get canCache {
740 return (_serviceType == 'Class' || 744 return (_serviceType == 'Class' ||
741 _serviceType == 'Function' || 745 _serviceType == 'Function' ||
742 _serviceType == 'Library') && 746 _serviceType == 'Field') &&
743 !_id.startsWith(objectIdRingPrefix); 747 !_id.startsWith(objectIdRingPrefix);
744 } 748 }
745 bool get immutable => canCache; 749 bool get immutable => false;
746 750
747 ServiceMap._empty(ServiceObjectOwner owner) : super._empty(owner); 751 ServiceMap._empty(ServiceObjectOwner owner) : super._empty(owner);
748 752
749 String toString() => _map.toString(); 753 String toString() => _map.toString();
750 754
751 void _upgradeValues() { 755 void _upgradeValues() {
752 assert(owner != null); 756 assert(owner != null);
753 _upgradeCollection(_map, owner); 757 _upgradeCollection(_map, owner);
754 } 758 }
755 759
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 848
845 void _update(ObservableMap map, bool mapIsRef) { 849 void _update(ObservableMap map, bool mapIsRef) {
846 kind = map['kind']; 850 kind = map['kind'];
847 message = map['message']; 851 message = map['message'];
848 response = map['response']; 852 response = map['response'];
849 name = 'ServiceException $kind'; 853 name = 'ServiceException $kind';
850 vmName = name; 854 vmName = name;
851 } 855 }
852 } 856 }
853 857
858 class Library extends ServiceObject {
859 @observable String url;
860 @reflectable final imports = new ObservableList<Library>();
861 @reflectable final scripts = new ObservableList<Script>();
862 @reflectable final classes = new ObservableList<ServiceMap>();
863 @reflectable final variables = new ObservableList<ServiceMap>();
864 @reflectable final functions = new ObservableList<ServiceMap>();
865
866 bool get canCache => true;
867 bool get immutable => false;
868
869 Library._empty(ServiceObjectOwner owner) : super._empty(owner);
870
871 void _update(ObservableMap map, bool mapIsRef) {
872 url = map['url'];
873 var shortUrl = url;
874 if (url.startsWith('file://') ||
875 url.startsWith('http://')) {
876 shortUrl = url.substring(url.lastIndexOf('/') + 1);
877 }
878 name = map['user_name'];
879 if (name.isEmpty) {
880 name = shortUrl;
881 }
882 vmName = map['name'];
883 if (mapIsRef) {
884 return;
885 }
886 _loaded = true;
887 _upgradeCollection(map, isolate);
888 imports.clear();
889 imports.addAll(map['imports']);
890 scripts.clear();
891 scripts.addAll(map['scripts']);
892 classes.clear();
893 classes.addAll(map['classes']);
894 variables.clear();
895 variables.addAll(map['variables']);
896 functions.clear();
897 functions.addAll(map['functions']);
898 }
899 }
900
854 class ScriptLine { 901 class ScriptLine {
855 @reflectable final int line; 902 @reflectable final int line;
856 @reflectable final String text; 903 @reflectable final String text;
857 ScriptLine(this.line, this.text); 904 ScriptLine(this.line, this.text);
858 } 905 }
859 906
860 class Script extends ServiceObject { 907 class Script extends ServiceObject {
861 @reflectable final lines = new ObservableList<ScriptLine>(); 908 @reflectable final lines = new ObservableList<ScriptLine>();
862 @reflectable final hits = new ObservableMap<int, int>(); 909 @reflectable final hits = new ObservableMap<int, int>();
863 @observable String kind; 910 @observable String kind;
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 var v = list[i]; 1474 var v = list[i];
1428 if ((v is ObservableMap) && _isServiceMap(v)) { 1475 if ((v is ObservableMap) && _isServiceMap(v)) {
1429 list[i] = owner.getFromMap(v); 1476 list[i] = owner.getFromMap(v);
1430 } else if (v is ObservableList) { 1477 } else if (v is ObservableList) {
1431 _upgradeObservableList(v, owner); 1478 _upgradeObservableList(v, owner);
1432 } else if (v is ObservableMap) { 1479 } else if (v is ObservableMap) {
1433 _upgradeObservableMap(v, owner); 1480 _upgradeObservableMap(v, owner);
1434 } 1481 }
1435 } 1482 }
1436 } 1483 }
OLDNEW
« no previous file with comments | « runtime/bin/vmservice/client/lib/src/elements/stack_trace.html ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698