| OLD | NEW |
| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 /// A NetworkRpcException is used to indicate that an rpc has | 71 /// A NetworkRpcException is used to indicate that an rpc has |
| 72 /// been canceled due to network error. | 72 /// been canceled due to network error. |
| 73 class NetworkRpcException extends RpcException | 73 class NetworkRpcException extends RpcException |
| 74 implements M.ConnectionException { | 74 implements M.ConnectionException { |
| 75 NetworkRpcException(String message) : super(message); | 75 NetworkRpcException(String message) : super(message); |
| 76 | 76 |
| 77 String toString() => 'NetworkRpcException(${message})'; | 77 String toString() => 'NetworkRpcException(${message})'; |
| 78 } | 78 } |
| 79 | 79 |
| 80 Future<ServiceObject> ignoreNetworkErrors( |
| 81 Object error, [ServiceObject resultOnNetworkError = null]) { |
| 82 if (error is NetworkRpcException) { |
| 83 return new Future.value(resultOnNetworkError); |
| 84 } |
| 85 return new Future.error(error); |
| 86 } |
| 87 |
| 80 class MalformedResponseRpcException extends RpcException { | 88 class MalformedResponseRpcException extends RpcException { |
| 81 MalformedResponseRpcException(String message, this.response) : super(message); | 89 MalformedResponseRpcException(String message, this.response) : super(message); |
| 82 | 90 |
| 83 Map response; | 91 Map response; |
| 84 | 92 |
| 85 String toString() => 'MalformedResponseRpcException(${message})'; | 93 String toString() => 'MalformedResponseRpcException(${message})'; |
| 86 } | 94 } |
| 87 | 95 |
| 88 class FakeVMRpcException extends RpcException { | 96 class FakeVMRpcException extends RpcException { |
| 89 FakeVMRpcException(String message) : super(message); | 97 FakeVMRpcException(String message) : super(message); |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 void _update(Map map, bool mapIsRef) { | 401 void _update(Map map, bool mapIsRef) { |
| 394 if (map['class'] != null) { | 402 if (map['class'] != null) { |
| 395 // Sent with refs for some types. Load it if available, but don't clobber | 403 // Sent with refs for some types. Load it if available, but don't clobber |
| 396 // it with null for kinds that only send if for full responses. | 404 // it with null for kinds that only send if for full responses. |
| 397 clazz = map['class']; | 405 clazz = map['class']; |
| 398 } | 406 } |
| 399 | 407 |
| 400 // Load the full class object if the isolate is runnable. | 408 // Load the full class object if the isolate is runnable. |
| 401 if (clazz != null) { | 409 if (clazz != null) { |
| 402 if (clazz.isolate.runnable) { | 410 if (clazz.isolate.runnable) { |
| 403 clazz.load(); | 411 // No one awaits on this request so we silence any network errors |
| 412 // that occur here but forward other errors. |
| 413 clazz.load().catchError((error) => ignoreNetworkErrors(error, clazz)); |
| 404 } | 414 } |
| 405 } | 415 } |
| 406 | 416 |
| 407 if (mapIsRef) { | 417 if (mapIsRef) { |
| 408 return; | 418 return; |
| 409 } | 419 } |
| 410 size = map['size']; | 420 size = map['size']; |
| 411 } | 421 } |
| 412 } | 422 } |
| 413 | 423 |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 } | 863 } |
| 854 | 864 |
| 855 Future<ServiceObject> getFlagList() { | 865 Future<ServiceObject> getFlagList() { |
| 856 return invokeRpc('getFlagList', {}); | 866 return invokeRpc('getFlagList', {}); |
| 857 } | 867 } |
| 858 | 868 |
| 859 Future<ServiceObject> _streamListen(String streamId) { | 869 Future<ServiceObject> _streamListen(String streamId) { |
| 860 Map params = { | 870 Map params = { |
| 861 'streamId': streamId, | 871 'streamId': streamId, |
| 862 }; | 872 }; |
| 863 return invokeRpc('streamListen', params).catchError((e) { | 873 // Ignore network errors on stream listen. |
| 864 // Ignore network errors on stream listen. | 874 return invokeRpc('streamListen', params).catchError( |
| 865 if (e is NetworkRpcException) { | 875 (e) => ignoreNetworkErrors(e)); |
| 866 return null; | |
| 867 } | |
| 868 }); | |
| 869 } | 876 } |
| 870 | 877 |
| 871 Future<ServiceObject> _streamCancel(String streamId) { | 878 Future<ServiceObject> _streamCancel(String streamId) { |
| 872 Map params = { | 879 Map params = { |
| 873 'streamId': streamId, | 880 'streamId': streamId, |
| 874 }; | 881 }; |
| 875 return invokeRpc('streamCancel', params).catchError((e) { | 882 // Ignore network errors on stream cancel. |
| 876 // Ignore network errors on stream cancel. | 883 return invokeRpc('streamCancel', params).catchError( |
| 877 if (e is NetworkRpcException) { | 884 (e) => ignoreNetworkErrors(e)); |
| 878 return null; | |
| 879 } | |
| 880 }); | |
| 881 } | 885 } |
| 882 | 886 |
| 883 // A map from stream id to event stream state. | 887 // A map from stream id to event stream state. |
| 884 Map<String, _EventStreamState> _eventStreams = {}; | 888 Map<String, _EventStreamState> _eventStreams = {}; |
| 885 | 889 |
| 886 // Well-known stream ids. | 890 // Well-known stream ids. |
| 887 static const kVMStream = 'VM'; | 891 static const kVMStream = 'VM'; |
| 888 static const kIsolateStream = 'Isolate'; | 892 static const kIsolateStream = 'Isolate'; |
| 889 static const kTimelineStream = 'Timeline'; | 893 static const kTimelineStream = 'Timeline'; |
| 890 static const kDebugStream = 'Debug'; | 894 static const kDebugStream = 'Debug'; |
| (...skipping 3464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4355 var v = list[i]; | 4359 var v = list[i]; |
| 4356 if ((v is Map) && _isServiceMap(v)) { | 4360 if ((v is Map) && _isServiceMap(v)) { |
| 4357 list[i] = owner.getFromMap(v); | 4361 list[i] = owner.getFromMap(v); |
| 4358 } else if (v is List) { | 4362 } else if (v is List) { |
| 4359 _upgradeList(v, owner); | 4363 _upgradeList(v, owner); |
| 4360 } else if (v is Map) { | 4364 } else if (v is Map) { |
| 4361 _upgradeMap(v, owner); | 4365 _upgradeMap(v, owner); |
| 4362 } | 4366 } |
| 4363 } | 4367 } |
| 4364 } | 4368 } |
| OLD | NEW |