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

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

Issue 112223002: WebSocket client for 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
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 "VMService_PostResponse"; 16 void postResponse(String response, int cookie) native "VMService_PostResponse";
17 17
18 void handleRequest(service, String uri, cookie) { 18 void handleMessage(service, uri, cookie) {
19 var serviceRequest = new ServiceRequest(); 19 var message = new Message.fromUri(uri);
turnidge 2013/12/11 17:56:07 So dartium will not support the /ws clients yet, r
Cutch 2013/12/12 22:37:42 Correct but the Observatory in Dartium communicate
20 var r = serviceRequest.parse(Uri.parse(uri)); 20 var client = new HttpRequestClient(request, service);
21 if (r) { 21 message.future.then((response) {
22 var f = service.runningIsolates.route(serviceRequest); 22 try {
23 assert(f != null); 23 postResponse(response, cookie);
24 f.then((_) { 24 } catch (_) {
25 postResponse(serviceRequest.response, cookie);
26 }).catchError((e) {
27 // Error posting response back to Dartium. 25 // Error posting response back to Dartium.
28 }); 26 }
29 return; 27 });
30 } 28 // Send message for processing.
31 postResponse(serviceRequest.response, cookie); 29 service.route(message);
32 } 30 }
33 31
34 main() { 32 main() {
35 // Create VmService. 33 // Create VmService.
36 var service = new VMService(); 34 var service = new VMService();
37 _receivePort = service.receivePort; 35 _receivePort = service.receivePort;
38 _requestPort = new RawReceivePort((message) { 36 _requestPort = new RawReceivePort((message) {
39 if (message == null) { 37 if (message == null) {
40 return; 38 return;
41 } 39 }
42 if (message is! List) { 40 if (message is! List) {
43 return; 41 return;
44 } 42 }
45 if (message.length != 2) { 43 if (message.length != 2) {
46 return; 44 return;
47 } 45 }
48 var uri = message[0]; 46 if (message[0] is! String) {
49 if (uri is! String) {
50 return; 47 return;
51 } 48 }
49 var uri = Uri.parse(message[0]);
52 var cookie = message[1]; 50 var cookie = message[1];
53 handleRequest(service, uri, cookie); 51 handleMessage(service, uri, cookie);
54 }); 52 });
55 } 53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698