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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/resources.h ('k') | no next file » | 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
new file mode 100644
index 0000000000000000000000000000000000000000..c1520ec674288aa9735a014729c965611cd7db13
--- /dev/null
+++ b/runtime/bin/vmservice/vmservice_dartium.dart
@@ -0,0 +1,60 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library vmservice_dartium;
+
+import 'dart:isolate';
+import 'vmservice.dart';
+
+// The receive port that isolate startup / shutdown messages are delivered on.
+RawReceivePort _receivePort;
+// The receive port that service request messages are delivered on.
+RawReceivePort _requestPort;
+
+// The native method that is called to post the response back to DevTools.
+void postResponse(String response, int cookie) native "PostResponse";
+
+void handleRequest(service, String uri, cookie) {
+ var serviceRequest = new ServiceRequest();
+ var r = serviceRequest.parse(Uri.parse(uri));
+ if (!r) {
+ // Did not understand the request uri.
+ serviceRequest.setErrorResponse('Invalid request uri: ${uri}');
+ } else {
+ var f = service.runningIsolates.route(serviceRequest);
+ if (f != null) {
+ f.then((_) {
+ postResponse(serviceRequest.response, cookie);
+ }).catchError((e) { });
+ return;
+ } else {
+ // Nothing responds to this type of request.
+ serviceRequest.setErrorResponse('No route for: $uri');
+ }
+ }
+ postResponse(serviceRequest.response, cookie);
+}
+
+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);
+ });
+}
« 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