Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(564)

Side by Side Diff: runtime/bin/vmservice/vmservice_dartium.dart

Issue 106193003: Cleanup VM service (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/vmservice/vmservice.dart ('k') | runtime/bin/vmservice_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_dartium; 5 library vmservice_dartium;
6 6
7 import 'dart:isolate'; 7 import 'dart:isolate';
8 import 'vmservice.dart'; 8 import 'vmservice.dart';
9 9
10 // The receive port that isolate startup / shutdown messages are delivered on. 10 // The receive port that isolate startup / shutdown messages are delivered on.
11 RawReceivePort _receivePort; 11 RawReceivePort _receivePort;
12 // The receive port that service request messages are delivered on. 12 // The receive port that service request messages are delivered on.
13 RawReceivePort _requestPort; 13 RawReceivePort _requestPort;
14 14
15 // The native method that is called to post the response back to DevTools. 15 // The native method that is called to post the response back to DevTools.
16 void postResponse(String response, int cookie) native "PostResponse"; 16 void postResponse(String response, int cookie) native "VMService_PostResponse";
17 17
18 void handleRequest(service, String uri, cookie) { 18 void handleRequest(service, String uri, cookie) {
19 var serviceRequest = new ServiceRequest(); 19 var serviceRequest = new ServiceRequest();
20 var r = serviceRequest.parse(Uri.parse(uri)); 20 var r = serviceRequest.parse(Uri.parse(uri));
21 if (!r) { 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); 22 var f = service.runningIsolates.route(serviceRequest);
26 if (f != null) { 23 assert(f != null);
27 f.then((_) { 24 f.then((_) {
28 postResponse(serviceRequest.response, cookie); 25 postResponse(serviceRequest.response, cookie);
29 }).catchError((e) { }); 26 }).catchError((e) {
30 return; 27 // Error posting response back to Dartium.
31 } else { 28 });
32 // Nothing responds to this type of request. 29 return;
33 serviceRequest.setErrorResponse('No route for: $uri');
34 }
35 } 30 }
36 postResponse(serviceRequest.response, cookie); 31 postResponse(serviceRequest.response, cookie);
37 } 32 }
38 33
39 main() { 34 main() {
40 // Create VmService. 35 // Create VmService.
41 var service = new VMService(); 36 var service = new VMService();
42 _receivePort = service.receivePort; 37 _receivePort = service.receivePort;
43 _requestPort = new RawReceivePort((message) { 38 _requestPort = new RawReceivePort((message) {
44 if (message == null) { 39 if (message == null) {
45 return; 40 return;
46 } 41 }
47 if (message is! List) { 42 if (message is! List) {
48 return; 43 return;
49 } 44 }
50 if (message.length != 2) { 45 if (message.length != 2) {
51 return; 46 return;
52 } 47 }
53 var uri = message[0]; 48 var uri = message[0];
54 if (uri is! String) { 49 if (uri is! String) {
55 return; 50 return;
56 } 51 }
57 var cookie = message[1]; 52 var cookie = message[1];
58 handleRequest(service, uri, cookie); 53 handleRequest(service, uri, cookie);
59 }); 54 });
60 } 55 }
OLDNEW
« no previous file with comments | « runtime/bin/vmservice/vmservice.dart ('k') | runtime/bin/vmservice_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698