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

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

Issue 895943002: Support root-level json rpc requests in the vm service. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 | « no previous file | runtime/vm/service.h » ('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 static int LexicalSortName(ServiceObject o1, ServiceObject o2) { 10 static int LexicalSortName(ServiceObject o1, ServiceObject o2) {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 Future<ServiceObject> load() { 204 Future<ServiceObject> load() {
205 if (loaded) { 205 if (loaded) {
206 return new Future.value(this); 206 return new Future.value(this);
207 } 207 }
208 // Call reload which will fill in the entire object. 208 // Call reload which will fill in the entire object.
209 return reload(); 209 return reload();
210 } 210 }
211 211
212 Future<ServiceObject> _inProgressReload; 212 Future<ServiceObject> _inProgressReload;
213 213
214 Future<ObservableMap> _fetchDirect() {
215 Map params = {
216 'objectId': id,
217 };
218 return isolate.invokeRpcNoUpgrade('getObject', params);
219 }
220
214 /// Reload [this]. Returns a future which completes to [this] or 221 /// Reload [this]. Returns a future which completes to [this] or
215 /// a [ServiceError]. 222 /// a [ServiceError].
216 Future<ServiceObject> reload() { 223 Future<ServiceObject> reload() {
217 if (id == '') { 224 if (id == '') {
218 // Errors don't have ids. 225 // Errors don't have ids.
219 assert(type == 'Error'); 226 assert(type == 'Error');
220 return new Future.value(this); 227 return new Future.value(this);
221 } 228 }
222 if (loaded && immutable) { 229 if (loaded && immutable) {
223 return new Future.value(this); 230 return new Future.value(this);
224 } 231 }
225 if (_inProgressReload == null) { 232 if (_inProgressReload == null) {
226 _inProgressReload = vm.getAsMap(link).then((ObservableMap map) { 233 _inProgressReload = _fetchDirect().then((ObservableMap map) {
227 var mapType = _stripRef(map['type']); 234 var mapType = _stripRef(map['type']);
228 if (mapType != _type) { 235 if (mapType != _type) {
229 // If the type changes, return a new object instead of 236 // If the type changes, return a new object instead of
230 // updating the existing one. 237 // updating the existing one.
231 // 238 //
232 // TODO(turnidge): Check for vmType changing as well? 239 // TODO(turnidge): Check for vmType changing as well?
233 assert(mapType == 'Error' || mapType == 'Sentinel'); 240 assert(mapType == 'Error' || mapType == 'Sentinel');
234 return new ServiceObject._fromMap(owner, map); 241 return new ServiceObject._fromMap(owner, map);
235 } 242 }
236 update(map); 243 update(map);
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 // through the JsonRpc interface, we will need to start checking the 589 // through the JsonRpc interface, we will need to start checking the
583 // cache before making the request here. For now, we just make the 590 // cache before making the request here. For now, we just make the
584 // request without bothering with the cache. 591 // request without bothering with the cache.
585 return invokeRpcNoUpgrade(method, params).then((ObservableMap response) { 592 return invokeRpcNoUpgrade(method, params).then((ObservableMap response) {
586 var obj = new ServiceObject._fromMap(this, response); 593 var obj = new ServiceObject._fromMap(this, response);
587 // TODO(turnidge): Put the object into the cache if we can. 594 // TODO(turnidge): Put the object into the cache if we can.
588 return obj; 595 return obj;
589 }); 596 });
590 } 597 }
591 598
599 Future<ObservableMap> _fetchDirect() {
600 return invokeRpcNoUpgrade('getVM', {});
601 }
602
592 /// Force the VM to disconnect. 603 /// Force the VM to disconnect.
593 void disconnect(); 604 void disconnect();
594 /// Completes when the VM first connects. 605 /// Completes when the VM first connects.
595 Future get onConnect; 606 Future get onConnect;
596 /// Completes when the VM disconnects or there was an error connecting. 607 /// Completes when the VM disconnects or there was an error connecting.
597 Future get onDisconnect; 608 Future get onDisconnect;
598 609
599 void _update(ObservableMap map, bool mapIsRef) { 610 void _update(ObservableMap map, bool mapIsRef) {
600 if (mapIsRef) { 611 if (mapIsRef) {
601 return; 612 return;
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 } 913 }
903 return obj; 914 return obj;
904 }); 915 });
905 } 916 }
906 917
907 Future<ObservableMap> invokeRpcNoUpgrade(String method, Map params) { 918 Future<ObservableMap> invokeRpcNoUpgrade(String method, Map params) {
908 params['isolate'] = id; 919 params['isolate'] = id;
909 return vm.invokeRpcNoUpgrade(method, params); 920 return vm.invokeRpcNoUpgrade(method, params);
910 } 921 }
911 922
912
913 Future<ServiceObject> invokeRpc(String method, Map params) { 923 Future<ServiceObject> invokeRpc(String method, Map params) {
914 return invokeRpcNoUpgrade(method, params).then((ObservableMap response) { 924 return invokeRpcNoUpgrade(method, params).then((ObservableMap response) {
915 // TODO - needs to cache!!! move to constructor? 925 // TODO - needs to cache!!! move to constructor?
916 return new ServiceObject._fromMap(this, response); 926 return new ServiceObject._fromMap(this, response);
917 }); 927 });
918 } 928 }
919 929
930 Future<ObservableMap> _fetchDirect() {
931 return invokeRpcNoUpgrade('getIsolate', {});
932 }
933
920 @observable Class objectClass; 934 @observable Class objectClass;
921 @observable final rootClasses = new ObservableList<Class>(); 935 @observable final rootClasses = new ObservableList<Class>();
922 936
923 @observable Library rootLib; 937 @observable Library rootLib;
924 @observable ObservableList<Library> libraries = 938 @observable ObservableList<Library> libraries =
925 new ObservableList<Library>(); 939 new ObservableList<Library>();
926 @observable ObservableMap topFrame; 940 @observable ObservableMap topFrame;
927 941
928 @observable String name; 942 @observable String name;
929 @observable String vmName; 943 @observable String vmName;
(...skipping 1860 matching lines...) Expand 10 before | Expand all | Expand 10 after
2790 2804
2791 final ObservableList<MetricSample> samples = 2805 final ObservableList<MetricSample> samples =
2792 new ObservableList<MetricSample>(); 2806 new ObservableList<MetricSample>();
2793 int _sampleBufferSize = 100; 2807 int _sampleBufferSize = 100;
2794 int get sampleBufferSize => _sampleBufferSize; 2808 int get sampleBufferSize => _sampleBufferSize;
2795 set sampleBufferSize(int size) { 2809 set sampleBufferSize(int size) {
2796 _sampleBufferSize = size; 2810 _sampleBufferSize = size;
2797 _removeOld(); 2811 _removeOld();
2798 } 2812 }
2799 2813
2814 Future<ObservableMap> _fetchDirect() {
2815 // TODO(johnmmccutchan): Make this use json rpc.
2816 return vm.getAsMap(link);
2817 }
2818
2819
2800 void addSample(MetricSample sample) { 2820 void addSample(MetricSample sample) {
2801 samples.add(sample); 2821 samples.add(sample);
2802 _removeOld(); 2822 _removeOld();
2803 } 2823 }
2804 2824
2805 void _removeOld() { 2825 void _removeOld() {
2806 // TODO(johnmccutchan): If this becomes hot, consider using a circular 2826 // TODO(johnmccutchan): If this becomes hot, consider using a circular
2807 // buffer. 2827 // buffer.
2808 if (samples.length > _sampleBufferSize) { 2828 if (samples.length > _sampleBufferSize) {
2809 int count = samples.length - _sampleBufferSize; 2829 int count = samples.length - _sampleBufferSize;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2911 var v = list[i]; 2931 var v = list[i];
2912 if ((v is ObservableMap) && _isServiceMap(v)) { 2932 if ((v is ObservableMap) && _isServiceMap(v)) {
2913 list[i] = owner.getFromMap(v); 2933 list[i] = owner.getFromMap(v);
2914 } else if (v is ObservableList) { 2934 } else if (v is ObservableList) {
2915 _upgradeObservableList(v, owner); 2935 _upgradeObservableList(v, owner);
2916 } else if (v is ObservableMap) { 2936 } else if (v is ObservableMap) {
2917 _upgradeObservableMap(v, owner); 2937 _upgradeObservableMap(v, owner);
2918 } 2938 }
2919 } 2939 }
2920 } 2940 }
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698