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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/vmservice/vmservice.dart ('k') | runtime/bin/vmservice/vmservice_io.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/vmservice/vmservice_dartium.dart
diff --git a/runtime/bin/vmservice/vmservice_dartium.dart b/runtime/bin/vmservice/vmservice_dartium.dart
index 249455dd9bb85e6996705e2f1488957a2d237e1f..99f04fa8dbcf686e90d013159f8e8b7a9f481caf 100644
--- a/runtime/bin/vmservice/vmservice_dartium.dart
+++ b/runtime/bin/vmservice/vmservice_dartium.dart
@@ -15,41 +15,44 @@ RawReceivePort _requestPort;
// The native method that is called to post the response back to DevTools.
void postResponse(String response, int cookie) native "VMService_PostResponse";
-void handleRequest(service, String uri, cookie) {
- var serviceRequest = new ServiceRequest();
- var r = serviceRequest.parse(Uri.parse(uri));
- if (r) {
- var f = service.runningIsolates.route(serviceRequest);
- assert(f != null);
- f.then((_) {
- postResponse(serviceRequest.response, cookie);
- }).catchError((e) {
- // Error posting response back to Dartium.
+/// Dartium recieves messages through the _requestPort and posts
+/// responses via postResponse. It has a single persistent client.
+class DartiumClient extends Client {
+ DartiumClient(port, service) : super(service) {
+ port.handler = ((message) {
+ if (message == null) {
+ return;
+ }
+ if (message is! List) {
+ return;
+ }
+ if (message.length != 2) {
+ return;
+ }
+ if (message[0] is! String) {
+ return;
+ }
+ var uri = Uri.parse(message[0]);
+ var cookie = message[1];
+ onMessage(cookie, new Message.fromUri(uri));
});
- return;
}
- postResponse(serviceRequest.response, cookie);
+
+ void post(var seq, String response) {
+ postResponse(response, seq);
+ }
+
+ dynamic toJson() {
+ var map = super.toJson();
+ map['type'] = 'DartiumClient';
+ }
}
+
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;
- }
- var cookie = message[1];
- handleRequest(service, uri, cookie);
- });
+ _requestPort = new RawReceivePort();
+ new DartiumClient(_requestPort, service);
}
« no previous file with comments | « runtime/bin/vmservice/vmservice.dart ('k') | runtime/bin/vmservice/vmservice_io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698