OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library dart._vmservice; | 5 library dart._vmservice; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 import 'dart:convert'; | 9 import 'dart:convert'; |
10 import 'dart:isolate'; | 10 import 'dart:isolate'; |
11 import 'dart:typed_data'; | 11 import 'dart:typed_data'; |
12 | 12 |
13 part 'asset.dart'; | 13 part 'asset.dart'; |
14 part 'client.dart'; | 14 part 'client.dart'; |
15 part 'constants.dart'; | 15 part 'constants.dart'; |
16 part 'running_isolate.dart'; | 16 part 'running_isolate.dart'; |
17 part 'running_isolates.dart'; | 17 part 'running_isolates.dart'; |
18 part 'message.dart'; | 18 part 'message.dart'; |
19 part 'message_router.dart'; | 19 part 'message_router.dart'; |
20 | 20 |
21 final RawReceivePort isolateLifecyclePort = new RawReceivePort(); | 21 final RawReceivePort isolateLifecyclePort = new RawReceivePort(); |
22 final RawReceivePort scriptLoadPort = new RawReceivePort(); | 22 final RawReceivePort scriptLoadPort = new RawReceivePort(); |
23 | 23 |
| 24 // This is for use by the embedder. It is a map from the isolateId to |
| 25 // anything. When an isolate goes away, it will be removed from this map. |
| 26 final Map<int, dynamic> isolateEmbedderData = new Map<int, dynamic>(); |
| 27 |
24 // These must be kept in sync with the declarations in vm/json_stream.h. | 28 // These must be kept in sync with the declarations in vm/json_stream.h. |
25 const kInvalidParams = -32602; | 29 const kInvalidParams = -32602; |
26 const kInternalError = -32603; | 30 const kInternalError = -32603; |
27 const kStreamAlreadySubscribed = 103; | 31 const kStreamAlreadySubscribed = 103; |
28 const kStreamNotSubscribed = 104; | 32 const kStreamNotSubscribed = 104; |
29 | 33 |
30 var _errorMessages = { | 34 var _errorMessages = { |
31 kInvalidParams: 'Invalid params', | 35 kInvalidParams: 'Invalid params', |
32 kInternalError: 'Internal error', | 36 kInternalError: 'Internal error', |
33 kStreamAlreadySubscribed: 'Stream already subscribed', | 37 kStreamAlreadySubscribed: 'Stream already subscribed', |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 void _controlMessageHandler(int code, | 121 void _controlMessageHandler(int code, |
118 int portId, | 122 int portId, |
119 SendPort sp, | 123 SendPort sp, |
120 String name) { | 124 String name) { |
121 switch (code) { | 125 switch (code) { |
122 case Constants.ISOLATE_STARTUP_MESSAGE_ID: | 126 case Constants.ISOLATE_STARTUP_MESSAGE_ID: |
123 runningIsolates.isolateStartup(portId, sp, name); | 127 runningIsolates.isolateStartup(portId, sp, name); |
124 break; | 128 break; |
125 case Constants.ISOLATE_SHUTDOWN_MESSAGE_ID: | 129 case Constants.ISOLATE_SHUTDOWN_MESSAGE_ID: |
126 runningIsolates.isolateShutdown(portId, sp); | 130 runningIsolates.isolateShutdown(portId, sp); |
| 131 isolateEmbedderData.remove(portId); |
127 break; | 132 break; |
128 } | 133 } |
129 } | 134 } |
130 | 135 |
131 Future _exit() async { | 136 Future _exit() async { |
132 // Stop the server. | 137 // Stop the server. |
133 if (VMServiceEmbedderHooks.serverStop != null) { | 138 if (VMServiceEmbedderHooks.serverStop != null) { |
134 await VMServiceEmbedderHooks.serverStop(); | 139 await VMServiceEmbedderHooks.serverStop(); |
135 } | 140 } |
136 | 141 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 external void onServerAddressChange(String address); | 338 external void onServerAddressChange(String address); |
334 | 339 |
335 /// Subscribe to a service stream. | 340 /// Subscribe to a service stream. |
336 external bool _vmListenStream(String streamId); | 341 external bool _vmListenStream(String streamId); |
337 | 342 |
338 /// Cancel a subscription to a service stream. | 343 /// Cancel a subscription to a service stream. |
339 external void _vmCancelStream(String streamId); | 344 external void _vmCancelStream(String streamId); |
340 | 345 |
341 /// Get the bytes to the tar archive. | 346 /// Get the bytes to the tar archive. |
342 external Uint8List _requestAssets(); | 347 external Uint8List _requestAssets(); |
OLD | NEW |