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

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

Issue 511413002: Revert "Give instances their own model class; move DartErrors out of instance-ref into their own er… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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/observatory/lib/src/elements/stack_frame.html ('k') | no next file » | 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 static int LexicalSortName(ServiceObject o1, ServiceObject o2) { 10 static int LexicalSortName(ServiceObject o1, ServiceObject o2) {
(...skipping 16 matching lines...) Expand all
27 @reflectable Isolate get isolate => _owner.isolate; 27 @reflectable Isolate get isolate => _owner.isolate;
28 28
29 /// The id of this object. 29 /// The id of this object.
30 @reflectable String get id => _id; 30 @reflectable String get id => _id;
31 String _id; 31 String _id;
32 32
33 /// The service type of this object. 33 /// The service type of this object.
34 @reflectable String get serviceType => _serviceType; 34 @reflectable String get serviceType => _serviceType;
35 String _serviceType; 35 String _serviceType;
36 36
37 bool get isBool => serviceType == 'Bool';
38 bool get isDouble => serviceType == 'Double';
39 bool get isError => serviceType == 'Error';
40 bool get isInstance => serviceType == 'Instance';
41 bool get isInt => serviceType == 'Smi' || serviceType == 'Mint' || serviceType == 'Bigint';
42 bool get isList => serviceType == 'GrowableObjectArray' || serviceType == 'Arr ay';
43 bool get isNull => serviceType == 'Null';
44 bool get isSentinel => serviceType == 'Sentinel';
45 bool get isString => serviceType == 'String';
46 bool get isType => serviceType == 'Type';
47
48 /// The complete service url of this object. 37 /// The complete service url of this object.
49 @reflectable String get link => _owner.relativeLink(_id); 38 @reflectable String get link => _owner.relativeLink(_id);
50 39
51 /// Has this object been fully loaded? 40 /// Has this object been fully loaded?
52 bool get loaded => _loaded; 41 bool get loaded => _loaded;
53 bool _loaded = false; 42 bool _loaded = false;
54 // TODO(turnidge): Make loaded observable and get rid of loading 43 // TODO(turnidge): Make loaded observable and get rid of loading
55 // from Isolate. 44 // from Isolate.
56 45
57 /// Is this object cacheable? That is, is it impossible for the [id] 46 /// Is this object cacheable? That is, is it impossible for the [id]
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 break; 81 break;
93 case 'Error': 82 case 'Error':
94 obj = new DartError._empty(owner); 83 obj = new DartError._empty(owner);
95 break; 84 break;
96 case 'Function': 85 case 'Function':
97 obj = new ServiceFunction._empty(owner); 86 obj = new ServiceFunction._empty(owner);
98 break; 87 break;
99 case 'Gauge': 88 case 'Gauge':
100 obj = new ServiceMetric._empty(owner); 89 obj = new ServiceMetric._empty(owner);
101 break; 90 break;
102 case 'Array':
103 case 'Bigint':
104 case 'Bool':
105 case 'Double':
106 case 'GrowableObjectArray':
107 case 'Instance':
108 case 'Mint':
109 case 'Null':
110 case 'Sentinel': // TODO(rmacnak): Separate this out.
111 case 'Smi':
112 case 'String':
113 case 'Type':
114 obj = new Instance._empty(owner);
115 break;
116 case 'Isolate': 91 case 'Isolate':
117 obj = new Isolate._empty(owner.vm); 92 obj = new Isolate._empty(owner.vm);
118 break; 93 break;
119 case 'Library': 94 case 'Library':
120 obj = new Library._empty(owner); 95 obj = new Library._empty(owner);
121 break; 96 break;
122 case 'ServiceError': 97 case 'ServiceError':
123 obj = new ServiceError._empty(owner); 98 obj = new ServiceError._empty(owner);
124 break; 99 break;
125 case 'ServiceEvent': 100 case 'ServiceEvent':
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 1152
1178 String toString() => "ServiceMap($_map)"; 1153 String toString() => "ServiceMap($_map)";
1179 } 1154 }
1180 1155
1181 /// A [DartError] is peered to a Dart Error object. 1156 /// A [DartError] is peered to a Dart Error object.
1182 class DartError extends ServiceObject { 1157 class DartError extends ServiceObject {
1183 DartError._empty(ServiceObject owner) : super._empty(owner); 1158 DartError._empty(ServiceObject owner) : super._empty(owner);
1184 1159
1185 @observable String kind; 1160 @observable String kind;
1186 @observable String message; 1161 @observable String message;
1187 @observable Instance exception; 1162 @observable ServiceMap exception;
1188 @observable ServiceMap stacktrace; 1163 @observable ServiceMap stacktrace;
1189 1164
1190 void _update(ObservableMap map, bool mapIsRef) { 1165 void _update(ObservableMap map, bool mapIsRef) {
1191 kind = map['kind']; 1166 kind = map['kind'];
1192 message = map['message']; 1167 message = map['message'];
1193 exception = new ServiceObject._fromMap(owner, map['exception']); 1168 exception = new ServiceObject._fromMap(owner, map['exception']);
1194 stacktrace = new ServiceObject._fromMap(owner, map['stacktrace']); 1169 stacktrace = new ServiceObject._fromMap(owner, map['stacktrace']);
1195 name = 'DartError $kind'; 1170 name = 'DartError $kind';
1196 vmName = name; 1171 vmName = name;
1197 } 1172 }
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 subclasses.sort(ServiceObject.LexicalSortName); 1432 subclasses.sort(ServiceObject.LexicalSortName);
1458 } 1433 }
1459 1434
1460 Future<ServiceObject> get(String command) { 1435 Future<ServiceObject> get(String command) {
1461 return isolate.get(id + "/$command"); 1436 return isolate.get(id + "/$command");
1462 } 1437 }
1463 1438
1464 String toString() => 'Class($vmName)'; 1439 String toString() => 'Class($vmName)';
1465 } 1440 }
1466 1441
1467 class Instance extends ServiceObject {
1468 @observable Class clazz;
1469 @observable String valueAsString;
1470 @observable int size;
1471 @observable ServiceFunction closureFunc; // If a closure.
1472 @observable String name; // If a Type.
1473
1474 @observable var typeClass;
1475 @observable var length;
1476 @observable var fields;
1477 @observable var nativeFields;
1478 @observable var elements;
1479 @observable var userName;
1480
1481 bool get isClosure => closureFunc != null;
1482
1483 Instance._empty(ServiceObjectOwner owner) : super._empty(owner);
1484
1485 void _update(ObservableMap map, bool mapIsRef) {
1486 // Extract full properties.
1487 _upgradeCollection(map, isolate);
1488
1489 clazz = map['class'];
1490 valueAsString = map['valueAsString'];
1491 size = map['size'];
1492 closureFunc = map['closureFunc'];
1493 name = map['name'];
1494
1495 if (mapIsRef) {
1496 return;
1497 }
1498
1499 nativeFields = map['nativeFields'];
1500 fields = map['fields'];
1501 length = map['length'];
1502 elements = map['elements'];
1503 typeClass = map['type_class'];
1504 userName = map['user_name'];
1505
1506 // We are fully loaded.
1507 _loaded = true;
1508 }
1509
1510 String get shortName => valueAsString != null ? valueAsString : 'a ${clazz.nam e}';
1511
1512 String toString() => 'Instance($shortName)';
1513 }
1514
1515 // TODO(koda): Sync this with VM. 1442 // TODO(koda): Sync this with VM.
1516 class FunctionKind { 1443 class FunctionKind {
1517 final String _strValue; 1444 final String _strValue;
1518 FunctionKind._internal(this._strValue); 1445 FunctionKind._internal(this._strValue);
1519 toString() => _strValue; 1446 toString() => _strValue;
1520 bool isFake() => [kCollected, kNative, kTag, kReused].contains(this); 1447 bool isFake() => [kCollected, kNative, kTag, kReused].contains(this);
1521 1448
1522 static FunctionKind fromJSON(String value) { 1449 static FunctionKind fromJSON(String value) {
1523 switch(value) { 1450 switch(value) {
1524 case 'kRegularFunction': return kRegularFunction; 1451 case 'kRegularFunction': return kRegularFunction;
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after
2422 for (var metric in metrics) { 2349 for (var metric in metrics) {
2423 metric.reload().then((m) { 2350 metric.reload().then((m) {
2424 m.addSample(new MetricSample(m.value)); 2351 m.addSample(new MetricSample(m.value));
2425 }); 2352 });
2426 } 2353 }
2427 } 2354 }
2428 } 2355 }
2429 2356
2430 // Convert any ServiceMaps representing a null instance into an actual null. 2357 // Convert any ServiceMaps representing a null instance into an actual null.
2431 _convertNull(obj) { 2358 _convertNull(obj) {
2432 if (obj.isNull) { 2359 if (obj is ServiceMap &&
2360 obj.serviceType == 'Null') {
2433 return null; 2361 return null;
2434 } 2362 }
2435 return obj; 2363 return obj;
2436 } 2364 }
2437 2365
2438 // Returns true if [map] is a service map. i.e. it has the following keys: 2366 // Returns true if [map] is a service map. i.e. it has the following keys:
2439 // 'id' and a 'type'. 2367 // 'id' and a 'type'.
2440 bool _isServiceMap(ObservableMap m) { 2368 bool _isServiceMap(ObservableMap m) {
2441 return (m != null) && (m['id'] != null) && (m['type'] != null); 2369 return (m != null) && (m['id'] != null) && (m['type'] != null);
2442 } 2370 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2475 var v = list[i]; 2403 var v = list[i];
2476 if ((v is ObservableMap) && _isServiceMap(v)) { 2404 if ((v is ObservableMap) && _isServiceMap(v)) {
2477 list[i] = owner.getFromMap(v); 2405 list[i] = owner.getFromMap(v);
2478 } else if (v is ObservableList) { 2406 } else if (v is ObservableList) {
2479 _upgradeObservableList(v, owner); 2407 _upgradeObservableList(v, owner);
2480 } else if (v is ObservableMap) { 2408 } else if (v is ObservableMap) {
2481 _upgradeObservableMap(v, owner); 2409 _upgradeObservableMap(v, owner);
2482 } 2410 }
2483 } 2411 }
2484 } 2412 }
OLDNEW
« no previous file with comments | « runtime/bin/vmservice/observatory/lib/src/elements/stack_frame.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698