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

Side by Side Diff: runtime/observatory/lib/src/service/object.dart

Issue 2119733003: Wrapping leaf nodes in non polymer elements (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Converted vm-connect Created 4 years, 5 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) 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 // Some value smaller than the object ring, so requesting a large array 7 // Some value smaller than the object ring, so requesting a large array
8 // doesn't result in an expired ref because the elements lapped it in the 8 // doesn't result in an expired ref because the elements lapped it in the
9 // object ring. 9 // object ring.
10 const int kDefaultFieldLimit = 100; 10 const int kDefaultFieldLimit = 100;
11 11
12 /// Helper function for canceling a Future<StreamSubscription>. 12 /// Helper function for canceling a Future<StreamSubscription>.
13 Future cancelFutureSubscription( 13 Future cancelFutureSubscription(
14 Future<StreamSubscription> subscriptionFuture) async { 14 Future<StreamSubscription> subscriptionFuture) async {
15 if (subscriptionFuture != null) { 15 if (subscriptionFuture != null) {
16 var subscription = await subscriptionFuture; 16 var subscription = await subscriptionFuture;
17 return subscription.cancel(); 17 return subscription.cancel();
18 } else { 18 } else {
19 return null; 19 return null;
20 } 20 }
21 } 21 }
22 22
23 /// An RpcException represents an exceptional event that happened 23 /// An RpcException represents an exceptional event that happened
24 /// while invoking an rpc. 24 /// while invoking an rpc.
25 abstract class RpcException implements Exception { 25 abstract class RpcException implements Exception, M.BasicException {
26 RpcException(this.message); 26 RpcException(this.message);
27 27
28 String message; 28 String message;
29 } 29 }
30 30
31 /// A ServerRpcException represents an error returned by the VM. 31 /// A ServerRpcException represents an error returned by the VM.
32 class ServerRpcException extends RpcException { 32 class ServerRpcException extends RpcException implements M.RequestException {
33 /// A list of well-known server error codes. 33 /// A list of well-known server error codes.
34 static const kParseError = -32700; 34 static const kParseError = -32700;
35 static const kInvalidRequest = -32600; 35 static const kInvalidRequest = -32600;
36 static const kMethodNotFound = -32601; 36 static const kMethodNotFound = -32601;
37 static const kInvalidParams = -32602; 37 static const kInvalidParams = -32602;
38 static const kInternalError = -32603; 38 static const kInternalError = -32603;
39 static const kFeatureDisabled = 100; 39 static const kFeatureDisabled = 100;
40 static const kCannotAddBreakpoint = 102; 40 static const kCannotAddBreakpoint = 102;
41 static const kStreamAlreadySubscribed = 103; 41 static const kStreamAlreadySubscribed = 103;
42 static const kStreamNotSubscribed = 104; 42 static const kStreamNotSubscribed = 104;
(...skipping 20 matching lines...) Expand all
63 ServerRpcException.fromMap(Map errorMap) : super(_getMessage(errorMap)) { 63 ServerRpcException.fromMap(Map errorMap) : super(_getMessage(errorMap)) {
64 code = errorMap['code']; 64 code = errorMap['code'];
65 data = errorMap['data']; 65 data = errorMap['data'];
66 } 66 }
67 67
68 String toString() => 'ServerRpcException(${message})'; 68 String toString() => 'ServerRpcException(${message})';
69 } 69 }
70 70
71 /// A NetworkRpcException is used to indicate that an rpc has 71 /// A NetworkRpcException is used to indicate that an rpc has
72 /// been canceled due to network error. 72 /// been canceled due to network error.
73 class NetworkRpcException extends RpcException { 73 class NetworkRpcException extends RpcException
74 implements M.ConnectionException {
74 NetworkRpcException(String message) : super(message); 75 NetworkRpcException(String message) : super(message);
75 76
76 String toString() => 'NetworkRpcException(${message})'; 77 String toString() => 'NetworkRpcException(${message})';
77 } 78 }
78 79
79 class MalformedResponseRpcException extends RpcException { 80 class MalformedResponseRpcException extends RpcException
81 implements M.ResponseException {
80 MalformedResponseRpcException(String message, this.response) 82 MalformedResponseRpcException(String message, this.response)
81 : super(message); 83 : super(message);
82 84
83 Map response; 85 Map response;
84 86
85 String toString() => 'MalformedResponseRpcException(${message})'; 87 String toString() => 'MalformedResponseRpcException(${message})';
86 } 88 }
87 89
88 class FakeVMRpcException extends RpcException { 90 class FakeVMRpcException extends RpcException {
89 FakeVMRpcException(String message) : super(message); 91 FakeVMRpcException(String message) : super(message);
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 /// be [loaded]. 419 /// be [loaded].
418 ServiceObject getFromMap(ObservableMap map); 420 ServiceObject getFromMap(ObservableMap map);
419 } 421 }
420 422
421 abstract class Location { 423 abstract class Location {
422 Script get script; 424 Script get script;
423 int get tokenPos; 425 int get tokenPos;
424 } 426 }
425 427
426 /// A [SourceLocation] represents a location or range in the source code. 428 /// A [SourceLocation] represents a location or range in the source code.
427 class SourceLocation extends ServiceObject implements Location { 429 class SourceLocation extends ServiceObject implements Location,
430 M.SourceLocation {
428 Script script; 431 Script script;
429 int tokenPos; 432 int tokenPos;
430 int endTokenPos; 433 int endTokenPos;
431 434
432 Future<int> getLine() async { 435 Future<int> getLine() async {
433 await script.load(); 436 await script.load();
434 return script.tokenToLine(tokenPos); 437 return script.tokenToLine(tokenPos);
435 } 438 }
436 439
437 Future<int> getColumn() async { 440 Future<int> getColumn() async {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 } 599 }
597 600
598 void addEvent(ServiceEvent event) { 601 void addEvent(ServiceEvent event) {
599 for (var controller in _controllers) { 602 for (var controller in _controllers) {
600 controller.add(event); 603 controller.add(event);
601 } 604 }
602 } 605 }
603 } 606 }
604 607
605 /// State for a VM being inspected. 608 /// State for a VM being inspected.
606 abstract class VM extends ServiceObjectOwner { 609 abstract class VM extends ServiceObjectOwner implements M.VM {
607 @reflectable VM get vm => this; 610 @reflectable VM get vm => this;
608 @reflectable Isolate get isolate => null; 611 @reflectable Isolate get isolate => null;
609 612
610 // TODO(turnidge): The connection should not be stored in the VM object. 613 // TODO(turnidge): The connection should not be stored in the VM object.
611 bool get isDisconnected; 614 bool get isDisconnected;
612 615
613 // Used for verbose logging. 616 // Used for verbose logging.
614 bool verbose = false; 617 bool verbose = false;
615 618
616 // TODO(johnmccutchan): Ensure that isolates do not end up in _cache. 619 // TODO(johnmccutchan): Ensure that isolates do not end up in _cache.
617 Map<String,ServiceObject> _cache = new Map<String,ServiceObject>(); 620 Map<String,ServiceObject> _cache = new Map<String,ServiceObject>();
618 final ObservableMap<String,Isolate> _isolateCache = 621 final ObservableMap<String,Isolate> _isolateCache =
619 new ObservableMap<String,Isolate>(); 622 new ObservableMap<String,Isolate>();
620 623
621 // The list of live isolates, ordered by isolate start time. 624 // The list of live isolates, ordered by isolate start time.
622 final ObservableList<Isolate> isolates = new ObservableList<Isolate>(); 625 final ObservableList<Isolate> isolates = new ObservableList<Isolate>();
623 626
624 @observable String version = 'unknown'; 627 @observable String version = 'unknown';
628 @observable String hostCPU;
625 @observable String targetCPU; 629 @observable String targetCPU;
626 @observable int architectureBits; 630 @observable int architectureBits;
627 @observable bool assertsEnabled = false; 631 @observable bool assertsEnabled = false;
628 @observable bool typeChecksEnabled = false; 632 @observable bool typeChecksEnabled = false;
629 @observable int pid = 0; 633 @observable int pid = 0;
630 @observable bool profileVM = false; 634 @observable bool profileVM = false;
631 @observable DateTime startTime; 635 @observable DateTime startTime;
632 @observable DateTime refreshTime; 636 @observable DateTime refreshTime;
633 @observable Duration get upTime { 637 @observable Duration get upTime {
634 if (startTime == null) { 638 if (startTime == null) {
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 vmName = map.containsKey('_vmName') ? map['_vmName'] : name; 893 vmName = map.containsKey('_vmName') ? map['_vmName'] : name;
890 if (mapIsRef) { 894 if (mapIsRef) {
891 return; 895 return;
892 } 896 }
893 // Note that upgrading the collection creates any isolates in the 897 // Note that upgrading the collection creates any isolates in the
894 // isolate list which are new. 898 // isolate list which are new.
895 _upgradeCollection(map, vm); 899 _upgradeCollection(map, vm);
896 900
897 _loaded = true; 901 _loaded = true;
898 version = map['version']; 902 version = map['version'];
903 hostCPU = map['hostCPU'];
899 targetCPU = map['targetCPU']; 904 targetCPU = map['targetCPU'];
900 architectureBits = map['architectureBits']; 905 architectureBits = map['architectureBits'];
901 int startTimeMillis = map['startTime']; 906 int startTimeMillis = map['startTime'];
902 startTime = new DateTime.fromMillisecondsSinceEpoch(startTimeMillis); 907 startTime = new DateTime.fromMillisecondsSinceEpoch(startTimeMillis);
903 refreshTime = new DateTime.now(); 908 refreshTime = new DateTime.now();
904 notifyPropertyChange(#upTime, 0, 1); 909 notifyPropertyChange(#upTime, 0, 1);
905 pid = map['pid']; 910 pid = map['pid'];
906 profileVM = map['_profilerMode'] == 'VM'; 911 profileVM = map['_profilerMode'] == 'VM';
907 assertsEnabled = map['_assertsEnabled']; 912 assertsEnabled = map['_assertsEnabled'];
908 typeChecksEnabled = map['_typeChecksEnabled']; 913 typeChecksEnabled = map['_typeChecksEnabled'];
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 print("${obj.runtimeType} should be a HeapObject"); 1115 print("${obj.runtimeType} should be a HeapObject");
1111 } 1116 }
1112 return obj; 1117 return obj;
1113 })); 1118 }));
1114 } 1119 }
1115 return result; 1120 return result;
1116 } 1121 }
1117 } 1122 }
1118 1123
1119 /// State for a running isolate. 1124 /// State for a running isolate.
1120 class Isolate extends ServiceObjectOwner { 1125 class Isolate extends ServiceObjectOwner implements M.Isolate {
1121 static const kLoggingStream = '_Logging'; 1126 static const kLoggingStream = '_Logging';
1122 static const kExtensionStream = 'Extension'; 1127 static const kExtensionStream = 'Extension';
1123 1128
1124 @reflectable VM get vm => owner; 1129 @reflectable VM get vm => owner;
1125 @reflectable Isolate get isolate => this; 1130 @reflectable Isolate get isolate => this;
1126 @observable int number; 1131 @observable int number;
1127 @observable int originNumber; 1132 @observable int originNumber;
1128 @observable DateTime startTime; 1133 @observable DateTime startTime;
1129 @observable Duration get upTime { 1134 @observable Duration get upTime {
1130 if (startTime == null) { 1135 if (startTime == null) {
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
2018 if (data == null) { 2023 if (data == null) {
2019 return "ServiceEvent(owner='${ownerName}', kind='${kind}', " 2024 return "ServiceEvent(owner='${ownerName}', kind='${kind}', "
2020 "time=${timestamp})"; 2025 "time=${timestamp})";
2021 } else { 2026 } else {
2022 return "ServiceEvent(owner='${ownerName}', kind='${kind}', " 2027 return "ServiceEvent(owner='${ownerName}', kind='${kind}', "
2023 "data.lengthInBytes=${data.lengthInBytes}, time=${timestamp})"; 2028 "data.lengthInBytes=${data.lengthInBytes}, time=${timestamp})";
2024 } 2029 }
2025 } 2030 }
2026 } 2031 }
2027 2032
2028 class Breakpoint extends ServiceObject { 2033 class Breakpoint extends ServiceObject implements M.Breakpoint {
2029 Breakpoint._empty(ServiceObjectOwner owner) : super._empty(owner); 2034 Breakpoint._empty(ServiceObjectOwner owner) : super._empty(owner);
2030 2035
2031 // TODO(turnidge): Add state to track if a breakpoint has been 2036 // TODO(turnidge): Add state to track if a breakpoint has been
2032 // removed from the program. Remove from the cache when deleted. 2037 // removed from the program. Remove from the cache when deleted.
2033 bool get canCache => true; 2038 bool get canCache => true;
2034 bool get immutable => false; 2039 bool get immutable => false;
2035 2040
2036 // A unique integer identifier for this breakpoint. 2041 // A unique integer identifier for this breakpoint.
2037 @observable int number; 2042 @observable int number;
2038 2043
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2114 2119
2115 LibraryDependency._(this.isImport, this.isDeferred, this.prefix, this.target); 2120 LibraryDependency._(this.isImport, this.isDeferred, this.prefix, this.target);
2116 2121
2117 static _fromMap(map) => new LibraryDependency._(map["isImport"], 2122 static _fromMap(map) => new LibraryDependency._(map["isImport"],
2118 map["isDeferred"], 2123 map["isDeferred"],
2119 map["prefix"], 2124 map["prefix"],
2120 map["target"]); 2125 map["target"]);
2121 } 2126 }
2122 2127
2123 2128
2124 class Library extends HeapObject { 2129 class Library extends HeapObject implements M.LibraryRef {
2125 @observable String uri; 2130 @observable String uri;
2126 @reflectable final dependencies = new ObservableList<LibraryDependency>(); 2131 @reflectable final dependencies = new ObservableList<LibraryDependency>();
2127 @reflectable final scripts = new ObservableList<Script>(); 2132 @reflectable final scripts = new ObservableList<Script>();
2128 @reflectable final classes = new ObservableList<Class>(); 2133 @reflectable final classes = new ObservableList<Class>();
2129 @reflectable final variables = new ObservableList<Field>(); 2134 @reflectable final variables = new ObservableList<Field>();
2130 @reflectable final functions = new ObservableList<ServiceFunction>(); 2135 @reflectable final functions = new ObservableList<ServiceFunction>();
2131 2136
2132 bool get canCache => true; 2137 bool get canCache => true;
2133 bool get immutable => false; 2138 bool get immutable => false;
2134 2139
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
2216 void update(List stats) { 2221 void update(List stats) {
2217 accumulated.instances = stats[ACCUMULATED]; 2222 accumulated.instances = stats[ACCUMULATED];
2218 accumulated.bytes = stats[ACCUMULATED_SIZE]; 2223 accumulated.bytes = stats[ACCUMULATED_SIZE];
2219 current.instances = stats[LIVE_AFTER_GC] + stats[ALLOCATED_SINCE_GC]; 2224 current.instances = stats[LIVE_AFTER_GC] + stats[ALLOCATED_SINCE_GC];
2220 current.bytes = stats[LIVE_AFTER_GC_SIZE] + stats[ALLOCATED_SINCE_GC_SIZE]; 2225 current.bytes = stats[LIVE_AFTER_GC_SIZE] + stats[ALLOCATED_SINCE_GC_SIZE];
2221 } 2226 }
2222 2227
2223 bool get empty => accumulated.empty && current.empty; 2228 bool get empty => accumulated.empty && current.empty;
2224 } 2229 }
2225 2230
2226 class Class extends HeapObject { 2231 class Class extends HeapObject implements M.ClassRef {
2227 @observable Library library; 2232 @observable Library library;
2228 2233
2229 @observable bool isAbstract; 2234 @observable bool isAbstract;
2230 @observable bool isConst; 2235 @observable bool isConst;
2231 @observable bool isFinalized; 2236 @observable bool isFinalized;
2232 @observable bool isPatch; 2237 @observable bool isPatch;
2233 @observable bool isImplemented; 2238 @observable bool isImplemented;
2234 2239
2235 @observable SourceLocation location; 2240 @observable SourceLocation location;
2236 2241
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
2911 } 2916 }
2912 2917
2913 /// The location of a local variable reference in a script. 2918 /// The location of a local variable reference in a script.
2914 class LocalVarLocation { 2919 class LocalVarLocation {
2915 final int line; 2920 final int line;
2916 final int column; 2921 final int column;
2917 final int endColumn; 2922 final int endColumn;
2918 LocalVarLocation(this.line, this.column, this.endColumn); 2923 LocalVarLocation(this.line, this.column, this.endColumn);
2919 } 2924 }
2920 2925
2921 class Script extends HeapObject { 2926 class Script extends HeapObject implements M.Script {
2922 final lines = new ObservableList<ScriptLine>(); 2927 final lines = new ObservableList<ScriptLine>();
2923 @observable String uri; 2928 @observable String uri;
2924 @observable String kind; 2929 @observable String kind;
2925 @observable DateTime loadTime; 2930 @observable DateTime loadTime;
2926 @observable int firstTokenPos; 2931 @observable int firstTokenPos;
2927 @observable int lastTokenPos; 2932 @observable int lastTokenPos;
2928 @observable int lineOffset; 2933 @observable int lineOffset;
2929 @observable int columnOffset; 2934 @observable int columnOffset;
2930 @observable Library library; 2935 @observable Library library;
2931 2936
2937 String source;
2938
2932 bool get immutable => true; 2939 bool get immutable => true;
2933 2940
2934 String _shortUri; 2941 String _shortUri;
2935 2942
2936 Script._empty(ServiceObjectOwner owner) : super._empty(owner); 2943 Script._empty(ServiceObjectOwner owner) : super._empty(owner);
2937 2944
2938 ScriptLine getLine(int line) { 2945 ScriptLine getLine(int line) {
2939 assert(_loaded); 2946 assert(_loaded);
2940 assert(line >= 1); 2947 assert(line >= 1);
2941 return lines[line - lineOffset - 1]; 2948 return lines[line - lineOffset - 1];
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
3023 vmName = uri; 3030 vmName = uri;
3024 if (mapIsRef) { 3031 if (mapIsRef) {
3025 return; 3032 return;
3026 } 3033 }
3027 _loaded = true; 3034 _loaded = true;
3028 int loadTimeMillis = map['_loadTime']; 3035 int loadTimeMillis = map['_loadTime'];
3029 loadTime = new DateTime.fromMillisecondsSinceEpoch(loadTimeMillis); 3036 loadTime = new DateTime.fromMillisecondsSinceEpoch(loadTimeMillis);
3030 lineOffset = map['lineOffset']; 3037 lineOffset = map['lineOffset'];
3031 columnOffset = map['columnOffset']; 3038 columnOffset = map['columnOffset'];
3032 _parseTokenPosTable(map['tokenPosTable']); 3039 _parseTokenPosTable(map['tokenPosTable']);
3040 source = map['source'];
3033 _processSource(map['source']); 3041 _processSource(map['source']);
3034 library = map['library']; 3042 library = map['library'];
3035 } 3043 }
3036 3044
3037 void _parseTokenPosTable(List<List<int>> table) { 3045 void _parseTokenPosTable(List<List<int>> table) {
3038 if (table == null) { 3046 if (table == null) {
3039 return; 3047 return;
3040 } 3048 }
3041 _tokenToLine.clear(); 3049 _tokenToLine.clear();
3042 _tokenToCol.clear(); 3050 _tokenToCol.clear();
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
3980 void _onPoll(_) { 3988 void _onPoll(_) {
3981 // Reload metrics and add a sample to each. 3989 // Reload metrics and add a sample to each.
3982 for (var metric in metrics) { 3990 for (var metric in metrics) {
3983 metric.reload().then((m) { 3991 metric.reload().then((m) {
3984 m.addSample(new MetricSample(m.value)); 3992 m.addSample(new MetricSample(m.value));
3985 }); 3993 });
3986 } 3994 }
3987 } 3995 }
3988 } 3996 }
3989 3997
3990 class Frame extends ServiceObject { 3998 class Frame extends ServiceObject implements M.Frame {
3991 @observable int index; 3999 @observable int index;
3992 @observable ServiceFunction function; 4000 @observable ServiceFunction function;
3993 @observable SourceLocation location; 4001 @observable SourceLocation location;
3994 @observable Code code; 4002 @observable Code code;
3995 @observable List<ServiceMap> variables = new ObservableList<ServiceMap>(); 4003 @observable List<ServiceMap> variables = new ObservableList<ServiceMap>();
3996 4004
3997 Frame._empty(ServiceObject owner) : super._empty(owner); 4005 Frame._empty(ServiceObject owner) : super._empty(owner);
3998 4006
3999 void _update(ObservableMap map, bool mapIsRef) { 4007 void _update(ObservableMap map, bool mapIsRef) {
4000 assert(!mapIsRef); 4008 assert(!mapIsRef);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
4115 var v = list[i]; 4123 var v = list[i];
4116 if ((v is ObservableMap) && _isServiceMap(v)) { 4124 if ((v is ObservableMap) && _isServiceMap(v)) {
4117 list[i] = owner.getFromMap(v); 4125 list[i] = owner.getFromMap(v);
4118 } else if (v is ObservableList) { 4126 } else if (v is ObservableList) {
4119 _upgradeObservableList(v, owner); 4127 _upgradeObservableList(v, owner);
4120 } else if (v is ObservableMap) { 4128 } else if (v is ObservableMap) {
4121 _upgradeObservableMap(v, owner); 4129 _upgradeObservableMap(v, owner);
4122 } 4130 }
4123 } 4131 }
4124 } 4132 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/repositories/target.dart ('k') | runtime/observatory/tests/manual_ui/inspector.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698