| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 vmservice; | 5 library vmservice; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:json' as JSON; | 8 import 'dart:json' as JSON; |
| 9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
| 10 import 'dart:typed_data'; | 10 import 'dart:typed_data'; |
| 11 import 'dart:utf' as UTF; | 11 import 'dart:utf' as UTF; |
| 12 | 12 |
| 13 part 'constants.dart'; | 13 part 'constants.dart'; |
| 14 part 'resources.dart'; | 14 part 'resources.dart'; |
| 15 part 'running_isolate.dart'; | 15 part 'running_isolate.dart'; |
| 16 part 'running_isolates.dart'; | 16 part 'running_isolates.dart'; |
| 17 part 'service_request.dart'; | 17 part 'service_request.dart'; |
| 18 part 'service_request_router.dart'; | 18 part 'service_request_router.dart'; |
| 19 | 19 |
| 20 class VMService { | 20 class VMService { |
| 21 static VMService _instance; | 21 static VMService _instance; |
| 22 RunningIsolates runningIsolates = new RunningIsolates(); | 22 RunningIsolates runningIsolates = new RunningIsolates(); |
| 23 | 23 |
| 24 void controlMessageHandler(int code, SendPort sp) { | 24 void controlMessageHandler(int code, SendPort sp, String name) { |
| 25 switch (code) { | 25 switch (code) { |
| 26 case Constants.ISOLATE_STARTUP_MESSAGE_ID: | 26 case Constants.ISOLATE_STARTUP_MESSAGE_ID: |
| 27 runningIsolates.isolateStartup(sp); | 27 runningIsolates.isolateStartup(sp, name); |
| 28 break; | 28 break; |
| 29 case Constants.ISOLATE_SHUTDOWN_MESSAGE_ID: | 29 case Constants.ISOLATE_SHUTDOWN_MESSAGE_ID: |
| 30 runningIsolates.isolateShutdown(sp); | 30 runningIsolates.isolateShutdown(sp); |
| 31 break; | 31 break; |
| 32 } | 32 } |
| 33 } | 33 } |
| 34 | 34 |
| 35 void messageHandler(message, SendPort replyTo) { | 35 void messageHandler(message, SendPort replyTo) { |
| 36 if (message is List && message.length == 2) { | 36 if (message is List && message.length == 3) { |
| 37 controlMessageHandler(message[0], message[1]); | 37 controlMessageHandler(message[0], message[1], message[2]); |
| 38 } | 38 } |
| 39 } | 39 } |
| 40 | 40 |
| 41 VMService._internal() { | 41 VMService._internal() { |
| 42 port.receive(messageHandler); | 42 port.receive(messageHandler); |
| 43 } | 43 } |
| 44 | 44 |
| 45 factory VMService() { | 45 factory VMService() { |
| 46 if (VMService._instance == null) { | 46 if (VMService._instance == null) { |
| 47 VMService._instance = new VMService._internal(); | 47 VMService._instance = new VMService._internal(); |
| 48 } | 48 } |
| 49 return _instance; | 49 return _instance; |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 void sendServiceMessage(SendPort sp, ReceivePort rp, Object m) | 53 void sendServiceMessage(SendPort sp, ReceivePort rp, Object m) |
| 54 native "SendServiceMessage"; | 54 native "SendServiceMessage"; |
| OLD | NEW |