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

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

Issue 474633002: Optional binary payloads in VM service events. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 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_html; 5 library service_html;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:html'; 9 import 'dart:html';
10 import 'dart:typed_data';
10 11
11 import 'package:observatory/service_common.dart'; 12 import 'package:observatory/service_common.dart';
12 13
13 // Export the service library. 14 // Export the service library.
14 export 'package:observatory/service_common.dart'; 15 export 'package:observatory/service_common.dart';
15 16
16 class _HtmlWebSocket implements CommonWebSocket { 17 class _HtmlWebSocket implements CommonWebSocket {
17 WebSocket _webSocket; 18 WebSocket _webSocket;
18 19
19 void connect(String address, 20 void connect(String address,
(...skipping 10 matching lines...) Expand all
30 31
31 bool get isOpen => _webSocket.readyState == WebSocket.OPEN; 32 bool get isOpen => _webSocket.readyState == WebSocket.OPEN;
32 33
33 void send(dynamic data) { 34 void send(dynamic data) {
34 _webSocket.send(data); 35 _webSocket.send(data);
35 } 36 }
36 37
37 void close() { 38 void close() {
38 _webSocket.close(); 39 _webSocket.close();
39 } 40 }
41
42 Future<ByteData> nonStringToByteData(dynamic data) {
43 assert(data is Blob);
44 FileReader fileReader = new FileReader();
45 fileReader.readAsArrayBuffer(data);
46 return fileReader.onLoadEnd.first.then((e)
47 => new ByteData.view(fileReader.result));
48 }
40 } 49 }
41 50
42 /// The [WebSocketVM] communicates with a Dart VM over WebSocket. The Dart VM 51 /// The [WebSocketVM] communicates with a Dart VM over WebSocket. The Dart VM
43 /// can be embedded in Chromium or standalone. In the case of Chromium, we 52 /// can be embedded in Chromium or standalone. In the case of Chromium, we
44 /// make the service requests via the Chrome Remote Debugging Protocol. 53 /// make the service requests via the Chrome Remote Debugging Protocol.
45 class WebSocketVM extends CommonWebSocketVM { 54 class WebSocketVM extends CommonWebSocketVM {
46 WebSocketVM(WebSocketVMTarget target) : super(target, new _HtmlWebSocket()); 55 WebSocketVM(WebSocketVMTarget target) : super(target, new _HtmlWebSocket());
47 } 56 }
48 57
49 // A VM that communicates with the service via posting messages from DevTools. 58 // A VM that communicates with the service via posting messages from DevTools.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 message['id'] = idString; 90 message['id'] = idString;
82 message['method'] = 'observatoryQuery'; 91 message['method'] = 'observatoryQuery';
83 message['query'] = '$path'; 92 message['query'] = '$path';
84 _requestSerial++; 93 _requestSerial++;
85 var completer = new Completer(); 94 var completer = new Completer();
86 _pendingRequests[idString] = completer; 95 _pendingRequests[idString] = completer;
87 window.parent.postMessage(JSON.encode(message), '*'); 96 window.parent.postMessage(JSON.encode(message), '*');
88 return completer.future; 97 return completer.future;
89 } 98 }
90 } 99 }
OLDNEW
« no previous file with comments | « runtime/bin/vmservice/observatory/lib/service_common.dart ('k') | runtime/bin/vmservice/observatory/lib/service_io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698