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

Side by Side Diff: runtime/bin/vmservice/observatory/lib/service_io.dart

Issue 575853002: Add tools/ddbg_service. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: gen js Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 service_io; 5 library service_io;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'dart:typed_data'; 9 import 'dart:typed_data';
10 10
(...skipping 11 matching lines...) Expand all
22 void onError(), 22 void onError(),
23 void onClose()) { 23 void onClose()) {
24 WebSocket.connect(address).then((WebSocket socket) { 24 WebSocket.connect(address).then((WebSocket socket) {
25 _webSocket = socket; 25 _webSocket = socket;
26 _webSocket.listen( 26 _webSocket.listen(
27 onMessage, 27 onMessage,
28 onError: (dynamic) => onError(), 28 onError: (dynamic) => onError(),
29 onDone: onClose, 29 onDone: onClose,
30 cancelOnError: true); 30 cancelOnError: true);
31 onOpen(); 31 onOpen();
32 }).catchError((e, st) {
33 onError();
32 }); 34 });
33 } 35 }
34 36
35 bool get isOpen => 37 bool get isOpen =>
36 (_webSocket != null) && (_webSocket.readyState == WebSocket.OPEN); 38 (_webSocket != null) && (_webSocket.readyState == WebSocket.OPEN);
37 39
38 void send(dynamic data) { 40 void send(dynamic data) {
39 _webSocket.add(data); 41 _webSocket.add(data);
40 } 42 }
41 43
42 void close() { 44 void close() {
43 _webSocket.close(); 45 if (_webSocket != null) {
46 _webSocket.close();
47 }
44 } 48 }
45 49
46 Future<ByteData> nonStringToByteData(dynamic data) { 50 Future<ByteData> nonStringToByteData(dynamic data) {
47 assert(data is Uint8List); 51 assert(data is Uint8List);
48 print('nonString: ${data.lengthInBytes}, $data'); 52 print('nonString: ${data.lengthInBytes}, $data');
49 return new Future.sync(() => 53 return new Future.sync(() =>
50 new ByteData.view(data.buffer, 54 new ByteData.view(data.buffer,
51 data.offsetInBytes, 55 data.offsetInBytes,
52 data.lengthInBytes)); 56 data.lengthInBytes));
53 } 57 }
54 } 58 }
55 59
56 /// The [WebSocketVM] communicates with a Dart VM over WebSocket. The Dart VM 60 /// The [WebSocketVM] communicates with a Dart VM over WebSocket. The Dart VM
57 /// can be embedded in Chromium or standalone. In the case of Chromium, we 61 /// can be embedded in Chromium or standalone. In the case of Chromium, we
58 /// make the service requests via the Chrome Remote Debugging Protocol. 62 /// make the service requests via the Chrome Remote Debugging Protocol.
59 class WebSocketVM extends CommonWebSocketVM { 63 class WebSocketVM extends CommonWebSocketVM {
60 WebSocketVM(WebSocketVMTarget target) : super(target, new _IOWebSocket()); 64 WebSocketVM(WebSocketVMTarget target) : super(target, new _IOWebSocket());
61 } 65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698