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

Unified Diff: runtime/bin/vmservice/client/lib/service_io.dart

Issue 428613002: Enable using the service library from dart:io applications. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 months 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/client/lib/service_html.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/vmservice/client/lib/service_io.dart
===================================================================
--- runtime/bin/vmservice/client/lib/service_io.dart (revision 0)
+++ runtime/bin/vmservice/client/lib/service_io.dart (revision 0)
@@ -0,0 +1,50 @@
+// Copyright (c) 2014, 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 service_io;
+
+import 'dart:io';
+
+import 'package:observatory/service_common.dart';
+
+// Export the service library.
+export 'package:observatory/service_common.dart';
+
+class _IOWebSocket implements CommonWebSocket {
+ WebSocket _webSocket;
+
+ void connect(String address,
+ void onOpen(),
+ void onMessage(dynamic data),
+ void onError(),
+ void onClose()) {
+ WebSocket.connect(address).then((WebSocket socket) {
+ _webSocket = socket;
+ _webSocket.listen(
+ onMessage,
+ onError: (dynamic) => onError(),
+ onDone: onClose,
+ cancelOnError: true);
+ onOpen();
+ });
+ }
+
+ bool get isOpen =>
+ (_webSocket != null) && (_webSocket.readyState == WebSocket.OPEN);
+
+ void send(dynamic data) {
+ _webSocket.add(data);
+ }
+
+ void close() {
+ _webSocket.close();
+ }
+}
+
+/// The [WebSocketVM] communicates with a Dart VM over WebSocket. The Dart VM
+/// can be embedded in Chromium or standalone. In the case of Chromium, we
+/// make the service requests via the Chrome Remote Debugging Protocol.
+class WebSocketVM extends CommonWebSocketVM {
+ WebSocketVM(WebSocketVMTarget target) : super(target, new _IOWebSocket());
+}
« no previous file with comments | « runtime/bin/vmservice/client/lib/service_html.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698