Chromium Code Reviews| 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:convert"; | 8 import "dart:convert"; |
| 9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
| 10 import 'dart:typed_data'; | 10 import 'dart:typed_data'; |
| 11 | 11 |
| 12 part 'constants.dart'; | 12 part 'constants.dart'; |
| 13 part 'resources.dart'; | 13 part 'resources.dart'; |
| 14 part 'running_isolate.dart'; | 14 part 'running_isolate.dart'; |
| 15 part 'running_isolates.dart'; | 15 part 'running_isolates.dart'; |
| 16 part 'service_request.dart'; | 16 part 'service_request.dart'; |
| 17 part 'service_request_router.dart'; | 17 part 'service_request_router.dart'; |
| 18 | 18 |
| 19 class VMService { | 19 class VMService { |
| 20 static VMService _instance; | 20 static VMService _instance; |
| 21 RunningIsolates runningIsolates = new RunningIsolates(); | 21 RunningIsolates runningIsolates = new RunningIsolates(); |
| 22 ReceivePort _receivePort; | |
|
floitsch
2013/10/24 15:28:30
maybe:
final ReceivePort receivePort = new Receive
Cutch
2013/10/25 01:21:57
Done.
| |
| 23 ReceivePort get receivePort => _receivePort; | |
| 22 | 24 |
| 23 void controlMessageHandler(int code, SendPort sp, String name) { | 25 void controlMessageHandler(int code, SendPort sp, String name) { |
| 24 switch (code) { | 26 switch (code) { |
| 25 case Constants.ISOLATE_STARTUP_MESSAGE_ID: | 27 case Constants.ISOLATE_STARTUP_MESSAGE_ID: |
| 26 runningIsolates.isolateStartup(sp, name); | 28 runningIsolates.isolateStartup(sp, name); |
| 27 break; | 29 break; |
| 28 case Constants.ISOLATE_SHUTDOWN_MESSAGE_ID: | 30 case Constants.ISOLATE_SHUTDOWN_MESSAGE_ID: |
| 29 runningIsolates.isolateShutdown(sp); | 31 runningIsolates.isolateShutdown(sp); |
| 30 break; | 32 break; |
| 31 } | 33 } |
| 32 } | 34 } |
| 33 | 35 |
| 34 void messageHandler(message, SendPort replyTo) { | 36 void messageHandler(message, SendPort replyTo) { |
| 35 if (message is List && message.length == 3) { | 37 if (message is List && message.length == 3) { |
| 36 controlMessageHandler(message[0], message[1], message[2]); | 38 controlMessageHandler(message[0], message[1], message[2]); |
| 37 } | 39 } |
| 38 } | 40 } |
| 39 | 41 |
| 40 VMService._internal() { | 42 VMService._internal() { |
| 41 port.receive(messageHandler); | 43 port.close(); |
|
Ivan Posva
2013/10/25 00:30:27
If you do not ever touch the default port, you sho
Cutch
2013/10/25 01:21:57
Removed.
| |
| 44 _receivePort = new ReceivePort(); | |
| 45 _receivePort.receive(messageHandler); | |
| 42 } | 46 } |
| 43 | 47 |
| 44 factory VMService() { | 48 factory VMService() { |
| 45 if (VMService._instance == null) { | 49 if (VMService._instance == null) { |
| 46 VMService._instance = new VMService._internal(); | 50 VMService._instance = new VMService._internal(); |
| 47 } | 51 } |
| 48 return _instance; | 52 return _instance; |
| 49 } | 53 } |
| 50 } | 54 } |
| 51 | 55 |
| 52 void sendServiceMessage(SendPort sp, ReceivePort rp, Object m) | 56 void sendServiceMessage(SendPort sp, ReceivePort rp, Object m) |
| 53 native "SendServiceMessage"; | 57 native "SendServiceMessage"; |
| OLD | NEW |