Chromium Code Reviews| Index: runtime/bin/vmservice/running_isolate.dart |
| diff --git a/runtime/bin/vmservice/running_isolate.dart b/runtime/bin/vmservice/running_isolate.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8cdf79d619675c5b51a9d5fed28196e79ee08a65 |
| --- /dev/null |
| +++ b/runtime/bin/vmservice/running_isolate.dart |
| @@ -0,0 +1,52 @@ |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +part of vmservice; |
| + |
| +class RunningIsolate implements ServiceRequestRouter { |
| + final SendPort sendPort; |
| + String id = 'Unknown'; |
| + |
| + |
| + RunningIsolate(this.sendPort); |
| + |
| + |
|
siva
2013/07/19 17:41:16
extraa blank lines here and above?
Cutch
2013/07/19 18:15:02
Done.
|
| + Future sendMessage(String request) { |
| + final completer = new Completer.sync(); |
| + final receivePort = new ReceivePort(); |
| + sendServiceMessage(sendPort, receivePort, request); |
| + receivePort.receive((value, ignoreReplyTo) { |
| + receivePort.close(); |
| + if (value is Exception) { |
| + completer.completeError(value); |
| + } else { |
| + completer.complete(value); |
| + } |
| + }); |
| + return completer.future; |
| + } |
| + |
| + |
| + bool route(ServiceRequest request) { |
| + // Do nothing for now. |
| + return false; |
| + } |
| + |
| + void sendIdRequest() { |
| + String request = JSON.stringify({'p': ['id'], 'k': [], 'v': []}); |
| + sendMessage(request).then(_handleIdResponse); |
| + } |
| + |
| + void _handleIdResponse(responseString) { |
| + Map response; |
|
siva
2013/07/19 17:41:16
ditto comment regarding style guide preference for
Cutch
2013/07/19 18:15:02
Done.
|
| + try { |
| + response = JSON.parse(responseString); |
| + } catch (e) { |
| + id = 'Error retrieving isolate id.'; |
| + return; |
| + } |
| + id = response['id']; |
| + } |
| + |
| +} |