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

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

Issue 107173003: Add vmservice_dartium.dart script (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/resources.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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";
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) { });
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 }
57 var cookie = message[1];
58 handleRequest(service, uri, cookie);
59 });
60 }
OLDNEW
« no previous file with comments | « runtime/bin/resources.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698