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

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

Issue 1153193006: Standardize on using "kind" to distinguish sub-varieties of a type. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: doc changes Created 5 years, 6 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 /// An RpcException represents an exceptional event that happened 7 /// An RpcException represents an exceptional event that happened
8 /// while invoking an rpc. 8 /// while invoking an rpc.
9 abstract class RpcException implements Exception { 9 abstract class RpcException implements Exception {
10 RpcException(this.message); 10 RpcException(this.message);
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 } 448 }
449 449
450 var eventIsolate = map['isolate']; 450 var eventIsolate = map['isolate'];
451 if (eventIsolate == null) { 451 if (eventIsolate == null) {
452 var event = new ServiceObject._fromMap(vm, map); 452 var event = new ServiceObject._fromMap(vm, map);
453 events.add(event); 453 events.add(event);
454 } else { 454 } else {
455 // getFromMap creates the Isolate if it hasn't been seen already. 455 // getFromMap creates the Isolate if it hasn't been seen already.
456 var isolate = getFromMap(map['isolate']); 456 var isolate = getFromMap(map['isolate']);
457 var event = new ServiceObject._fromMap(isolate, map); 457 var event = new ServiceObject._fromMap(isolate, map);
458 if (event.eventType == ServiceEvent.kIsolateExit) { 458 if (event.kind == ServiceEvent.kIsolateExit) {
459 _removeIsolate(isolate.id); 459 _removeIsolate(isolate.id);
460 } 460 }
461 isolate._onEvent(event); 461 isolate._onEvent(event);
462 events.add(event); 462 events.add(event);
463 } 463 }
464 } 464 }
465 465
466 void _removeIsolate(String isolateId) { 466 void _removeIsolate(String isolateId) {
467 assert(_isolateCache.containsKey(isolateId)); 467 assert(_isolateCache.containsKey(isolateId));
468 _isolateCache.remove(isolateId); 468 _isolateCache.remove(isolateId);
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 @observable int number; 806 @observable int number;
807 @observable DateTime startTime; 807 @observable DateTime startTime;
808 @observable Duration get upTime => 808 @observable Duration get upTime =>
809 (new DateTime.now().difference(startTime)); 809 (new DateTime.now().difference(startTime));
810 810
811 @observable ObservableMap counters = new ObservableMap(); 811 @observable ObservableMap counters = new ObservableMap();
812 812
813 void _updateRunState() { 813 void _updateRunState() {
814 topFrame = (pauseEvent != null ? pauseEvent.topFrame : null); 814 topFrame = (pauseEvent != null ? pauseEvent.topFrame : null);
815 paused = (pauseEvent != null && 815 paused = (pauseEvent != null &&
816 pauseEvent.eventType != ServiceEvent.kResume); 816 pauseEvent.kind != ServiceEvent.kResume);
817 running = (!paused && topFrame != null); 817 running = (!paused && topFrame != null);
818 idle = (!paused && topFrame == null); 818 idle = (!paused && topFrame == null);
819 notifyPropertyChange(#topFrame, 0, 1); 819 notifyPropertyChange(#topFrame, 0, 1);
820 notifyPropertyChange(#paused, 0, 1); 820 notifyPropertyChange(#paused, 0, 1);
821 notifyPropertyChange(#running, 0, 1); 821 notifyPropertyChange(#running, 0, 1);
822 notifyPropertyChange(#idle, 0, 1); 822 notifyPropertyChange(#idle, 0, 1);
823 } 823 }
824 824
825 @observable ServiceEvent pauseEvent = null; 825 @observable ServiceEvent pauseEvent = null;
826 @observable bool paused = false; 826 @observable bool paused = false;
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 void _addBreakpoint(Breakpoint bpt) { 1125 void _addBreakpoint(Breakpoint bpt) {
1126 breakpoints[bpt.number] = bpt; 1126 breakpoints[bpt.number] = bpt;
1127 } 1127 }
1128 1128
1129 void _removeBreakpoint(Breakpoint bpt) { 1129 void _removeBreakpoint(Breakpoint bpt) {
1130 breakpoints.remove(bpt.number); 1130 breakpoints.remove(bpt.number);
1131 bpt.remove(); 1131 bpt.remove();
1132 } 1132 }
1133 1133
1134 void _onEvent(ServiceEvent event) { 1134 void _onEvent(ServiceEvent event) {
1135 switch(event.eventType) { 1135 switch(event.kind) {
1136 case ServiceEvent.kIsolateStart: 1136 case ServiceEvent.kIsolateStart:
1137 case ServiceEvent.kIsolateExit: 1137 case ServiceEvent.kIsolateExit:
1138 case ServiceEvent.kInspect: 1138 case ServiceEvent.kInspect:
1139 // Handled elsewhere. 1139 // Handled elsewhere.
1140 break; 1140 break;
1141 1141
1142 case ServiceEvent.kBreakpointAdded: 1142 case ServiceEvent.kBreakpointAdded:
1143 _addBreakpoint(event.breakpoint); 1143 _addBreakpoint(event.breakpoint);
1144 break; 1144 break;
1145 1145
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 stacktrace = new ServiceObject._fromMap(owner, map['stacktrace']); 1422 stacktrace = new ServiceObject._fromMap(owner, map['stacktrace']);
1423 name = 'DartError($message)'; 1423 name = 'DartError($message)';
1424 vmName = name; 1424 vmName = name;
1425 } 1425 }
1426 1426
1427 String toString() => 'DartError($message)'; 1427 String toString() => 'DartError($message)';
1428 } 1428 }
1429 1429
1430 /// A [ServiceEvent] is an asynchronous event notification from the vm. 1430 /// A [ServiceEvent] is an asynchronous event notification from the vm.
1431 class ServiceEvent extends ServiceObject { 1431 class ServiceEvent extends ServiceObject {
1432 /// The possible 'eventType' values. 1432 /// The possible 'kind' values.
1433 static const kIsolateStart = 'IsolateStart'; 1433 static const kIsolateStart = 'IsolateStart';
1434 static const kIsolateExit = 'IsolateExit'; 1434 static const kIsolateExit = 'IsolateExit';
1435 static const kIsolateUpdate = 'IsolateUpdate'; 1435 static const kIsolateUpdate = 'IsolateUpdate';
1436 static const kPauseStart = 'PauseStart'; 1436 static const kPauseStart = 'PauseStart';
1437 static const kPauseExit = 'PauseExit'; 1437 static const kPauseExit = 'PauseExit';
1438 static const kPauseBreakpoint = 'PauseBreakpoint'; 1438 static const kPauseBreakpoint = 'PauseBreakpoint';
1439 static const kPauseInterrupted = 'PauseInterrupted'; 1439 static const kPauseInterrupted = 'PauseInterrupted';
1440 static const kPauseException = 'PauseException'; 1440 static const kPauseException = 'PauseException';
1441 static const kResume = 'Resume'; 1441 static const kResume = 'Resume';
1442 static const kBreakpointAdded = 'BreakpointAdded'; 1442 static const kBreakpointAdded = 'BreakpointAdded';
1443 static const kBreakpointResolved = 'BreakpointResolved'; 1443 static const kBreakpointResolved = 'BreakpointResolved';
1444 static const kBreakpointRemoved = 'BreakpointRemoved'; 1444 static const kBreakpointRemoved = 'BreakpointRemoved';
1445 static const kGraph = '_Graph'; 1445 static const kGraph = '_Graph';
1446 static const kGC = 'GC'; 1446 static const kGC = 'GC';
1447 static const kInspect = 'Inspect'; 1447 static const kInspect = 'Inspect';
1448 static const kConnectionClosed = 'ConnectionClosed'; 1448 static const kConnectionClosed = 'ConnectionClosed';
1449 1449
1450 ServiceEvent._empty(ServiceObjectOwner owner) : super._empty(owner); 1450 ServiceEvent._empty(ServiceObjectOwner owner) : super._empty(owner);
1451 1451
1452 ServiceEvent.connectionClosed(this.reason) : super._empty(null) { 1452 ServiceEvent.connectionClosed(this.reason) : super._empty(null) {
1453 eventType = kConnectionClosed; 1453 kind = kConnectionClosed;
1454 } 1454 }
1455 1455
1456 @observable String eventType; 1456 @observable String kind;
1457 @observable Breakpoint breakpoint; 1457 @observable Breakpoint breakpoint;
1458 @observable ServiceMap topFrame; 1458 @observable ServiceMap topFrame;
1459 @observable ServiceMap exception; 1459 @observable ServiceMap exception;
1460 @observable ServiceObject inspectee; 1460 @observable ServiceObject inspectee;
1461 @observable ByteData data; 1461 @observable ByteData data;
1462 @observable int count; 1462 @observable int count;
1463 @observable String reason; 1463 @observable String reason;
1464 int chunkIndex, chunkCount, nodeCount; 1464 int chunkIndex, chunkCount, nodeCount;
1465 1465
1466 @observable bool get isPauseEvent { 1466 @observable bool get isPauseEvent {
1467 return (eventType == kPauseStart || 1467 return (kind == kPauseStart ||
1468 eventType == kPauseExit || 1468 kind == kPauseExit ||
1469 eventType == kPauseBreakpoint || 1469 kind == kPauseBreakpoint ||
1470 eventType == kPauseInterrupted || 1470 kind == kPauseInterrupted ||
1471 eventType == kPauseException); 1471 kind == kPauseException);
1472 } 1472 }
1473 1473
1474 void _update(ObservableMap map, bool mapIsRef) { 1474 void _update(ObservableMap map, bool mapIsRef) {
1475 _loaded = true; 1475 _loaded = true;
1476 _upgradeCollection(map, owner); 1476 _upgradeCollection(map, owner);
1477 assert(map['isolate'] == null || owner == map['isolate']); 1477 assert(map['isolate'] == null || owner == map['isolate']);
1478 eventType = map['eventType']; 1478 kind = map['kind'];
1479 notifyPropertyChange(#isPauseEvent, 0, 1); 1479 notifyPropertyChange(#isPauseEvent, 0, 1);
1480 name = 'ServiceEvent $eventType'; 1480 name = 'ServiceEvent $kind';
1481 vmName = name; 1481 vmName = name;
1482 if (map['breakpoint'] != null) { 1482 if (map['breakpoint'] != null) {
1483 breakpoint = map['breakpoint']; 1483 breakpoint = map['breakpoint'];
1484 } 1484 }
1485 if (map['topFrame'] != null) { 1485 if (map['topFrame'] != null) {
1486 topFrame = map['topFrame']; 1486 topFrame = map['topFrame'];
1487 } 1487 }
1488 if (map['exception'] != null) { 1488 if (map['exception'] != null) {
1489 exception = map['exception']; 1489 exception = map['exception'];
1490 } 1490 }
(...skipping 12 matching lines...) Expand all
1503 if (map['nodeCount'] != null) { 1503 if (map['nodeCount'] != null) {
1504 nodeCount = map['nodeCount']; 1504 nodeCount = map['nodeCount'];
1505 } 1505 }
1506 if (map['count'] != null) { 1506 if (map['count'] != null) {
1507 count = map['count']; 1507 count = map['count'];
1508 } 1508 }
1509 } 1509 }
1510 1510
1511 String toString() { 1511 String toString() {
1512 if (data == null) { 1512 if (data == null) {
1513 return "ServiceEvent(owner='${owner.id}', type='${eventType}')"; 1513 return "ServiceEvent(owner='${owner.id}', kind='${kind}')";
1514 } else { 1514 } else {
1515 return "ServiceEvent(owner='${owner.id}', type='${eventType}', " 1515 return "ServiceEvent(owner='${owner.id}', kind='${kind}', "
1516 "data.lengthInBytes=${data.lengthInBytes})"; 1516 "data.lengthInBytes=${data.lengthInBytes})";
1517 } 1517 }
1518 } 1518 }
1519 } 1519 }
1520 1520
1521 class Breakpoint extends ServiceObject { 1521 class Breakpoint extends ServiceObject {
1522 Breakpoint._empty(ServiceObjectOwner owner) : super._empty(owner); 1522 Breakpoint._empty(ServiceObjectOwner owner) : super._empty(owner);
1523 1523
1524 // TODO(turnidge): Add state to track if a breakpoint has been 1524 // TODO(turnidge): Add state to track if a breakpoint has been
1525 // removed from the program. Remove from the cache when deleted. 1525 // removed from the program. Remove from the cache when deleted.
(...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after
3157 var v = list[i]; 3157 var v = list[i];
3158 if ((v is ObservableMap) && _isServiceMap(v)) { 3158 if ((v is ObservableMap) && _isServiceMap(v)) {
3159 list[i] = owner.getFromMap(v); 3159 list[i] = owner.getFromMap(v);
3160 } else if (v is ObservableList) { 3160 } else if (v is ObservableList) {
3161 _upgradeObservableList(v, owner); 3161 _upgradeObservableList(v, owner);
3162 } else if (v is ObservableMap) { 3162 } else if (v is ObservableMap) {
3163 _upgradeObservableMap(v, owner); 3163 _upgradeObservableMap(v, owner);
3164 } 3164 }
3165 } 3165 }
3166 } 3166 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698