Chromium Code Reviews| Index: runtime/bin/vmservice/vmservice_dartium.dart |
| diff --git a/runtime/bin/vmservice/vmservice_dartium.dart b/runtime/bin/vmservice/vmservice_dartium.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c1520ec674288aa9735a014729c965611cd7db13 |
| --- /dev/null |
| +++ b/runtime/bin/vmservice/vmservice_dartium.dart |
| @@ -0,0 +1,60 @@ |
| +// 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. |
| + |
| +library vmservice_dartium; |
| + |
| +import 'dart:isolate'; |
| +import 'vmservice.dart'; |
| + |
| +// The receive port that isolate startup / shutdown messages are delivered on. |
| +RawReceivePort _receivePort; |
| +// The receive port that service request messages are delivered on. |
| +RawReceivePort _requestPort; |
| + |
| +// The native method that is called to post the response back to DevTools. |
| +void postResponse(String response, int cookie) native "PostResponse"; |
|
siva
2013/12/06 00:04:18
Can the name PostResponse be qualified as
"vmservi
Cutch
2013/12/06 01:36:08
Agreed. I'm doing this in a cleanup CL that I will
|
| + |
| +void handleRequest(service, String uri, cookie) { |
| + var serviceRequest = new ServiceRequest(); |
| + var r = serviceRequest.parse(Uri.parse(uri)); |
| + if (!r) { |
| + // Did not understand the request uri. |
| + serviceRequest.setErrorResponse('Invalid request uri: ${uri}'); |
| + } else { |
| + var f = service.runningIsolates.route(serviceRequest); |
| + if (f != null) { |
| + f.then((_) { |
| + postResponse(serviceRequest.response, cookie); |
| + }).catchError((e) { }); |
|
siva
2013/12/06 00:04:18
should the catchError case also post an error resp
Cutch
2013/12/06 01:36:08
The only way for catchError to trigger would be if
|
| + return; |
| + } else { |
| + // Nothing responds to this type of request. |
| + serviceRequest.setErrorResponse('No route for: $uri'); |
| + } |
| + } |
| + postResponse(serviceRequest.response, cookie); |
| +} |
| + |
| +main() { |
| + // Create VmService. |
| + var service = new VMService(); |
| + _receivePort = service.receivePort; |
| + _requestPort = new RawReceivePort((message) { |
| + if (message == null) { |
| + return; |
| + } |
| + if (message is! List) { |
| + return; |
| + } |
| + if (message.length != 2) { |
| + return; |
| + } |
| + var uri = message[0]; |
| + if (uri is! String) { |
| + return; |
| + } |
|
siva
2013/12/06 00:04:18
In the above code we seem to ignore invalid messag
Cutch
2013/12/06 01:36:08
This code is verifying that the data from the embe
|
| + var cookie = message[1]; |
| + handleRequest(service, uri, cookie); |
| + }); |
| +} |