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

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

Issue 1977873003: Allow users to see more elements of a list/map in Observatory. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix problems found during testing Created 4 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
« no previous file with comments | « runtime/observatory/lib/src/elements/instance_ref.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 // 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;
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 Future<ServiceObject> load() { 280 Future<ServiceObject> load() {
281 if (loaded) { 281 if (loaded) {
282 return new Future.value(this); 282 return new Future.value(this);
283 } 283 }
284 // Call reload which will fill in the entire object. 284 // Call reload which will fill in the entire object.
285 return reload(); 285 return reload();
286 } 286 }
287 287
288 Future<ServiceObject> _inProgressReload; 288 Future<ServiceObject> _inProgressReload;
289 289
290 Future<ObservableMap> _fetchDirect() { 290 Future<ObservableMap> _fetchDirect({int count: kDefaultFieldLimit}) {
291 Map params = { 291 Map params = {
292 'objectId': id, 292 'objectId': id,
293 'count': kDefaultFieldLimit, 293 'count': count,
294 }; 294 };
295 return isolate.invokeRpcNoUpgrade('getObject', params); 295 return isolate.invokeRpcNoUpgrade('getObject', params);
296 } 296 }
297 297
298 /// Reload [this]. Returns a future which completes to [this] or 298 /// Reload [this]. Returns a future which completes to [this] or
299 /// an exception. 299 /// an exception.
300 Future<ServiceObject> reload() { 300 Future<ServiceObject> reload({int count: kDefaultFieldLimit}) {
301 // TODO(turnidge): Checking for a null id should be part of the 301 // TODO(turnidge): Checking for a null id should be part of the
302 // "immmutable" check. 302 // "immmutable" check.
303 bool hasId = (id != null) && (id != ''); 303 bool hasId = (id != null) && (id != '');
304 bool isVM = this is VM; 304 bool isVM = this is VM;
305 // We should always reload the VM. 305 // We should always reload the VM.
306 // We can't reload objects without an id. 306 // We can't reload objects without an id.
307 // We shouldn't reload an immutable and already loaded object. 307 // We shouldn't reload an immutable and already loaded object.
308 bool skipLoad = !isVM && (!hasId || (immutable && loaded)); 308 bool skipLoad = !isVM && (!hasId || (immutable && loaded));
309 if (skipLoad) { 309 if (skipLoad) {
310 return new Future.value(this); 310 return new Future.value(this);
311 } 311 }
312 if (_inProgressReload == null) { 312 if (_inProgressReload == null) {
313 var completer = new Completer<ServiceObject>(); 313 var completer = new Completer<ServiceObject>();
314 _inProgressReload = completer.future; 314 _inProgressReload = completer.future;
315 _fetchDirect().then((ObservableMap map) { 315 _fetchDirect(count: count).then((ObservableMap map) {
316 var mapType = _stripRef(map['type']); 316 var mapType = _stripRef(map['type']);
317 if (mapType == 'Sentinel') { 317 if (mapType == 'Sentinel') {
318 // An object may have been collected, etc. 318 // An object may have been collected, etc.
319 completer.complete(new ServiceObject._fromMap(owner, map)); 319 completer.complete(new ServiceObject._fromMap(owner, map));
320 } else { 320 } else {
321 // TODO(turnidge): Check for vmType changing as well? 321 // TODO(turnidge): Check for vmType changing as well?
322 assert(mapType == _type); 322 assert(mapType == _type);
323 update(map); 323 update(map);
324 completer.complete(this); 324 completer.complete(this);
325 } 325 }
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 var isolate = event.isolate; 799 var isolate = event.isolate;
800 if (isolate != null) { 800 if (isolate != null) {
801 isolate._onEvent(event); 801 isolate._onEvent(event);
802 } 802 }
803 } 803 }
804 804
805 Future restart() { 805 Future restart() {
806 return invokeRpc('_restartVM', {}); 806 return invokeRpc('_restartVM', {});
807 } 807 }
808 808
809 Future<ObservableMap> _fetchDirect() async { 809 Future<ObservableMap> _fetchDirect({int count: kDefaultFieldLimit}) async {
810 if (!loaded) { 810 if (!loaded) {
811 // The vm service relies on these events to keep the VM and 811 // The vm service relies on these events to keep the VM and
812 // Isolate types up to date. 812 // Isolate types up to date.
813 try { 813 try {
814 await listenEventStream(kVMStream, _dispatchEventToIsolate); 814 await listenEventStream(kVMStream, _dispatchEventToIsolate);
815 await listenEventStream(kIsolateStream, _dispatchEventToIsolate); 815 await listenEventStream(kIsolateStream, _dispatchEventToIsolate);
816 await listenEventStream(kDebugStream, _dispatchEventToIsolate); 816 await listenEventStream(kDebugStream, _dispatchEventToIsolate);
817 await listenEventStream(_kGraphStream, _dispatchEventToIsolate); 817 await listenEventStream(_kGraphStream, _dispatchEventToIsolate);
818 } on FakeVMRpcException catch (_) { 818 } on FakeVMRpcException catch (_) {
819 // ignore FakeVMRpcExceptions here. 819 // ignore FakeVMRpcExceptions here.
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 params['isolateId'] = id; 1281 params['isolateId'] = id;
1282 return vm.invokeRpcNoUpgrade(method, params); 1282 return vm.invokeRpcNoUpgrade(method, params);
1283 } 1283 }
1284 1284
1285 Future<ServiceObject> invokeRpc(String method, Map params) { 1285 Future<ServiceObject> invokeRpc(String method, Map params) {
1286 return invokeRpcNoUpgrade(method, params).then((ObservableMap response) { 1286 return invokeRpcNoUpgrade(method, params).then((ObservableMap response) {
1287 return getFromMap(response); 1287 return getFromMap(response);
1288 }); 1288 });
1289 } 1289 }
1290 1290
1291 Future<ServiceObject> getObject(String objectId, {bool reload: true}) { 1291 Future<ServiceObject> getObject(String objectId,
1292 {bool reload: true,
1293 int count: kDefaultFieldLimit}) {
1292 assert(objectId != null && objectId != ''); 1294 assert(objectId != null && objectId != '');
1293 var obj = _cache[objectId]; 1295 var obj = _cache[objectId];
1294 if (obj != null) { 1296 if (obj != null) {
1295 if (reload) { 1297 if (reload) {
1296 return obj.reload(); 1298 return obj.reload(count: count);
1297 } 1299 }
1298 // Returned cached object. 1300 // Returned cached object.
1299 return new Future.value(obj); 1301 return new Future.value(obj);
1300 } 1302 }
1301 Map params = { 1303 Map params = {
1302 'objectId': objectId, 1304 'objectId': objectId,
1303 'count': kDefaultFieldLimit, 1305 'count': count,
1304 }; 1306 };
1305 return isolate.invokeRpc('getObject', params); 1307 return isolate.invokeRpc('getObject', params);
1306 } 1308 }
1307 1309
1308 Future<ObservableMap> _fetchDirect() { 1310 Future<ObservableMap> _fetchDirect({int count: kDefaultFieldLimit}) async {
1309 return invokeRpcNoUpgrade('getIsolate', {}); 1311 return invokeRpcNoUpgrade('getIsolate', {});
1310 } 1312 }
1311 1313
1312 @observable Class objectClass; 1314 @observable Class objectClass;
1313 @observable final rootClasses = new ObservableList<Class>(); 1315 @observable final rootClasses = new ObservableList<Class>();
1314 Map<int, Class> _classesByCid = new Map<int, Class>(); 1316 Map<int, Class> _classesByCid = new Map<int, Class>();
1315 1317
1316 @observable Library rootLibrary; 1318 @observable Library rootLibrary;
1317 @observable ObservableList<Library> libraries = 1319 @observable ObservableList<Library> libraries =
1318 new ObservableList<Library>(); 1320 new ObservableList<Library>();
(...skipping 2234 matching lines...) Expand 10 before | Expand all | Expand 10 after
3553 script.load().then(_updateDescriptors); 3555 script.load().then(_updateDescriptors);
3554 }); 3556 });
3555 return; 3557 return;
3556 } 3558 }
3557 // Load the script and then update descriptors. 3559 // Load the script and then update descriptors.
3558 function.location.script.load().then(_updateDescriptors); 3560 function.location.script.load().then(_updateDescriptors);
3559 } 3561 }
3560 3562
3561 /// Reload [this]. Returns a future which completes to [this] or an 3563 /// Reload [this]. Returns a future which completes to [this] or an
3562 /// exception. 3564 /// exception.
3563 Future<ServiceObject> reload() { 3565 Future<ServiceObject> reload({int count: kDefaultFieldLimit}) {
3564 assert(kind != null); 3566 assert(kind != null);
3565 if (isDartCode) { 3567 if (isDartCode) {
3566 // We only reload Dart code. 3568 // We only reload Dart code.
3567 return super.reload(); 3569 return super.reload(count: count);
3568 } 3570 }
3569 return new Future.value(this); 3571 return new Future.value(this);
3570 } 3572 }
3571 3573
3572 void _update(ObservableMap m, bool mapIsRef) { 3574 void _update(ObservableMap m, bool mapIsRef) {
3573 name = m['name']; 3575 name = m['name'];
3574 vmName = (m.containsKey('_vmName') ? m['_vmName'] : name); 3576 vmName = (m.containsKey('_vmName') ? m['_vmName'] : name);
3575 isOptimized = m['_optimized']; 3577 isOptimized = m['_optimized'];
3576 kind = CodeKind.fromString(m['kind']); 3578 kind = CodeKind.fromString(m['kind']);
3577 hasIntrinsic = m['_intrinsic']; 3579 hasIntrinsic = m['_intrinsic'];
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
3838 3840
3839 final ObservableList<MetricSample> samples = 3841 final ObservableList<MetricSample> samples =
3840 new ObservableList<MetricSample>(); 3842 new ObservableList<MetricSample>();
3841 int _sampleBufferSize = 100; 3843 int _sampleBufferSize = 100;
3842 int get sampleBufferSize => _sampleBufferSize; 3844 int get sampleBufferSize => _sampleBufferSize;
3843 set sampleBufferSize(int size) { 3845 set sampleBufferSize(int size) {
3844 _sampleBufferSize = size; 3846 _sampleBufferSize = size;
3845 _removeOld(); 3847 _removeOld();
3846 } 3848 }
3847 3849
3848 Future<ObservableMap> _fetchDirect() { 3850 Future<ObservableMap> _fetchDirect({int count: kDefaultFieldLimit}) {
3849 assert(owner is Isolate); 3851 assert(owner is Isolate);
3850 return isolate.invokeRpcNoUpgrade('_getIsolateMetric', { 'metricId': id }); 3852 return isolate.invokeRpcNoUpgrade('_getIsolateMetric', { 'metricId': id });
3851 } 3853 }
3852 3854
3853 3855
3854 void addSample(MetricSample sample) { 3856 void addSample(MetricSample sample) {
3855 samples.add(sample); 3857 samples.add(sample);
3856 _removeOld(); 3858 _removeOld();
3857 } 3859 }
3858 3860
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
4045 var v = list[i]; 4047 var v = list[i];
4046 if ((v is ObservableMap) && _isServiceMap(v)) { 4048 if ((v is ObservableMap) && _isServiceMap(v)) {
4047 list[i] = owner.getFromMap(v); 4049 list[i] = owner.getFromMap(v);
4048 } else if (v is ObservableList) { 4050 } else if (v is ObservableList) {
4049 _upgradeObservableList(v, owner); 4051 _upgradeObservableList(v, owner);
4050 } else if (v is ObservableMap) { 4052 } else if (v is ObservableMap) {
4051 _upgradeObservableMap(v, owner); 4053 _upgradeObservableMap(v, owner);
4052 } 4054 }
4053 } 4055 }
4054 } 4056 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/instance_ref.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698