Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
use vm_service_client to talk to Observatory
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo committed Feb 16, 2016
1 parent 196ffbe commit f3dfba4
Show file tree
Hide file tree
Showing 9 changed files with 279 additions and 356 deletions.
24 changes: 15 additions & 9 deletions lib/src/collect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ library coverage.collect;

import 'dart:async';

import 'devtools.dart';
import 'vm_service_client.dart';
import 'util.dart';

const _retryInterval = const Duration(milliseconds: 200);

Future<Map> collect(String host, int port, bool resume, bool waitPaused,
{Duration timeout}) async {
var uri = 'ws://$host:$port/ws';

var vmService = await retry(
() => VMService.connect(host, port), _retryInterval,
() => VMServiceClient.connect(uri), _retryInterval,
timeout: timeout);
try {
if (waitPaused) {
Expand All @@ -30,30 +32,34 @@ Future<Map> collect(String host, int port, bool resume, bool waitPaused,
}
}

Future<Map> _getAllCoverage(VMService service) async {
Future<Map> _getAllCoverage(VMServiceClient service) async {
var vm = await service.getVM();
var allCoverage = [];

for (var isolateRef in vm.isolates) {
var coverage = await service.getCoverage(isolateRef.id);
var isolate = await isolateRef.load();
var coverage = await service.getCoverage(isolate);
allCoverage.addAll(coverage.coverage);
}
return {'type': 'CodeCoverage', 'coverage': allCoverage};
}

Future _resumeIsolates(VMService service) async {
Future _resumeIsolates(VMServiceClient service) async {
var vm = await service.getVM();
for (var isolateRef in vm.isolates) {
await service.resume(isolateRef.id);
var isolate = await isolateRef.load();
if (isolate.isPaused) {
await isolateRef.resume();
}
}
}

Future _waitIsolatesPaused(VMService service, {Duration timeout}) async {
Future _waitIsolatesPaused(VMServiceClient service, {Duration timeout}) async {
allPaused() async {
var vm = await service.getVM();
for (var isolateRef in vm.isolates) {
var isolate = await service.getIsolate(isolateRef.id);
if (!isolate.paused) throw "Unpaused isolates remaining.";
var isolate = await isolateRef.load();
if (!isolate.isPaused) throw "Unpaused isolates remaining.";
}
}
return retry(allPaused, _retryInterval, timeout: timeout);
Expand Down
319 changes: 0 additions & 319 deletions lib/src/devtools.dart

This file was deleted.

Loading

0 comments on commit f3dfba4

Please sign in to comment.