Commit b7ababe6 authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Remove unused DevFsProgressReporter (#11249)

Discovered dead code during review of #10791
parent 5756d629
......@@ -16,8 +16,6 @@ import 'dart/package_map.dart';
import 'globals.dart';
import 'vmservice.dart';
typedef void DevFSProgressReporter(int progress, int max);
class DevFSConfig {
/// Should DevFS assume that symlink targets are stable?
bool cacheSymlinks = false;
......@@ -240,23 +238,18 @@ class _DevFSHttpWriter {
Map<Uri, DevFSContent> _outstanding;
Completer<Null> _completer;
HttpClient _client;
int _done;
int _max;
Future<Null> write(Map<Uri, DevFSContent> entries,
{DevFSProgressReporter progressReporter}) async {
Future<Null> write(Map<Uri, DevFSContent> entries) async {
_client = new HttpClient();
_client.maxConnectionsPerHost = kMaxInFlight;
_completer = new Completer<Null>();
_outstanding = new Map<Uri, DevFSContent>.from(entries);
_done = 0;
_max = _outstanding.length;
_scheduleWrites(progressReporter);
_scheduleWrites();
await _completer.future;
_client.close();
}
void _scheduleWrites(DevFSProgressReporter progressReporter) {
void _scheduleWrites() {
while (_inFlight < kMaxInFlight) {
if (_outstanding.isEmpty) {
// Finished.
......@@ -264,15 +257,14 @@ class _DevFSHttpWriter {
}
final Uri deviceUri = _outstanding.keys.first;
final DevFSContent content = _outstanding.remove(deviceUri);
_scheduleWrite(deviceUri, content, progressReporter);
_scheduleWrite(deviceUri, content);
_inFlight++;
}
}
Future<Null> _scheduleWrite(
Uri deviceUri,
DevFSContent content,
DevFSProgressReporter progressReporter, [
DevFSContent content, [
int retry = 0,
]) async {
try {
......@@ -293,21 +285,17 @@ class _DevFSHttpWriter {
} catch (e) {
if (retry < kMaxRetries) {
printTrace('Retrying writing "$deviceUri" to DevFS due to error: $e');
_scheduleWrite(deviceUri, content, progressReporter, retry + 1);
_scheduleWrite(deviceUri, content, retry + 1);
return;
} else {
printError('Error writing "$deviceUri" to DevFS: $e');
}
}
if (progressReporter != null) {
_done++;
progressReporter(_done, _max);
}
_inFlight--;
if ((_outstanding.isEmpty) && (_inFlight == 0)) {
_completer.complete(null);
} else {
_scheduleWrites(progressReporter);
_scheduleWrites();
}
}
}
......@@ -372,10 +360,11 @@ class DevFS {
}
/// Update files on the device and return the number of bytes sync'd
Future<int> update({ DevFSProgressReporter progressReporter,
AssetBundle bundle,
bool bundleDirty: false,
Set<String> fileFilter}) async {
Future<int> update({
AssetBundle bundle,
bool bundleDirty: false,
Set<String> fileFilter,
}) async {
// Mark all entries as possibly deleted.
for (DevFSContent content in _entries.values) {
content._exists = false;
......@@ -440,8 +429,7 @@ class DevFS {
printTrace('Updating files');
if (_httpWriter != null) {
try {
await _httpWriter.write(dirtyEntries,
progressReporter: progressReporter);
await _httpWriter.write(dirtyEntries);
} on SocketException catch (socketException, stackTrace) {
printTrace("DevFS sync failed. Lost connection to device: $socketException");
throw new DevFSException('Lost connection to device.', socketException, stackTrace);
......@@ -457,17 +445,6 @@ class DevFS {
if (operation != null)
_pendingOperations.add(operation);
});
if (progressReporter != null) {
final int max = _pendingOperations.length;
int complete = 0;
_pendingOperations.forEach((Future<dynamic> f) => f.whenComplete(() {
// TODO(ianh): If one of the pending operations fail, we'll keep
// calling progressReporter long after update() has completed its
// future, assuming that doesn't crash the app.
complete += 1;
progressReporter(complete, max);
}));
}
await Future.wait(_pendingOperations, eagerError: true);
_pendingOperations.clear();
}
......
......@@ -314,7 +314,6 @@ class FlutterDevice {
}
Future<bool> updateDevFS({
DevFSProgressReporter progressReporter,
AssetBundle bundle,
bool bundleDirty: false,
Set<String> fileFilter
......@@ -326,7 +325,6 @@ class FlutterDevice {
int bytes = 0;
try {
bytes = await devFS.update(
progressReporter: progressReporter,
bundle: bundle,
bundleDirty: bundleDirty,
fileFilter: fileFilter
......
......@@ -12,7 +12,6 @@ import 'base/logger.dart';
import 'base/utils.dart';
import 'build_info.dart';
import 'dart/dependencies.dart';
import 'devfs.dart';
import 'device.dart';
import 'globals.dart';
import 'resident_runner.dart';
......@@ -223,7 +222,7 @@ class HotRunner extends ResidentRunner {
return devFSUris;
}
Future<bool> _updateDevFS({ DevFSProgressReporter progressReporter }) async {
Future<bool> _updateDevFS() async {
if (!_refreshDartDependencies()) {
// Did not update DevFS because of a Dart source error.
return false;
......@@ -238,7 +237,6 @@ class HotRunner extends ResidentRunner {
for (FlutterDevice device in flutterDevices) {
final bool result = await device.updateDevFS(
progressReporter: progressReporter,
bundle: assetBundle,
bundleDirty: rebuildBundle,
fileFilter: _dartDependencies,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment