| OLD | NEW |
| 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_html; | 5 library service_html; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'dart:typed_data'; | 9 import 'dart:typed_data'; |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 void close() { | 34 void close() { |
| 35 _webSocket.close(); | 35 _webSocket.close(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 Future<ByteData> nonStringToByteData(dynamic data) { | 38 Future<ByteData> nonStringToByteData(dynamic data) { |
| 39 assert(data is Blob); | 39 assert(data is Blob); |
| 40 FileReader fileReader = new FileReader(); | 40 FileReader fileReader = new FileReader(); |
| 41 fileReader.readAsArrayBuffer(data); | 41 fileReader.readAsArrayBuffer(data); |
| 42 return fileReader.onLoadEnd.first.then((e) { | 42 return fileReader.onLoadEnd.first.then((e) { |
| 43 var result = fileReader.result; | 43 Uint8List result = fileReader.result as Uint8List; |
| 44 return new ByteData.view( | 44 return new ByteData.view( |
| 45 result.buffer, result.offsetInBytes, result.length); | 45 result.buffer, result.offsetInBytes, result.length); |
| 46 }); | 46 }); |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 | 49 |
| 50 /// The [WebSocketVM] communicates with a Dart VM over WebSocket. The Dart VM | 50 /// The [WebSocketVM] communicates with a Dart VM over WebSocket. The Dart VM |
| 51 /// can be embedded in Chromium or standalone. In the case of Chromium, we | 51 /// can be embedded in Chromium or standalone. In the case of Chromium, we |
| 52 /// make the service requests via the Chrome Remote Debugging Protocol. | 52 /// make the service requests via the Chrome Remote Debugging Protocol. |
| 53 class WebSocketVM extends CommonWebSocketVM { | 53 class WebSocketVM extends CommonWebSocketVM { |
| 54 WebSocketVM(WebSocketVMTarget target) : super(target, new _HtmlWebSocket()); | 54 WebSocketVM(WebSocketVMTarget target) : super(target, new _HtmlWebSocket()); |
| 55 } | 55 } |
| OLD | NEW |