Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library vmservice_dartium; | |
| 6 | |
| 7 import 'dart:isolate'; | |
| 8 import 'vmservice.dart'; | |
| 9 | |
| 10 // The receive port that isolate startup / shutdown messages are delivered on. | |
| 11 RawReceivePort _receivePort; | |
| 12 // The receive port that service request messages are delivered on. | |
| 13 RawReceivePort _requestPort; | |
| 14 | |
| 15 // The native method that is called to post the response back to DevTools. | |
| 16 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
| |
| 17 | |
| 18 void handleRequest(service, String uri, cookie) { | |
| 19 var serviceRequest = new ServiceRequest(); | |
| 20 var r = serviceRequest.parse(Uri.parse(uri)); | |
| 21 if (!r) { | |
| 22 // Did not understand the request uri. | |
| 23 serviceRequest.setErrorResponse('Invalid request uri: ${uri}'); | |
| 24 } else { | |
| 25 var f = service.runningIsolates.route(serviceRequest); | |
| 26 if (f != null) { | |
| 27 f.then((_) { | |
| 28 postResponse(serviceRequest.response, cookie); | |
| 29 }).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
| |
| 30 return; | |
| 31 } else { | |
| 32 // Nothing responds to this type of request. | |
| 33 serviceRequest.setErrorResponse('No route for: $uri'); | |
| 34 } | |
| 35 } | |
| 36 postResponse(serviceRequest.response, cookie); | |
| 37 } | |
| 38 | |
| 39 main() { | |
| 40 // Create VmService. | |
| 41 var service = new VMService(); | |
| 42 _receivePort = service.receivePort; | |
| 43 _requestPort = new RawReceivePort((message) { | |
| 44 if (message == null) { | |
| 45 return; | |
| 46 } | |
| 47 if (message is! List) { | |
| 48 return; | |
| 49 } | |
| 50 if (message.length != 2) { | |
| 51 return; | |
| 52 } | |
| 53 var uri = message[0]; | |
| 54 if (uri is! String) { | |
| 55 return; | |
| 56 } | |
|
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
| |
| 57 var cookie = message[1]; | |
| 58 handleRequest(service, uri, cookie); | |
| 59 }); | |
| 60 } | |
| OLD | NEW |