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

Side by Side Diff: runtime/observatory/tests/service/test_helper.dart

Issue 1241673003: Async-step, first cut. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // VMOptions=--compile_all --error_on_bad_type --error_on_bad_override --checked 4 // VMOptions=--compile_all --error_on_bad_type --error_on_bad_override --checked
5 5
6 library test_helper; 6 library test_helper;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'dart:io'; 10 import 'dart:io';
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 vm.getEventStream(streamId).then((stream) { 148 vm.getEventStream(streamId).then((stream) {
149 var subscription; 149 var subscription;
150 subscription = stream.listen((ServiceEvent event) { 150 subscription = stream.listen((ServiceEvent event) {
151 handler(event, subscription, completer); 151 handler(event, subscription, completer);
152 }); 152 });
153 }); 153 });
154 return completer.future; 154 return completer.future;
155 } 155 }
156 156
157 157
158 Future<Isolate> hasStoppedAtBreakpoint(Isolate isolate) async { 158 Future<Isolate> hasStoppedAtBreakpoint(Isolate isolate) {
Cutch 2015/07/15 17:04:23 why remove async? why switch from using await to u
159 await isolate.reload(); // Might have missed pauseEvent.
160
161 if ((isolate.pauseEvent != null) &&
162 (isolate.pauseEvent.kind == ServiceEvent.kPauseBreakpoint)) {
163 // Already waiting at a breakpoint.
164 print('Breakpoint reached');
165 return new Future.value(isolate);
166 }
167
168 // Set up a listener to wait for breakpoint events. 159 // Set up a listener to wait for breakpoint events.
169 Completer completer = new Completer(); 160 Completer completer = new Completer();
170 isolate.vm.getEventStream(VM.kDebugStream).then((stream) { 161 isolate.vm.getEventStream(VM.kDebugStream).then((stream) {
171 var subscription; 162 var subscription;
172 subscription = stream.listen((ServiceEvent event) { 163 subscription = stream.listen((ServiceEvent event) {
164 print("Event: $event");
173 if (event.kind == ServiceEvent.kPauseBreakpoint) { 165 if (event.kind == ServiceEvent.kPauseBreakpoint) {
174 print('Breakpoint reached'); 166 print('Breakpoint reached');
175 subscription.cancel(); 167 subscription.cancel();
176 completer.complete(); 168 if (completer != null) {
169 completer.complete(isolate);
170 completer = null;
171 }
177 } 172 }
178 }); 173 });
174
175 // Pause may have happened before we subscribed.
176 isolate.reload().then((_) {
177 if ((isolate.pauseEvent != null) &&
178 (isolate.pauseEvent.kind == ServiceEvent.kPauseBreakpoint)) {
179 // Already waiting at a breakpoint.
180 print('Breakpoint reached');
181 subscription.cancel();
182 if (completer != null) {
183 completer.complete(isolate);
184 completer = null;
185 }
186 }
187 });
179 }); 188 });
180 189
181 return completer.future; // Will complete when breakpoint hit. 190 return completer.future; // Will complete when breakpoint hit.
182 } 191 }
183 192
184 193
185 Future<Isolate> resumeIsolate(Isolate isolate) { 194 Future<Isolate> resumeIsolate(Isolate isolate) {
186 Completer completer = new Completer(); 195 Completer completer = new Completer();
187 isolate.vm.getEventStream(VM.kDebugStream).then((stream) { 196 isolate.vm.getEventStream(VM.kDebugStream).then((stream) {
188 var subscription; 197 var subscription;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 }, onError: (e, st) { 258 }, onError: (e, st) {
250 process.requestExit(); 259 process.requestExit();
251 if (!_isWebSocketDisconnect(e)) { 260 if (!_isWebSocketDisconnect(e)) {
252 print('Unexpected exception in service tests: $e $st'); 261 print('Unexpected exception in service tests: $e $st');
253 throw e; 262 throw e;
254 } 263 }
255 }); 264 });
256 }); 265 });
257 } 266 }
258 } 267 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698