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

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

Issue 1166433008: 2nd attempt at adding streamListen/streamCancel to the service protocol. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix context objects 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);
11 11
12 String message; 12 String message;
13 } 13 }
14 14
15 /// A ServerRpcException represents an error returned by the VM. 15 /// A ServerRpcException represents an error returned by the VM.
16 class ServerRpcException extends RpcException { 16 class ServerRpcException extends RpcException {
17 /// A list of well-known server error codes. 17 /// A list of well-known server error codes.
18 static const kParseError = -32700; 18 static const kParseError = -32700;
19 static const kInvalidRequest = -32600; 19 static const kInvalidRequest = -32600;
20 static const kMethodNotFound = -32601; 20 static const kMethodNotFound = -32601;
21 static const kInvalidParams = -32602; 21 static const kInvalidParams = -32602;
22 static const kInternalError = -32603; 22 static const kInternalError = -32603;
23 static const kFeatureDisabled = 100; 23 static const kFeatureDisabled = 100;
24 static const kVMMustBePaused = 101; 24 static const kVMMustBePaused = 101;
25 static const kCannotAddBreakpoint = 102; 25 static const kCannotAddBreakpoint = 102;
26 static const kStreamAlreadySubscribed = 103;
27 static const kStreamNotSubscribed = 104;
26 28
27 int code; 29 int code;
28 Map data; 30 Map data;
29 31
30 static _getMessage(Map errorMap) { 32 static _getMessage(Map errorMap) {
31 Map data = errorMap['data']; 33 Map data = errorMap['data'];
32 if (data != null && data['details'] != null) { 34 if (data != null && data['details'] != null) {
33 return data['details']; 35 return data['details'];
34 } else { 36 } else {
35 return errorMap['message']; 37 return errorMap['message'];
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 return invokeRpcNoUpgrade(method, params).then((ObservableMap response) { 555 return invokeRpcNoUpgrade(method, params).then((ObservableMap response) {
554 var obj = new ServiceObject._fromMap(this, response); 556 var obj = new ServiceObject._fromMap(this, response);
555 if ((obj != null) && obj.canCache) { 557 if ((obj != null) && obj.canCache) {
556 String objId = obj.id; 558 String objId = obj.id;
557 _cache.putIfAbsent(objId, () => obj); 559 _cache.putIfAbsent(objId, () => obj);
558 } 560 }
559 return obj; 561 return obj;
560 }); 562 });
561 } 563 }
562 564
563 Future<ObservableMap> _fetchDirect() { 565 Future<ObservableMap> _fetchDirect() async {
564 return invokeRpcNoUpgrade('getVM', {}); 566 if (!loaded) {
567 // TODO(turnidge): Instead of always listening to all streams,
568 // implement a stream abstraction in the service library so
569 // that we only subscribe to the streams we want.
570 await _streamListen('Isolate');
571 await _streamListen('Debug');
572 await _streamListen('GC');
573 await _streamListen('_Echo');
574 await _streamListen('_Graph');
575 }
576 return await invokeRpcNoUpgrade('getVM', {});
565 } 577 }
566 578
567 Future<ServiceObject> getFlagList() { 579 Future<ServiceObject> getFlagList() {
568 return invokeRpc('getFlagList', {}); 580 return invokeRpc('getFlagList', {});
569 } 581 }
570 582
583 Future<ServiceObject> _streamListen(String streamId) {
584 Map params = {
585 'streamId': streamId,
586 };
587 return invokeRpc('streamListen', params);
588 }
589
571 /// Force the VM to disconnect. 590 /// Force the VM to disconnect.
572 void disconnect(); 591 void disconnect();
573 /// Completes when the VM first connects. 592 /// Completes when the VM first connects.
574 Future get onConnect; 593 Future get onConnect;
575 /// Completes when the VM disconnects or there was an error connecting. 594 /// Completes when the VM disconnects or there was an error connecting.
576 Future get onDisconnect; 595 Future get onDisconnect;
577 596
578 void _update(ObservableMap map, bool mapIsRef) { 597 void _update(ObservableMap map, bool mapIsRef) {
579 if (mapIsRef) { 598 if (mapIsRef) {
580 return; 599 return;
(...skipping 2667 matching lines...) Expand 10 before | Expand all | Expand 10 after
3248 var v = list[i]; 3267 var v = list[i];
3249 if ((v is ObservableMap) && _isServiceMap(v)) { 3268 if ((v is ObservableMap) && _isServiceMap(v)) {
3250 list[i] = owner.getFromMap(v); 3269 list[i] = owner.getFromMap(v);
3251 } else if (v is ObservableList) { 3270 } else if (v is ObservableList) {
3252 _upgradeObservableList(v, owner); 3271 _upgradeObservableList(v, owner);
3253 } else if (v is ObservableMap) { 3272 } else if (v is ObservableMap) {
3254 _upgradeObservableMap(v, owner); 3273 _upgradeObservableMap(v, owner);
3255 } 3274 }
3256 } 3275 }
3257 } 3276 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/service_ref.dart ('k') | runtime/observatory/tests/service/contexts_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698