| 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 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 // Used for verbose logging. | 658 // Used for verbose logging. |
| 659 bool verbose = false; | 659 bool verbose = false; |
| 660 | 660 |
| 661 // TODO(johnmccutchan): Ensure that isolates do not end up in _cache. | 661 // TODO(johnmccutchan): Ensure that isolates do not end up in _cache. |
| 662 Map<String, ServiceObject> _cache = new Map<String, ServiceObject>(); | 662 Map<String, ServiceObject> _cache = new Map<String, ServiceObject>(); |
| 663 final Map<String, Isolate> _isolateCache = <String, Isolate>{}; | 663 final Map<String, Isolate> _isolateCache = <String, Isolate>{}; |
| 664 | 664 |
| 665 // The list of live isolates, ordered by isolate start time. | 665 // The list of live isolates, ordered by isolate start time. |
| 666 final List<Isolate> isolates = <Isolate>[]; | 666 final List<Isolate> isolates = <Isolate>[]; |
| 667 | 667 |
| 668 final List<Service> services = <Service>[]; |
| 669 |
| 668 String version = 'unknown'; | 670 String version = 'unknown'; |
| 669 String hostCPU; | 671 String hostCPU; |
| 670 String targetCPU; | 672 String targetCPU; |
| 671 int architectureBits; | 673 int architectureBits; |
| 672 bool assertsEnabled = false; | 674 bool assertsEnabled = false; |
| 673 bool typeChecksEnabled = false; | 675 bool typeChecksEnabled = false; |
| 674 int nativeZoneMemoryUsage = 0; | 676 int nativeZoneMemoryUsage = 0; |
| 675 int pid = 0; | 677 int pid = 0; |
| 676 int heapAllocatedMemoryUsage = 0; | 678 int heapAllocatedMemoryUsage = 0; |
| 677 int heapAllocationCount = 0; | 679 int heapAllocationCount = 0; |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 }); | 850 }); |
| 849 } | 851 } |
| 850 | 852 |
| 851 void _dispatchEventToIsolate(ServiceEvent event) { | 853 void _dispatchEventToIsolate(ServiceEvent event) { |
| 852 var isolate = event.isolate; | 854 var isolate = event.isolate; |
| 853 if (isolate != null) { | 855 if (isolate != null) { |
| 854 isolate._onEvent(event); | 856 isolate._onEvent(event); |
| 855 } | 857 } |
| 856 } | 858 } |
| 857 | 859 |
| 860 void _updateService(ServiceEvent event) { |
| 861 switch (event.kind) { |
| 862 case ServiceEvent.kServiceRegistered: |
| 863 services.add(new Service(event.alias, event.method, event.service)); |
| 864 break; |
| 865 case ServiceEvent.kServiceUnregistered: |
| 866 services.removeWhere((s) => s.method == event.method); |
| 867 break; |
| 868 } |
| 869 } |
| 870 |
| 858 Future<Map> _fetchDirect({int count: kDefaultFieldLimit}) async { | 871 Future<Map> _fetchDirect({int count: kDefaultFieldLimit}) async { |
| 859 if (!loaded) { | 872 if (!loaded) { |
| 860 // The vm service relies on these events to keep the VM and | 873 // The vm service relies on these events to keep the VM and |
| 861 // Isolate types up to date. | 874 // Isolate types up to date. |
| 862 try { | 875 try { |
| 863 await listenEventStream(kVMStream, _dispatchEventToIsolate); | 876 await listenEventStream(kVMStream, _dispatchEventToIsolate); |
| 864 await listenEventStream(kIsolateStream, _dispatchEventToIsolate); | 877 await listenEventStream(kIsolateStream, _dispatchEventToIsolate); |
| 865 await listenEventStream(kDebugStream, _dispatchEventToIsolate); | 878 await listenEventStream(kDebugStream, _dispatchEventToIsolate); |
| 866 await listenEventStream(_kGraphStream, _dispatchEventToIsolate); | 879 await listenEventStream(_kGraphStream, _dispatchEventToIsolate); |
| 880 await listenEventStream(kServiceStream, _updateService); |
| 867 } on FakeVMRpcException catch (_) { | 881 } on FakeVMRpcException catch (_) { |
| 868 // ignore FakeVMRpcExceptions here. | 882 // ignore FakeVMRpcExceptions here. |
| 869 } on NetworkRpcException catch (_) { | 883 } on NetworkRpcException catch (_) { |
| 870 // ignore network errors here. | 884 // ignore network errors here. |
| 871 } | 885 } |
| 872 } | 886 } |
| 873 return await invokeRpcNoUpgrade('getVM', {}); | 887 return await invokeRpcNoUpgrade('getVM', {}); |
| 874 } | 888 } |
| 875 | 889 |
| 876 Future setName(String newName) { | 890 Future setName(String newName) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 904 | 918 |
| 905 // Well-known stream ids. | 919 // Well-known stream ids. |
| 906 static const kVMStream = 'VM'; | 920 static const kVMStream = 'VM'; |
| 907 static const kIsolateStream = 'Isolate'; | 921 static const kIsolateStream = 'Isolate'; |
| 908 static const kTimelineStream = 'Timeline'; | 922 static const kTimelineStream = 'Timeline'; |
| 909 static const kDebugStream = 'Debug'; | 923 static const kDebugStream = 'Debug'; |
| 910 static const kGCStream = 'GC'; | 924 static const kGCStream = 'GC'; |
| 911 static const kStdoutStream = 'Stdout'; | 925 static const kStdoutStream = 'Stdout'; |
| 912 static const kStderrStream = 'Stderr'; | 926 static const kStderrStream = 'Stderr'; |
| 913 static const _kGraphStream = '_Graph'; | 927 static const _kGraphStream = '_Graph'; |
| 928 static const kServiceStream = '_Service'; |
| 914 | 929 |
| 915 /// Returns a single-subscription Stream object for a VM event stream. | 930 /// Returns a single-subscription Stream object for a VM event stream. |
| 916 Future<Stream> getEventStream(String streamId) async { | 931 Future<Stream> getEventStream(String streamId) async { |
| 917 var eventStream = _eventStreams.putIfAbsent( | 932 var eventStream = _eventStreams.putIfAbsent( |
| 918 streamId, | 933 streamId, |
| 919 () => new _EventStreamState( | 934 () => new _EventStreamState( |
| 920 this, streamId, () => _eventStreams.remove(streamId))); | 935 this, streamId, () => _eventStreams.remove(streamId))); |
| 921 Stream stream = await eventStream.addStream(); | 936 Stream stream = await eventStream.addStream(); |
| 922 return stream; | 937 return stream; |
| 923 } | 938 } |
| (...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2118 static const kBreakpointAdded = 'BreakpointAdded'; | 2133 static const kBreakpointAdded = 'BreakpointAdded'; |
| 2119 static const kBreakpointResolved = 'BreakpointResolved'; | 2134 static const kBreakpointResolved = 'BreakpointResolved'; |
| 2120 static const kBreakpointRemoved = 'BreakpointRemoved'; | 2135 static const kBreakpointRemoved = 'BreakpointRemoved'; |
| 2121 static const kGraph = '_Graph'; | 2136 static const kGraph = '_Graph'; |
| 2122 static const kGC = 'GC'; | 2137 static const kGC = 'GC'; |
| 2123 static const kInspect = 'Inspect'; | 2138 static const kInspect = 'Inspect'; |
| 2124 static const kDebuggerSettingsUpdate = '_DebuggerSettingsUpdate'; | 2139 static const kDebuggerSettingsUpdate = '_DebuggerSettingsUpdate'; |
| 2125 static const kConnectionClosed = 'ConnectionClosed'; | 2140 static const kConnectionClosed = 'ConnectionClosed'; |
| 2126 static const kLogging = '_Logging'; | 2141 static const kLogging = '_Logging'; |
| 2127 static const kExtension = 'Extension'; | 2142 static const kExtension = 'Extension'; |
| 2128 static const kEditor = '_Editor'; | 2143 static const kServiceRegistered = 'ServiceRegistered'; |
| 2144 static const kServiceUnregistered = 'ServiceUnregistered'; |
| 2129 | 2145 |
| 2130 ServiceEvent._empty(ServiceObjectOwner owner) : super._empty(owner); | 2146 ServiceEvent._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 2131 | 2147 |
| 2132 ServiceEvent.connectionClosed(this.reason) : super._empty(null) { | 2148 ServiceEvent.connectionClosed(this.reason) : super._empty(null) { |
| 2133 kind = kConnectionClosed; | 2149 kind = kConnectionClosed; |
| 2134 } | 2150 } |
| 2135 | 2151 |
| 2136 String kind; | 2152 String kind; |
| 2137 DateTime timestamp; | 2153 DateTime timestamp; |
| 2138 List<M.Breakpoint> pauseBreakpoints; | 2154 List<M.Breakpoint> pauseBreakpoints; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2150 String exceptions; | 2166 String exceptions; |
| 2151 String bytesAsString; | 2167 String bytesAsString; |
| 2152 Map logRecord; | 2168 Map logRecord; |
| 2153 String extensionKind; | 2169 String extensionKind; |
| 2154 Map extensionData; | 2170 Map extensionData; |
| 2155 List timelineEvents; | 2171 List timelineEvents; |
| 2156 String spawnToken; | 2172 String spawnToken; |
| 2157 String spawnError; | 2173 String spawnError; |
| 2158 String editor; | 2174 String editor; |
| 2159 ServiceObject object; | 2175 ServiceObject object; |
| 2176 String method; |
| 2177 String service; |
| 2178 String alias; |
| 2160 | 2179 |
| 2161 int chunkIndex, chunkCount, nodeCount; | 2180 int chunkIndex, chunkCount, nodeCount; |
| 2162 | 2181 |
| 2163 bool get isPauseEvent { | 2182 bool get isPauseEvent { |
| 2164 return (kind == kPauseStart || | 2183 return (kind == kPauseStart || |
| 2165 kind == kPauseExit || | 2184 kind == kPauseExit || |
| 2166 kind == kPauseBreakpoint || | 2185 kind == kPauseBreakpoint || |
| 2167 kind == kPauseInterrupted || | 2186 kind == kPauseInterrupted || |
| 2168 kind == kPauseException || | 2187 kind == kPauseException || |
| 2169 kind == kPausePostRequest || | 2188 kind == kPausePostRequest || |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2246 } | 2265 } |
| 2247 if (map['spawnError'] != null) { | 2266 if (map['spawnError'] != null) { |
| 2248 spawnError = map['spawnError']; | 2267 spawnError = map['spawnError']; |
| 2249 } | 2268 } |
| 2250 if (map['editor'] != null) { | 2269 if (map['editor'] != null) { |
| 2251 editor = map['editor']; | 2270 editor = map['editor']; |
| 2252 } | 2271 } |
| 2253 if (map['object'] != null) { | 2272 if (map['object'] != null) { |
| 2254 object = map['object']; | 2273 object = map['object']; |
| 2255 } | 2274 } |
| 2275 if (map['service'] != null) { |
| 2276 service = map['service']; |
| 2277 } |
| 2278 if (map['method'] != null) { |
| 2279 method = map['method']; |
| 2280 } |
| 2281 if (map['alias'] != null) { |
| 2282 alias = map['alias']; |
| 2283 } |
| 2256 } | 2284 } |
| 2257 | 2285 |
| 2258 String toString() { | 2286 String toString() { |
| 2259 var ownerName = owner.id != null ? owner.id.toString() : owner.name; | 2287 var ownerName = owner.id != null ? owner.id.toString() : owner.name; |
| 2260 if (data == null) { | 2288 if (data == null) { |
| 2261 return "ServiceEvent(owner='${ownerName}', kind='${kind}', " | 2289 return "ServiceEvent(owner='${ownerName}', kind='${kind}', " |
| 2262 "time=${timestamp})"; | 2290 "time=${timestamp})"; |
| 2263 } else { | 2291 } else { |
| 2264 return "ServiceEvent(owner='${ownerName}', kind='${kind}', " | 2292 return "ServiceEvent(owner='${ownerName}', kind='${kind}', " |
| 2265 "data.lengthInBytes=${data.lengthInBytes}, time=${timestamp})"; | 2293 "data.lengthInBytes=${data.lengthInBytes}, time=${timestamp})"; |
| (...skipping 2391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4657 var v = list[i]; | 4685 var v = list[i]; |
| 4658 if ((v is Map) && _isServiceMap(v)) { | 4686 if ((v is Map) && _isServiceMap(v)) { |
| 4659 list[i] = owner.getFromMap(v); | 4687 list[i] = owner.getFromMap(v); |
| 4660 } else if (v is List) { | 4688 } else if (v is List) { |
| 4661 _upgradeList(v, owner); | 4689 _upgradeList(v, owner); |
| 4662 } else if (v is Map) { | 4690 } else if (v is Map) { |
| 4663 _upgradeMap(v, owner); | 4691 _upgradeMap(v, owner); |
| 4664 } | 4692 } |
| 4665 } | 4693 } |
| 4666 } | 4694 } |
| 4695 |
| 4696 class Service implements M.Service { |
| 4697 final String alias; |
| 4698 final String method; |
| 4699 final String service; |
| 4700 |
| 4701 Service(this.alias, this.method, this.service) { |
| 4702 assert(this.alias != null); |
| 4703 assert(this.method != null); |
| 4704 assert(this.service != null); |
| 4705 } |
| 4706 } |
| OLD | NEW |