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

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

Issue 340443006: Add support for asynchronous event notification to the observatory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 10
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 socket.onClose.first.then((_) { 88 socket.onClose.first.then((_) {
89 _socketFuture = null; 89 _socketFuture = null;
90 }); 90 });
91 completer.complete(socket); 91 completer.complete(socket);
92 }); 92 });
93 socket.onError.first.then((_) { 93 socket.onError.first.then((_) {
94 _socketFuture = null; 94 _socketFuture = null;
95 }); 95 });
96 } 96 }
97 97
98 void _handleMessage(MessageEvent event) { 98 void _handleMessage(MessageEvent message) {
99 var map = JSON.decode(event.data); 99 var map = JSON.decode(message.data);
100 int seq = map['seq']; 100 int seq = map['seq'];
101 var response = map['response']; 101 var response = map['response'];
102 if (seq == null) {
103 // Messages without sequence numbers are asynchronous events
104 // from the vm.
105 postEventMessage(response);
106 return;
107 }
102 var completer = _pendingRequests.remove(seq); 108 var completer = _pendingRequests.remove(seq);
103 if (completer == null) { 109 if (completer == null) {
104 Logger.root.severe('Received unexpected message: ${map}'); 110 Logger.root.severe('Received unexpected message: ${map}');
105 } else { 111 } else {
106 completer.complete(response); 112 completer.complete(response);
107 } 113 }
108 } 114 }
109 115
110 Future<String> getString(String id) { 116 Future<String> getString(String id) {
111 if (_socketFuture == null) { 117 if (_socketFuture == null) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 message['id'] = idString; 169 message['id'] = idString;
164 message['method'] = 'observatoryQuery'; 170 message['method'] = 'observatoryQuery';
165 message['query'] = '$path'; 171 message['query'] = '$path';
166 _requestSerial++; 172 _requestSerial++;
167 var completer = new Completer(); 173 var completer = new Completer();
168 _pendingRequests[idString] = completer; 174 _pendingRequests[idString] = completer;
169 window.parent.postMessage(JSON.encode(message), '*'); 175 window.parent.postMessage(JSON.encode(message), '*');
170 return completer.future; 176 return completer.future;
171 } 177 }
172 } 178 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698